Hello all,
I am trying to get a script to work that I did not write. It looks like it should be working:
I'm running this on a sun server. It seems like the first "if" loop is not working. The line:
echo $OS
returns SunOS, however the line:
echo "Extract DIR = $EXT_DIR"
returns:
Extract DIR =
So the $EXT_DIR variable is not being set.
Also there is no shebang line, is that OK? I do mostly perl programming.
Any help is appreciated.
If at first you don't succeed, don't try skydiving.
I am trying to get a script to work that I did not write. It looks like it should be working:
Code:
#________________________________________________________________________
# Program: CPU3_check
#
# This script checks the CPU utilization of a system against
# a predetermined threshold. If the threshold is exceeded an
# email or a page is sent.
#
#
# Files used:
# CPU3_threshold = contains nodename and an integer threshold value (ex "40")
# CPU3_report = config file for extract to get GBL_CPU_TOTAL_UTIL
# CPU3_notify = list of people to email or page
# node.CPU3.ctime = contains output from extract utility
#________________________________________________________________________
OS=`uname -s`
echo "$OS"
if [[ $OS = AIX ]]
then
EXT_DIR="/usr/lpp/perf/bin"
MON_DIR="/var/opt/OV/bin/instrumentation
else
EXT_DIR="/opt/perf/bin"
MON_DIR="/var/opt/OV/bin/instrumentation
fi
#MON_DIR="/home/mt37810"
node=`uname -n`
ctime=`date +%y%m%d%H%M%S`
mtime=`date +%H`:00
outfile="/tmp/$node.CPU3.$ctime"
reportfile="$MON_DIR/CPU3_report"
notifyfile="$MON_DIR/CPU3_notify"
start_time="today-1"
#echo "start_time=$start_time"
#echo "mtime=$mtime"
if [ -f $MON_DIR/CPU3_threshold ]
then
threshold=`cat $MON_DIR/CPU3_threshold | grep $node | awk '{ print $2 }'`
else
threshold=60
fi
echo "Extract DIR = $EXT_DIR"
$EXT_DIR/extract -xp -r $reportfile -f $outfile -b $start_time -e LAST -G
if [ -s $outfile ]
then
CPU_util=`tail -1 $outfile`
else
echo "CPU_util is null"
exit 1
fi
#echo "CPU_util=$CPU_util"
# CPU utilization is a decimal number. Need to change to integer
int1=`echo $CPU_util | awk -F. '{ print $1 }'`
int2=`echo $CPU_util | awk -F. '{ print $2 }'`
if [ $int2 > 50 ] #round up if over 50
then
CPU_util=`expr $int1 + 1`
else
CPU_util=$int1
fi
#echo "CPU_util=$CPU_util"
if [ $CPU_util -ge $threshold ]
then
message="$node CPU utilization is at $CPU_util% which is at or above the threshold of $threshold%"
# echo "$message"
else
# echo "CPU OK"
# message="CPU OK"
rm $outfile
exit 0
fi
while read notify_user
do
#echo "notify_user=$notify_user."
if [ `echo $notify_user | grep myairmail` ]
then
echo "$message" | mailx -m $notify_user
#echo "paging"
else
echo "$message" | mailx -s $node $notify_user
#echo "emailing"
fi
done < $MON_DIR/CPU3_notify
rm $outfile
exit 0
I'm running this on a sun server. It seems like the first "if" loop is not working. The line:
echo $OS
returns SunOS, however the line:
echo "Extract DIR = $EXT_DIR"
returns:
Extract DIR =
So the $EXT_DIR variable is not being set.
Also there is no shebang line, is that OK? I do mostly perl programming.
Any help is appreciated.
If at first you don't succeed, don't try skydiving.