Showing results for 
Search instead for 
Did you mean: 

Another Script question

Go to solution
Vito Sarducci
Regular Advisor

Another Script question

From my previous question on tail of the sar data average line. How would I incorporate all of the 30 files for the month into one nice neat file that I can download to my desktop?

tail -1 ppm_1001 >> Vito
tail -1 ppm_1002 >> Vito
tail -l ppm_1003 >> Vito

I have 10 systems to do this on. What am i missing to incorporate this for 30 days and for each of my systems?

So far, everyone has done great giving me feedback, but im having a mental block right now trying to figure this out?

Please advise?

Lifes too short to stress out, Enjoy every day you have on earth!
Rodney Hills
Honored Contributor

Re: Another Script question

Two common methods for pulling together data from different systems are-

NFS - Export 1 filesystem and mount on the other 9. Write all your data to that filesystem

RCP - Using rcp, you could copy the data files to one location and process there.

If you are using "cron" on each of the 10 systems, you could schedule a script that would pull the data together and then put it to a central system.

To get the data to a PC, you could either ftp or use SAMBA and mount the filesystem on your PC.

Note- If you write your data comma seperated and name the file with .CSV extension, you can open it up in M$ EXCEL by opening the file from your PC.

Their are other methods available, but I think these are the most common.

-- Rod Hills
There be dragons...
Alan Riggs
Honored Contributor

Re: Another Script question

for i in ppm_10*
tail -1 $i
done >> vito

In the other thread, I also gave you the awk syntax to generate your summary line.
Sridhar Bhaskarla
Honored Contributor

Re: Another Script question


I din't understand your requirement
well. Do you want to have the sar Averages of all the Systems for 30days into a single file?. Then it is three dimensional. However, you can have sar reports of each system in one file so you will get 10 files of data.

Incorporate this script in job to run at 11:49 everyday. This has to run after your system_mmdd file gets created.


DATED=`date +%m%d`
MONTH=`date +%m%Y`
DATE=`date +%m-%d-%Y`

if [ ! -f $RESULT ]
echo " DATE %usr %sys %WIO %IDLE" >> $RESULT

USR=`grep Average $FILE|awk '{print $2}'`
SYS=`grep Average $FILE|awk '{print $3}'`
WIO=`grep Average $FILE|awk '{print $4}'`
IDLE=`grep Average $FILE|awk '{print $5}'`



You can use printf statement to get a clean output. Checkout man page for printf and replace the echo statements with printfs.

You will have these files for every month in /some_where directory.

Hope this helps.

This is a generic script so you can place it on any system if the sar files are the in the same location everywhere.

You may be disappointed if you fail, but you are doomed if you don't try
Bernie Vande Griend
Respected Contributor

Re: Another Script question

Are all the sar files already on one system?

If they are, then you can just do a for loop like:

for i in in ppm*
tail -1 $i >> /outputfilename

Otherwise if they are not on 1 system, you need to use rcp, NFS, ssh, ftp or some other mechanism to transfer the files from each of the systems to one central system. My preference would be to use SSH's scp as it is encypted and does require passing passwords around.
Ye who thinks he has a lot to say, probably shouldn't.
Honored Contributor

Re: Another Script question


Pulling data from various system:

While writing to a file use $hostname to identify the data belongs to which system.
for e.g use sardata$date.$hostname.

Once that is done use script to run rcp or ftp
to pull the data at a centrel location.

Hope this helps
Good Luck..
Sachin Patel
Honored Contributor

Re: Another Script question

Hi Vito,

for SYS in "sys1 sys2 sys3 sys4"; do
remsh $SYS tail -1 >> /tmp/vito.$SYS
/*either you can right 10 remsh or use another
for loop or you can use Alan's method for i in /sar/pam*; do
this will genereate /tmp/vito.$SYS in to local system you can pull that to this server where you are running script */
rcp $SYS:/tmp/vito.$SYS /tmp/vito1
cat /tmp/vito1 >> /tmp/

Is photography a hobby or another way to spend $