RE: I have a question involving some cron'd shell scripts and Red hat 7.0 performance / methodology / peer review

"Collins, Eric S." <[email protected]> Thu, 14 Nov 2002 19:19:28 -0600
Newsgroups gmane.linux.redhat.release.guinness
Message-ID <CFC80EECB4A4D6118DF800D0B7C9B52B038E39@ntcr1107.apacteleservices.com>
Guess spelling shbang correctly would help

-----Original Message-----
From: Collins, Eric S. [mailto:[email protected]] 
Sent: Thursday, November 14, 2002 6:18 PM
To: '[email protected]'
Subject: RE: I have a question involving some cron'd shell scripts and Red
hat 7.0 performance / methodology / peer review


  Ian,
 
        You are correct, it is in bad form to not include that shebang line.
I will work on that. Thanks for your input.
 
-Eric

-----Original Message-----
From: Ian Douglas [mailto:[email protected]] 
Sent: Thursday, November 14, 2002 6:01 PM
To: [email protected]
Subject: RE: I have a question involving some cron'd shell scripts and
Redhat 7.0 performance / methodology / peer review


Eric,
 
I notice in all of your script examples that you don't load a script
interpreter in any of them.
 
I'm not exactly a script expert myself, but I do a LOT of Perl and a handful
of bash scripts and they all have to have
 
#!/bin/bash
 
or
 
#!/usr/bin/perl 
 
 
 graph1 script

 
CENTERS=$(cat /usr/local/rrdwork/graph_centers) #This is a list of all
current remote facilities, i.e. norda1 norda2
for center in $CENTERS;do
/usr/local/rrdwork/graph_hour $center >> /dev/null # these graph_*  files
are duplicates, with the only difference being the time ranges
/usr/local/rrdwork/graph_day $center >> /dev/null
/usr/local/rrdwork/graph_week $center >> /dev/null
done
exit 0 

updatec script example
FACS=$(cat /usr/local/rrdwork/centers)         #the updatec2 script would
reference /usr/local/rrdwork/centers2, this is the only difference in these
scripts
for fac in $FACS ;do                                    #so I have each
group of remote systems broken up into 4 centers* files.
master=`rsh $fac /bin/totinf`
   ld=`echo "$master"|gawk '{ if (NR == 1) print $0 }'`
   users=`echo "$master"|gawk '{ if (NR == 2) print $0 }'`
   tout=`echo "$master"|gawk '{ if (NR == 3) print $0 }'`
   tout2=`echo "$master"|gawk '{ if (NR == 4) print $0 }'`
   dat=`date`
   systime=`echo "$master"|gawk '{ if (NR == 5) print $0 }'`
   cpu=`echo "$master"|gawk '{ if (NR == 6) print $0 }'`
   uptim=`echo "$master"|gawk '{if (NR == 7) print $0}'`
   cmv=`echo "$master"|gawk '{ if (NR == 8) print $0}'`
rrdtool update /usr/local/rrdwork/rrds/$fac.rrd N:$ld:$users:$tout:$tout2
if [ -e /usr/local/rrdwork/logs/$fac.log ] ; then >
/usr/local/rrdwork/logs/$fac.log; fi
echo "$ld" >> /usr/local/rrdwork/logs/$fac.log
echo "$users" >> /usr/local/rrdwork/logs/$fac.log
echo "$tout" >> /usr/local/rrdwork/logs/$fac.log
echo "$tout2" >> /usr/local/rrdwork/logs/$fac.log
echo "$systime" >> /usr/local/rrdwork/logs/$fac.log
echo "$cpu" >> /usr/local/rrdwork/logs/$fac.log
echo "$uptim" >> /usr/local/rrdwork/logs/$fac.log
echo "$cmv" >> /usr/local/rrdwork/logs/$fac.log
done 

And finally, the remote script which is executed by the updatec series of
scripts.

uptime|sed -e 's/.* load/load/' -e 's/\,//g'|cut -d" " -f3
t=`w|grep tmr|grep auto|wc -l`
u=`w|grep epac.sh|wc -l`
tu=`expr "$t" + "$u"`
echo $tu
s=`date '+%d'`
x=`tail -32 "/u/server/log/tal$s.log"|awk '{print $2 ;}'|grep 000|wc -l|awk
'{print $1}'`
echo "$x"
tout2=`cat "/u/server/log/tal$s.log"|awk '{print $2 ;}'|grep 000|wc -l|awk
'{print $1}'`
echo "$tout2"
time=`/bin/date` ; echo "$time"
cpu=`hw -r cpu|grep performs` ; echo "$cpu"
uptim=`w -t`;echo "$uptim"
cmv=`cat /u/server/motd|grep VERSION`; echo "$cmv"