cancel
Showing results for 
Search instead for 
Did you mean: 

Another Script question

SOLVED
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?

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

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*
do
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

Vito,

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.

//END

#!/usr/bin/ksh
HOST=`hostname`
DATED=`date +%m%d`
MONTH=`date +%m%Y`
DATE=`date +%m-%d-%Y`
FILE=${HOST}_$DATED
RESULT=/some_where/result.$MONTH

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

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}'`

echo " $DATE $USR $SYS $WIO %IDLE >> $RESULT"


//End


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.

-Sri
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*
do
tail -1 $i >> /outputfilename
done

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.
Uday_S_Ankolekar
Honored Contributor

Re: Another Script question

Hi,

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
-USA..
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/vito.final
done

Sachin
Is photography a hobby or another way to spend $