Operating System - HP-UX
1832578 Members
3235 Online
110043 Solutions
New Discussion

Re: iostat and sar output

 
M. Tariq Ayub
Regular Advisor

iostat and sar output

Hi,

I need to collect iostat and sar output for every 15 minute.
iostat 900
sar -d 900 100

How can i save the output. I need to see it later for 24 hours.
10 REPLIES 10
MarkSyder
Honored Contributor

Re: iostat and sar output

If you want this to run every 15 minutes, it would be logical to use a cron job.

In the case of sar, you could direct the output to a file via sar -o filename. You would read the file via sar -f filename. I would suggest putting a suffix on the end of the filename so you can keep the readings separate: e.g. $$ would give you the current process id as a suffix. This will only cause problems if you keep the records a long time.

I'll leave it to someone else to advise you on iostat!

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Mark Grant
Honored Contributor

Re: iostat and sar output

Simple answer is

"iostat 900 > iostat.file" and "sar -d 100 100 > sar.file"

Never preceed any demonstration with anything more predictive than "watch this"
Borislav Perkov
Respected Contributor

Re: iostat and sar output

Hi,
you can do it with crontab entry like it is described in sar manual pages. something like this
00,15,30,45 * * * * /usr/lbin/sa/sa1 900 100
or similar. After that you can find for every day files saXX and from there you can extract what you need. and for iostat you have to redirect the output to file.
T G Manikandan
Honored Contributor

Re: iostat and sar output

you can do

myfile.sh

iostat 5 5 > /var/mydir/myfile.txt
sar -d 5 5 >>/var/mydir/myfile.txt

you can run myfile.sh in cron for the required period.

Thanks

Borislav Perkov
Respected Contributor

Re: iostat and sar output

The saXX files you can find in
/var/adm/sa
directory.
You need to create it if it doesn't exist.
Vijaya Kumar_3
Respected Contributor

Re: iostat and sar output

Consider using glance product in advisory mode.

Or you can think about using Measureware product if you have some perks for this assignment.
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
KCS_1
Respected Contributor

Re: iostat and sar output

Hi


At this time, you will get the output of them forevery 15minutes by cron that included iostat and sar commands.

Have a look at this manpages associated with cron

# man crontab

It will help you how to set the cron on time.



Easy going at all.
Shaikh Imran
Honored Contributor

Re: iostat and sar output

You can do this or any test output by redirecting it to a file using > command.
Example in Your case
#iostat 900 > /tmp/iostat.opuput &
#sar -d 900 100 > /tmp/sar.output

These are the text files in which your respective Outputs are stored for you further references.
Additional Info:
Now To Automate this Process create a script:
# cd /tmp
#vi script
while true
do
iostat > /tmp/iostat.output
sleep 900
iostat >> /tmp/iostat.output
sleep 900
done
#chmod 777 scr
#./scr ( This will execute the script )

Do the same for sar o/p.

I'll sleep when i am dead.
Mobeen_1
Esteemed Contributor

Re: iostat and sar output

Tariq,
Just simply by directing the output to a file

iostat 900 >/tmp/iostat.out
sar -d 900 100 >/tmp/sar.out

Like many of our friends here have suggested, i would advise that you do the following

1.create a script and name it perform.sh
your script should contain the following
iostat 900 >/tmp/iostat.out &
sar -d 900 100 >/tmp/sar.out &
exit

2.Next while you are logged in your system edit crontab by issuing the command
$:/>crontab -e

3. Go to the last line of this file and
make the following entry
00,15,30,45 * * * * /tmp/perform.sh

regards
Mobeen
Tim Sanko
Trusted Contributor

Re: iostat and sar output

I would suggerst somethin like this
call it sarperf.sh.

cron inits ot with this line
00 * * * * /root/SCRIPTS/performance.sh > /dev/null 2>&1

# sarperf.sh
Month=`/usr/bin/date +%m`
Day=`/usr/bin/date +%d`
Year=`/usr/bin/date +%y`
Hour=`/usr/bin/date +%H`
Minute=`/usr/bin/date +%M`
LOGFILE=/root/LOG/SAR/$Year$Month$Day-$Hour$Minute.sar

/usr/sbin/sar -A -o $LOGFILE 60 60 > /dev/nul &

Enjoy

Tim