Operating System - HP-UX
1753903 Members
9697 Online
108810 Solutions
New Discussion юеВ

Re: Can we get cpu usage through pstat_getprocessor

 
zdbao
New Member

Can we get cpu usage through pstat_getprocessor

I want to compute the cpu usage for a while.
First I get cpu number through pstat_getdynamic, secondly I call pstat_getprocessor to get all states's ticks of all cpus, including CPU_IDLE, CPU_USER, CPU_KERNEL, CPU_WAIT, and so on.
My computing method is: the difference of CPU_IDLE and CPU_WAIT is used as the numerator, and the whole difference of all states is used as the denominator.
But the result is obviously different from top or sar's output.
3 REPLIES 3
Emil Velez
Honored Contributor

Re: Can we get cpu usage through pstat_getprocessor

if you have a HPUX system check whether you have OVPA (formerly called measureware). you can do this with a command called perfstat. if it shows a process called midaemon and scope you have measureware.

The measureware product has already collected that data per processor every 5 minutes for 6 months.

If you do not have measureware check whether you purchased the Enterprise or Mission Critical OE. IF you did you are entitled to a license for OVPA and glance.

In addition you can use glance in advisor mode to print out CPU global and per cpu metrics on a recuring basis.

check out the sa1 man page

man sa1

on how to make sar collect data for you on a regular basis.

This way you have 3 options..

Good luck
Emil
zdbao
New Member

Re: Can we get cpu usage through pstat_getprocessor

Hi Emil,
Thank you for your advice. Now I want to get cpu usage through programming. I believe that some system calls can help me to achive it, but I still did not find them.
rick jones
Honored Contributor

Re: Can we get cpu usage through pstat_getprocessor

An unofficial thing do do would be to look at the HP-UX-specific code in netperf. Specifically:

http://www.netperf.org/svn/netperf2/trunk/src/netcpu_pstat.c

and the pstat_new.c versions.

If you would prefer GPL code, then you can look at:

http://www.netperf.org/svn/netperf4/trunk/src/netsysstats_hpux.c

Options for what you can/should use vary with release.
there is no rest for the wicked yet the virtuous have no pillows