number of processes from sar?

3,339 views
Skip to first unread message

Robert Citek

unread,
Nov 14, 2012, 3:39:04 PM11/14/12
to CWE-LUG, SLUUG general discussion
These three commands capture about the same information: the number of
currently running processes:

# ls -d /proc/[0-9]* | wc -l ; /usr/lib64/nagios/plugins/check_procs ;
ps faux | wc -l
506
PROCS OK: 505 processes
507

Does sar collect that information?

The plist-sz from 'sar -q' would seem like the answer, but its numbers
are about 200 higher than what I'm measuring with the above commands.
I'm still looking through other options, but nothing stands out at
this point.

# sar -q | tail -2 | head -1
08:33:01 PM 2 704 0.44 0.43 0.38

Regards,
- Robert

Robert Citek

unread,
Nov 14, 2012, 7:15:19 PM11/14/12
to SLUUG general discussion, CWE-LUG
On Wed, Nov 14, 2012 at 5:35 PM, Seibel, Rich <ri...@mail.sluug.org> wrote:
> On Nov 14, 2012, at 2:39 PM, Robert Citek wrote:
>> These three commands capture about the same information: the number of
>> currently running processes:
>>
>> # ls -d /proc/[0-9]* | wc -l ; /usr/lib64/nagios/plugins/check_procs ;
>> ps faux | wc -l
>> 506
>> PROCS OK: 505 processes
>> 507
>>
>> Does sar collect that information?
>>
>
> Maybe sar is counting LWPs, all the threads in all the processes.

Possibly. If so, any thoughts on how to reconcile the numbers?
Although, I'm really only interested in processes and not threads.

Regards,
- Robert

Robert Citek

unread,
Nov 14, 2012, 9:58:22 PM11/14/12
to SLUUG general discussion, CWE-LUG
Looks like sar is indeed capturing all processes+threads.

# sar -o /tmp/zfoo.sar.data 1 2 >& /dev/null

# sar -f /tmp/zfoo.sar.data -q
Linux 2.6.32-25-server (P-MXS-01) 11/15/2012 _x86_64_ (8 CPU)

02:38:42 AM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
02:38:43 AM 0 587 0.32 0.49 0.47
02:38:44 AM 0 589 0.32 0.49 0.47
Average: 0 588 0.32 0.49 0.47

# ls -d /proc/[0-9]*/task/* | wc -l
590

# ls -d /proc/[0-9]* | wc -l ; /usr/lib64/nagios/plugins/check_procs ;
ps faux | wc -l
416
PROCS OK: 415 processes
417

That seems to solve that mystery. Now on to either getting sar to
record/display process (sans thread) counts or getting Nagios to
include thread counts.

Thanks, Rich and Charles.

Regards,
- Robert

On Wed, Nov 14, 2012 at 8:45 PM, Charles Sharp <cas.n...@gmail.com> wrote:
>
> Hi Robert,
>
> Instead of using /proc, you might want to count the pids under the
> /proc/<pid>/task
> directory. There will be at least one (for the pid itself), plus pids for
> the the Linux
> tasks.
>
> I didn't have time to play with it much, but here's a first pass:
>
> cas@rock-ubuntu120464:~$ sudo find /proc -name task -exec ls {} \; |wc -w
> 315
> cas@rock-ubuntu120464:~$ ls -d /proc/[0-9]* | wc -l
> 141
>
> interesting,
> cas
> _______________________________________________
> Discuss mailing list
> Dis...@sluug.org
> http://www.sluug.org/mailman/listinfo/discuss
>
>
>
> _______________________________________________
> Discuss mailing list
> Dis...@sluug.org
> http://www.sluug.org/mailman/listinfo/discuss
>
Reply all
Reply to author
Forward
0 new messages