while [ 1 ]; do date; cat /proc/loadavg; ps -Leo pid,state,args | awk ' $2 ~ /(D|R)/ {state[$2 " - (" $1 ") " $NF]++} \ END{ for (j in state) {printf "%s - %d\n", j, state[j]}}' | sort -k 2; echo "---"; sleep 5; done
Kind of my extended memory with thoughts mostly on Linux and related technologies. You might also find some other stuff, a bit of SF, astronomy as well as old (quantum) chemistry posts.
Search This Blog
Friday, December 27, 2013
Even more threads counting
This is small extension to one of my previous posts. This time a loop is enriched by load values (from /proc/loadavg) as well as measurement time (date). ps command uses the same option, but there is small improvement in awk call. Rather than count only processes per state it concatenate state with last string in command arguments — I was mostly interested in few java application and jar name was the last parameter for each one. Also awk counts only processes actually running or in uninterruptible sleep ($2 ~ /(D|R)/ at the beginning of awk command).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment