1826204 Members
3030 Online
109691 Solutions
New Discussion

sar

 
roger_101
Occasional Contributor

sar

Hi

I'd like to use sar to generate a monthly report on CPU and memory utilization (and maybe smome other metrics).Does anyone have a cheat sheet on how to do this?

Thanks in advance for your reply.
6 REPLIES 6
Pete Randall
Outstanding Contributor

Re: sar

Roger,

You could start with the man page for sa1. Things are pretty well explained there.


Pete

Pete
harry_7
Frequent Advisor

Re: sar

Dear Roger,

Try the below script.

#!/bin/ksh
#
#
LOGDIR="/tmp/stats"
LOGFILE="${LOGDIR}/sar_`hostname`.`date +'%d%m%y'`"

SARCMD=/usr/sbin/sar
SAROPTS="-udgpqr"

# Interval in seconds (5 minutes below)

INTERVAL=300

TOTALSECSINDAY=86400

NTIMES=`expr ${TOTALSECSINDAY} / ${INTERVAL}`

$SARCMD $SAROPTS -o $LOGFILE $INTERVAL $NTIMES >/dev/null 2>&1

With Regards

Harry
Geoff Wild
Honored Contributor

Re: sar

You can do both with vmstat


Or, install mrtg

http://people.ee.ethz.ch/~oetiker/webtools/mrtg/

Or - if you have perfview/glance installed:

From cron:

# performance
55 23 * * 1-5 /opt/perf/bin/extract -xp -r /home/gwild/zgbltemplate -g -b today 7:00 -e today 18:00 -f stdout | /bin/mailx -s 'svr100 performance report' gwild@mydomain.com >/dev/null 2>&1


# cat /home/gwild/zgbltemplate
REPORT "MWA Export on !SYSTEM_ID"
FORMAT ASCII
HEADINGS ON
SEPARATOR="|"
SUMMARY=60
MISSING=0
DATA TYPE GLOBAL
YEAR
DATE
TIME
GBL_CPU_TOTAL_UTIL
GBL_MEM_UTIL
GBL_SWAP_SPACE_UTIL
GBL_MEM_CACHE_HIT_PCT
GBL_DISK_UTIL_PEAK
GBL_FS_SPACE_UTIL_PEAK

Rgds...Geoff

Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Steven E. Protter
Exalted Contributor

Re: sar

You could run the scripts I'm attaching for a time period you select via cron once a week.

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
Rick Garland
Honored Contributor

Re: sar

In the root's crontab (ensure permissions/ownerships are OK) or the adm's crontab, put this entry. This will collect sys statistics q15min.
0,15,30,45 * * * * /usr/lib/sa/sa1

In the root's crontab I am parsing and converting the sa1 binary output to ASCII output to read the values.

56 23 * * * /var/adm/sa/get_sars 2>&1 > /dev/null

I am attaching the get_sars script. It will provide ASCII data q15min and put it into the directory structure listed in the script. Modify for your uses.

I have this generating daily but you can change to be monthly as your needs dictate.
Sridhar Bhaskarla
Honored Contributor

Re: sar

Hi Roger,

If you spend some money, Glance+ pak (available as trial pack in Application CDs) can help you in quite a few ways. It can gather the data, report it (measureware) and you can view runtime performance (glance). If you go bit further, you can add Perfview to it that can be used to view data graphically both current and historical on multiple servers.

Also check 'sarcheck.com' for the tool sarcheck. It's available for a low price.

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