View Single Post

   
  #4 (permalink)  
Old 01-05-2008, 05:43 AM
BigBill
 
Posts: n/a
Default Re: AIX kernel statistics

This script is for Solaris based machines that I work with:

################################################## ##########
#
# Variable Definitions #
#
################################################## ##########

SERVER=`/usr/bin/hostname`
ERROR=/tmp/up_mon.err
FLAG=/tmp/up_mon.flag
LASTBOOT=`/usr/bin/kstat | grep boot_time | awk '{print \$2}'`
DATE=`/usr/local/bin/perl -e 'printf"%d\n", time;'`

################################################## ###########
#
# FUNCTION DEFINITION #
#
################################################## ###########

#Email script fail notice function
function messagenotice {
mailx -s "up_mon.ksh" user@noname.net < ${ERROR}
/usr/bin/rm ${ERROR}
exit 0
}

################################################## ###########
#
# EXECUTION #
#
################################################## ###########

#Check for flag
if [ -f ${FLAG} ]
then
let "ii = ${DATE} - `cat ${FLAG}`"
if [ ii -le 1800 ]
then
exit 0
else
/usr/bin/rm ${FLAG}
fi
fi

#Check to see if flag exists
if [ -f /usr/bin/kstat ]
then
echo kstat exists!
else
echo "kstat does not exist on ${SERVER}." > ${ERROR}
messagenotice
fi

#Check for reboot
let "i = ${DATE} - ${LASTBOOT}"

if [ ${i} -le 1800 ]
then
echo "Server ${SERVER} recently rebooted, please investigate."
> ${ERROR}

echo "`/usr/bin/who -b | awk '{print \$2,\$3,\$4,\$5,\$6}'`" >>
${ERROR}
echo ${DATE} > ${FLAG}
messagenotice
fi

exit 0


Instead of re-inventing the wheel, I would like to do exactly the same
thing.

Reply With Quote