top displays these numbers in its summary:
Tasks: 193 total, 1 running, 192 sleeping, 0 stopped, 0 zombie
I'm looking for a way to get them some other way -- running a program, parsing a /proc file.
Do you know of a way to get those numbers?
The closest I've been able to get is:
pgrep "" -c 192
and top & pgrep:
top -b -n 1 | head -n 2 | tail -n 1; pgrep "" -c
never agree ...
e.g. 194 vs 191
grep 'procs' /proc/stat procs_running 2 procs_blocked 0
And a mention of running, sleeping, stopped, zombie here: http://procps.cvs.sourceforge.net/viewvc/procps/procps/top.c?revision=1.134&view=markup#l1025
This grep turned up a match, sleeping is 192:
grep -R sleeping /proc/*/status | wc -l
but its way of doing sleeping and pgrep's way of doing total don't add up:
top -b -n 1 | head -n 2 | tail -n 1; pgrep "" -c; grep "procs" /proc/stat; grep -R sleeping /proc/*/status | wc -l