Monitor number of threads in Linux
-- Monitor Number of threads per user
ps h -Led -o user | sort | uniq -c | sort -n
ps h -Led -o user | sort | uniq -c | sort -n | awk '{ print $2}'
-- Show Currently running threads of a particular user
ps -o nlwp,pid,lwp,args -u alfresco | sort -n
-- Show threads per user
#!/bin/bash
# lagay sa isang array
var=($(ps h -Led -o user | sort | uniq -c | sort -n | awk '{ print $2}'))
#iterate yong array
for i in ${var[@]}
do
ps -o nlwp,pid,lwp,args -u $i | sort -n
done