telemorgan
MIS
hey guys
I have a script that I wrote that runs fine when i call it manually but I receive errors when running it from the cron. Here are the errors:
Your "cron" job on enterprise
/morgan/bin/system_test.scr
produced the following output:
/morgan/bin/system_test.scr[25]: ping: not found
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
Here is the script, any ideas?
#!/bin/ksh
#
# SET GLOBAL VARIABLES
IP="10.10.28.55" # target ip
ADMIN="morgan@telephonics.com" # admin to send mail to
MYMSG_GD="/morgan/working/system_good.txt" # ouput for successful tests
MYMSG_BD="/morgan/working/system_bad.txt" # ouput for failed tests
DB="deltekcp griffon epay deltektc testcp" # database names
TEST_STR="OK" # SQL test string
PAR="u01 u02 u03 u04 u05 u06 rootvol" # partition names
SIZE="" # create empty var
#
#
# CHECK FOR PREVIOUS OUTPUT FILES
if [ -s $MYMSG_GD ] # Is there a file with a length greater than 0?
then # Yes,
> $MYMSG_GD # erase it.
fi
if [ -s $MYMSG_BD ] # Is there a file with a length greater than 0?
then # Yes,
> $MYMSG_BD # erase it.
fi
#
# PING TEST
ping -c 2 $IP > /dev/null # ping target with a count of 2
if [ $? != 0 ] ; then # successful?
echo "couldn't ping enterprise box" > $MYMSG_BD # No, echo message
else
echo "enterprise box is alive" > $MYMSG_GD # Yes, echo message
fi
#
#
#
# SQL DB TEST
#
for x in $DB ; do # Are the databases up?
if [ `tnsping $x | grep OK | nawk -F ' ' '{print $1}'` != $TEST_STR ] ; then
echo "$x : down" >> $MYMSG_BD # NO, echo message
else
echo "$x : up" >> $MYMSG_GD # Yes, echo message
fi
done
# DISK SPACE TEST
for y in $PAR ; do # Current capacity over 98%?
if [ `df -k | grep $y | awk '{print $5}' | nawk -F '%' '{print $1}'` -ge "98" ]; then
echo "$y warning!" >> $MYMSG_BD # Yes, echo
else
echo "$y is below threshold" >> $MYMSG_GD # No, echo
fi
done
#
# MAIL FAILED OUPUT TO ADMIN
if [ -s $MYMSG_BD ]; then
cat $MYMSG_BD | mail $ADMIN
fi
I have a script that I wrote that runs fine when i call it manually but I receive errors when running it from the cron. Here are the errors:
Your "cron" job on enterprise
/morgan/bin/system_test.scr
produced the following output:
/morgan/bin/system_test.scr[25]: ping: not found
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
/morgan/bin/system_test.scr[37]: tnsping: not found
/morgan/bin/system_test.scr[37]: test: argument expected
Here is the script, any ideas?
#!/bin/ksh
#
# SET GLOBAL VARIABLES
IP="10.10.28.55" # target ip
ADMIN="morgan@telephonics.com" # admin to send mail to
MYMSG_GD="/morgan/working/system_good.txt" # ouput for successful tests
MYMSG_BD="/morgan/working/system_bad.txt" # ouput for failed tests
DB="deltekcp griffon epay deltektc testcp" # database names
TEST_STR="OK" # SQL test string
PAR="u01 u02 u03 u04 u05 u06 rootvol" # partition names
SIZE="" # create empty var
#
#
# CHECK FOR PREVIOUS OUTPUT FILES
if [ -s $MYMSG_GD ] # Is there a file with a length greater than 0?
then # Yes,
> $MYMSG_GD # erase it.
fi
if [ -s $MYMSG_BD ] # Is there a file with a length greater than 0?
then # Yes,
> $MYMSG_BD # erase it.
fi
#
# PING TEST
ping -c 2 $IP > /dev/null # ping target with a count of 2
if [ $? != 0 ] ; then # successful?
echo "couldn't ping enterprise box" > $MYMSG_BD # No, echo message
else
echo "enterprise box is alive" > $MYMSG_GD # Yes, echo message
fi
#
#
#
# SQL DB TEST
#
for x in $DB ; do # Are the databases up?
if [ `tnsping $x | grep OK | nawk -F ' ' '{print $1}'` != $TEST_STR ] ; then
echo "$x : down" >> $MYMSG_BD # NO, echo message
else
echo "$x : up" >> $MYMSG_GD # Yes, echo message
fi
done
# DISK SPACE TEST
for y in $PAR ; do # Current capacity over 98%?
if [ `df -k | grep $y | awk '{print $5}' | nawk -F '%' '{print $1}'` -ge "98" ]; then
echo "$y warning!" >> $MYMSG_BD # Yes, echo
else
echo "$y is below threshold" >> $MYMSG_GD # No, echo
fi
done
#
# MAIL FAILED OUPUT TO ADMIN
if [ -s $MYMSG_BD ]; then
cat $MYMSG_BD | mail $ADMIN
fi