1829889 Members
2543 Online
109993 Solutions
New Discussion

problem with sar

 

problem with sar

Hi guys,

I have written 2 simple scripts to run 24X7 and collect CPU and disk usage data using sar on my L2000, 2CPU 64Bit HP-UX 11.00 server.

What I expected was I will be having CPU's usage in cpu_log.... and disk usage stats in disk_log...

But, sar had written same data in both the files. I wonder where the mistake is.

Please help me out.

bye,
Raghu.

PS: Here is the code :
1. mon_cpu.sh

while true
do

sar -u -M -o /opt/admin/REPORTS/CPUREP/cpu_log.`date +%d%m%y%X` 600 144
done

2. mon_disk.sh
while true
do
sar -d -o /opt/admin/REPORTS/DISKREP/disk_log.`date +%d%m%y%X` 600 144
done

I launched the scripts as :
./mon_cpu.sh 1>>/dev/null 2>&1 &
./mon_disk.sh 1>>/dev/null 2>&1 &

Unix is not for those who donot love Unix!
5 REPLIES 5
Olivier LEGRAND
Frequent Advisor

Re: problem with sar

Hi,

Try not to run these scripts at the same time.

And verify the results.

Regards
Manoj P.U.
Advisor

Re: problem with sar



Dear Raghu

There is a simple script of os itself called sadc

You have to run the below command in background it will create files everyday with different name sa01, sa02 the numeric number is date of that particular day.

#/usr/lbin/sa/sadc 300 290 /var/adm/sa/sa`date +%d` &

This will create cpu, disk, swap buffer etc etc in one file under /var/adm/sa directory.

Afterwards you will have to do

#sar -A -f
To report all data.

More info you see #man sar and #man sadc

Regards

Manoj



Manoj P.U.
Paula J Frazer-Campbell
Honored Contributor

Re: problem with sar

Hi

Cron this to start at 05:00 and then all sar data will be writted to /var/adm/saXX file - XX being the day number of month.


---------------cut here-----------
#!/bin/sh

# 1 minute
period=${1:-"60"}


iterations=${2:-"`expr 86400 / $period`"}


echo "sar: $iterations iterations at $period second intervals"
/usr/sbin/sar -A \
-o /var/adm/sa/sa`date +%d` \
$period \
$iterations > /dev/null

---------------cut here------------

to look at yesterdays buffer data from sar then

sar -b -f /var/adm/sa/sa27

I have a script that will do a full month month extract of date from all the saXX files if you require it.


HTH

Paula
If you can spell SysAdmin then you is one - anon

Re: problem with sar

Thanks to you all
I shall try these options

bye,
Raghu.
Unix is not for those who donot love Unix!
harry d brown jr
Honored Contributor

Re: problem with sar

Gamoji,

With glance/measureware and perfview, you can capture the information you desire at a granularity unavailable with sar. sar, top, vmstat, iostat, will only collect data at the end of a processes timeslice, missing the hundreds of commands being executed (remember we are using risc technology - meaning in one tick you can have many commands being executed), whereas measureware has the hooks to capture this information. Plus with perfview, you can graph your performance.

sorry if I sound like an HP salesperson, it's just that I sometimes don't understand why people aren't willing to spend a few thousand dollars to make their jobs a lot easier, and in the long run saving themselves ten times or more the cost of the software.


live free or die
harry

Live Free or Die