Unix Technical Forum

Monitoring Process CPU Using `ps` ... Not Working?

This is a discussion on Monitoring Process CPU Using `ps` ... Not Working? within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi All, I'm trying to monitor the amount of CPU consumed by our Sun Java System Directory Server slapd ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 10:49 AM
Paul
 
Posts: n/a
Default Monitoring Process CPU Using `ps` ... Not Working?

Hi All,

I'm trying to monitor the amount of CPU consumed by our Sun Java System
Directory Server slapd process on AIX 5.2. The command I'm using is:

echo "`date +%H:%M:%S` `ps avg $PIDNUM | tail -1 | awk '{ print $6, $7,
$11, $12 }'`" >> ${FILEA}

Which produces output like this:

23:50:08 218336 218516 0.4 1.0
23:51:08 218336 218516 0.4 1.0
23:52:08 218336 218516 0.4 1.0
23:53:08 218336 218516 0.4 1.0
23:54:08 218336 218516 0.4 1.0
23:55:08 218336 218516 0.4 1.0
23:56:08 218336 218516 0.4 1.0
23:57:08 218336 218516 0.4 1.0
23:58:08 218336 218516 0.4 1.0
23:59:08 218336 218516 0.4 1.0

The strange thing I'm seeing is that since implementing this monitor
over a week ago, the PCPU (Precent CPU) field has *never* deviated from
0.4%. This is on a production system, and I know that traffic varies at
different times of the day. I can further validate this by using the
monitor script bundled with Directory Server, which shows number of
current connections, etc.

So my question is should I be trusting the output of ps, or might there
be something wrong?

Cheers!
Paul

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 10:50 AM
steven_nospam at Yahoo! Canada
 
Posts: n/a
Default Re: Monitoring Process CPU Using `ps` ... Not Working?


Paul wrote:
> I'm trying to monitor the amount of CPU consumed by our Sun Java System
> Directory Server slapd process on AIX 5.2. The command I'm using is:
>
> echo "`date +%H:%M:%S` `ps avg $PIDNUM | tail -1 | awk '{ print $6, $7,
> $11, $12 }'`" >> ${FILEA}
>
> Which produces output like this:
>
> 23:50:08 218336 218516 0.4 1.0
> 23:51:08 218336 218516 0.4 1.0
>


Hi Paul,

You can try the following commands instead, but I think it may end up
giving you pretty much the same results. I have not seen growth in a
daemon process that I have for EDI transfers nor to the qdaemon in the
short time I monitored it.

# echo "$(date +"%H:%M:%S) $(ps -p ${PIDNUM} -o "%p %c %C %x %z
%t"|tail -1)" >> ${FILEA}

The elapsed time will at least show you that the lines are not
duplicated all the time and are in fact unique.

Steve

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 10:50 AM
bennett.tony@cnf.com
 
Posts: n/a
Default Re: Monitoring Process CPU Using `ps` ... Not Working?


Paul wrote:
> Hi All,
>
> I'm trying to monitor the amount of CPU consumed by our Sun Java System
> Directory Server slapd process on AIX 5.2. The command I'm using is:
>
> echo "`date +%H:%M:%S` `ps avg $PIDNUM | tail -1 | awk '{ print $6, $7,
> $11, $12 }'`" >> ${FILEA}
>
> Which produces output like this:
>
> 23:50:08 218336 218516 0.4 1.0
> 23:51:08 218336 218516 0.4 1.0
> 23:52:08 218336 218516 0.4 1.0
> 23:53:08 218336 218516 0.4 1.0
> 23:54:08 218336 218516 0.4 1.0
> 23:55:08 218336 218516 0.4 1.0
> 23:56:08 218336 218516 0.4 1.0
> 23:57:08 218336 218516 0.4 1.0
> 23:58:08 218336 218516 0.4 1.0
> 23:59:08 218336 218516 0.4 1.0
>
> The strange thing I'm seeing is that since implementing this monitor
> over a week ago, the PCPU (Precent CPU) field has *never* deviated from
> 0.4%. This is on a production system, and I know that traffic varies at
> different times of the day. I can further validate this by using the
> monitor script bundled with Directory Server, which shows number of
> current connections, etc.
>
> So my question is should I be trusting the output of ps, or might there
> be something wrong?
>
> Cheers!
> Paul


Paul,

I don't think the Percent CPU value is what you expect.
It is NOT a snapshot of the percentage of CPU a process is using
NOW...
....it is the percentage of CPU a process has used over the LIFE of the
process.

>From AIX 5.1 & 5.3 man page on "ps":

%CPU
(u and v flags) The percentage of time the process has used the CPU
since the
process started. The value is computed by dividing the time the
process uses the CPU
by the elapsed time of the process. In a multi-processor environment,
the value is
further divided by the number of available CPUs because several
threads in the same
process can run on different CPUs at the same time. (Because the time
base over
which this data is computed varies, the sum of all %CPU fields can
exceed 100%.)

-tony

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:41 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com