1825775 Members
2035 Online
109687 Solutions
New Discussion

Re: SAR Command help.

 
joe_91
Super Advisor

SAR Command help.

Team:

I need to capture total cpu utilization and Load Average on the box using SAR. Can someone help me with the commands?

Thanks

Joe.
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: SAR Command help.

The attached script does this and more.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Sridhar Bhaskarla
Honored Contributor

Re: SAR Command help.

Hi Joe,

sar -uq 5 10

will print 10 iterations of Utilization and Queue metrics (first and second row of each iteration respectively).

If you want to collect the stats over a period of time, then you will need to enable sar in cron. Look at the man page of 'sa1' and how it can be implemented in cron. Once the data is being collected through cron (it will be output to /var/adm/sa), you can extract the previous information with the sar command (look at -s and -e options of sar)

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
doug mielke
Respected Contributor

Re: SAR Command help.

the sa1 history will be valuable.
an alternative is to run for command line redirected to file.

sar -A 30 5000 > /tmp/outfile
joe_91
Super Advisor

Re: SAR Command help.

Team:

Thanks for the reply. What i am trying to do is to put a simple command in a script to find out the cpu utilization ans load and based on that i am trying to connect to different machines. I hope i am clear. The bottomline is if machine a's load is more than machine d then the connection would go to ,machine d. That is what i am trying to achieve.

Thanks Again,

Joe.
doug mielke
Respected Contributor

Re: SAR Command help.

use of the sa1 history will be easy. If you script from the command line, you'll have to run sar in the background, then query its output file to see instantanious load.

or
If you tail the last entry of the sar history,
sar -f /var/adm/sa/sa02
you'll be able to see the average load over prior 20 mins. ( time of this is configurable, as in the man sa1)
John Dvorchak
Honored Contributor

Re: SAR Command help.

I am not really sure what you are asking but if you just want to take a snapshop of a system you can use sar:

sar -u 1 1

means get cpu stats 1 time for 1 second and looks like this:

root> sar -u 1 1

HP-UX servername B.11.11 U 9000/800 02/03/04

16:27:05 %usr %sys %wio %idle
16:27:06 8 2 0 90
If it has wheels or a skirt, you can't afford it.