1827871 Members
1242 Online
109969 Solutions
New Discussion

sar usage

 
SOLVED
Go to solution
Danny Fang
Frequent Advisor

sar usage

Hi,

I would like to measure the CPU utilization over a period of time (by specifying the start and end times).

May I know how do I specify the options to the "sar" command to in order not to specify the referenced log file? This is because I'm only interested in measuring the CPU utilization of particular time frame.Attached is the text file containing the error output when specifying the -s and -e options without the -f option for the log file.

Also,how to use sar to measure the CPU utilization for a particular application?

Could anyone kindly help me out?

3 REPLIES 3
Ivan Ferreira
Honored Contributor

Re: sar usage

If I understood right, what you want to is not possible with the sar command. Do you want to collect performance statistics for a specific time?

The -s and -e options are only valid when you analyze a log file.

If you want to collect performance counters for a specific time, you should use the sadc command in a crontab entry.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Raj D.
Honored Contributor
Solution

Re: sar usage

Hi Danny ,

You can use sar to capture the CPU usage data over a long time.
vmstat for Virtual Memory statistics.
iostat for io statistics.

###########################################
#!/usr/bin/ksh
touch sar_cpu.txt ; touch vmstat.txt ; touch iostat.txt
i=0
while [ $i -le 60 ]
do
sar -u 5 12 >>sar_cpu.txt # 5 second interval .
vmstat 5 12 >> vmstat.txt
iostat 5 12 >> iostat.txt
echo "-----------------------"
i=`expr $i + 1`
done
echo " SAR data collected for 1 hr complete "
echo " CPU Data stored in the file sar_cpu.txt "
echo "Vmstat Data stored in the file vmstat.txt "
echo "iostat Data stored in the file iostat.txt "
echo "------------------------------------"

###########################################

You cannot measure the CPU utilisation for a particular application through sar , but hope you can do it with top , ps command. grep for cpu usage and sort the output.

cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Alessandro Pilati
Esteemed Contributor

Re: sar usage

Danny,
use this syntax to have a complete report for sar ( included CPU utilization ):

sar -o sarfile 5 60
sar -Af sarfile > sar.report

Then have a look to the file sar.report

For the interpretation, have a look to the CPU section

Rgds,
Alex
if you don't try, you'll never know if you are able to