Operating System - HP-UX
1833383 Members
3504 Online
110052 Solutions
New Discussion

%CPU usage for a specific process

 
Bijoy_1
Occasional Contributor

%CPU usage for a specific process

Hello friends,
How to calculate the %cpu usage for a particular process.I'm running apache.There are around 16 httpd process running at a given time.I want to find the aggregate of %cpu fot this.Top is not listing the %cpu usage for this process, and the utilisation is very less.Any help will be appreciated.
Thanks,
4 REPLIES 4
Patrick Wallek
Honored Contributor

Re: %CPU usage for a specific process

I would inverst in the GlancePlus Pak software for this. With the Glance software you can see the amount of CPU Usage for all processes at that time. The Measureware software will keep a history of usage so you can go back a few days, weeks, or months (depending on how big you make your log files) and see historical process usage.

You can find more information on GlancePlus Pak here:
http://www.openview.hp.com/products/gppak2k/index.html
Sridhar Bhaskarla
Honored Contributor

Re: %CPU usage for a specific process

Hi Bijoy,

The best way is to use 'measureware'. If you have it, group all 'httpd' processes together as an 'application' in /var/opt/perf/parm file and restart measureware. Once the datacollection is started, you can extract the stats using the command 'extract'. It's a easy-to-use tool. There are some examples in parm file so it shouldn't be a problem for you to configure an additional application.

If you don't have measureware, you can use XPG's version of 'ps' to collect the samples.

UNIX95= ps -C "httpd" -o "pcpu" |sed '1d' |awk '{sum += $1} END {print sum}'

However, customizing measureware is the best solution as you can get quite few metrics in addition to CPU usage.


-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Bijoy_1
Occasional Contributor

Re: %CPU usage for a specific process

Hi Sri/Patrick,
Thanks for the answer.The command works fine.
I've already configured the gpm and 'm using perfiew to monitor the usage.I wanted my own script to monitor this, and this works fine.
Now I've one more question.When i monitor apache using apache status tool, the cpu load is shown as 80% and the calculated %cpu value using the ps command is 0.21%.
The cpu load sometimes goin to 120% also.So how to interpret the cpu load from apache and %cpu calculated using the command given ?
Thanks,
Bijoy
Fred Ruffet
Honored Contributor

Re: %CPU usage for a specific process

system load and process working pcu percentage are different :
. pcpu is the time the cpu have been used for the process for the time it has been given the cpu. Due to multi-thread processes, and to the fact, that a line in top is a process (maybe multi-thread), a process can be shown using 120% (one thread using 80% other 40%).
. System load is the number of processes that have been in a running state during the mesure time. 5 processes having a pcpu of 100% during the mesure time will give a load of 500% (5).

Note that for a multi-cpu box, you will have a difference between load and load average, where load average is the average of the loads of each processor.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)