Operating System - HP-UX
1826460 Members
3254 Online
109692 Solutions
New Discussion

Re: light load system call to check CPU load

 
Jean Zhou
New Member

light load system call to check CPU load

Hi,

I want to find out a light load system call which can be used to check out CPU
load on HP servers. I know shell command top can do the job. But top is too
heavy load. Please advice.

thanks,
Jean
7 REPLIES 7
Neil Gast_1
Frequent Advisor

Re: light load system call to check CPU load

Try sar(1M). It's about as low overhead as you can get. You can also put it in
a loop and watch resources over time, which is its most valuable feature.

Typing just sar at the root prompt will report on CPU activity. It can also
report on things like swapping, buffer cache, system calls, run queue, and some
kernel tables. See the man page.

MrNeil
Anthony Goonetilleke_1
Regular Advisor

Re: light load system call to check CPU load

I would agree with Neil sar is fairly light weight and very easy to use. I
have a little perl script which runs on a multiproccess machine via cron every
30 mins to gather some data which I use in an excel spreadsheet to report on
monthly performance.

#!/usr/local/bin/perl
# Author: Anthony Goonetilleke
# Desc: Get amount of cpu usage
###############################
$DATE=`date`;
chop($DATE);
@STATS=`/usr/bin/sar -uM 1 5`;
print ("START $DATE");
print "@STATS\n";
print ("END $DATE\n\n*****");
Alan Riggs_1
Regular Advisor

Re: light load system call to check CPU load

I also like sar for it's built in reporting functionality. I find it helpful
in generating formatted reports to track system usage over time. (mwa also
does this, of course, with significantly more refinement and significantly more
overhead). For command line troubleshooting, though, I prefer vmstat. More
information in a concise format with negligible overhead.
Jean Zhou
New Member

Re: light load system call to check CPU load

Hi,

Thanks for your suggestion. "sar" seems to be light
load. Is there any system call which I can
use in the C/C++ program to check cpu load
instead of making a system call?

thanks much again,
Jean
TBOSS
Occasional Advisor

Re: light load system call to check CPU load

Try
1. uptime : not continuously monitor CPU load.
2. vmstat : continuously monitor CPU load
For me, I use cron and uptime together.
TBOSS
Andy Monks
Honored Contributor

Re: light load system call to check CPU load

You can use the pstat() system call. Probably want to look at pstat_dynamic and pstat_vminfo

The pstat() man page gives some examples, but looking in /usr/include/sys/pstat.h gives the most info.

Andy
Anthony deRito
Respected Contributor

Re: light load system call to check CPU load

In addition to sar, you might want to use uptime command. Its nice because it shows an average number of jobs in the run queue over the last 1, 5 and 15 minutes. Its great for a history snapshot of load conditions.

Hope this helps.

Tony