# more sar.sh
#!/bin/sh
# ########### README ############
# usage: ./sar.sh start-time stop-time dir-name sar-file-name
# start-time: in the form hh[:mm[:ss]]
# stop-time: in the form hh[:mm[:ss]]
# dir-name: directory where reports are stored. Make sure directory doesn't exist
# sar-file-name: The file name of binary file containing the system activity. If you started the /usr/lib/sa/sa1, then the file name would be /var/adm/sa/saDD where DD is the day.
#
# reference is sar command: sar -f ${FILE} -s 04:01 -e 04:15 -r
#
# To prepare system for sar utility:
# msc is the user name
# 1) Create /var/spool/cron/crontabs/msc with crontab commands:
# e.g. with the following line, activity report every 5 minutes everyday; cron starts at top of hour
# 0 * * * * /usr/lib/sa/sa1 300 12 &
# Note: If current time is 14:32, put the following line and cron will start at 14:34
# 34 * * * * /usr/lib/sa/sa1 300 12 &
# 2) Start cron job: /usr/sbin/cron or "pkill cron"
# Note: if there is "cannot start cron; FIFO exists" error, remove file /etc/cron.d/FIFO and start cron
# 3) Make crontab file: crontab msc
# 4) To verify updated crontab: crontab -l
# If you get error: crontab: can't open your crontab file.
# add user to /etc/cron.d/cron.allow file. e.g.:
# root
# msc
#
# To stop cron job
# 1) rm /var/spool/cron/crontabs/msc
# 2) pkill cron
# ########### README ############
# start time in the form hh[:mm[:ss]]
START_TIME=$1
# stop time in the form hh[:mm[:ss]]
STOP_TIME=$2
# directory name
DIR=$3
# The file name of binary file containing the system activity. If you started the /usr/lib/sa/sa1, then the file name would be /var/adm/sa/saDD where DD is the day.
FILE=$4

mkdir $DIR

sar -f ${FILE} -s ${START_TIME} -e ${STOP_TIME} -r > ./${DIR}/memory.txt
sar -f ${FILE} -s ${START_TIME} -e ${STOP_TIME} -u > ./${DIR}/cpu.txt
#sar -f ${FILE} -s ${START_TIME} -e ${STOP_TIME} -g > ./${DIR}/paging.txt
sar -f ${FILE} -s ${START_TIME} -e ${STOP_TIME} -d > ./${DIR}/disk.txt
chmod 555 ${DIR}




Read More about [sar.sh...