Script for Monitoring iCAP Systems (August 2010)

4
# A best practice would be to establish an e-mail alias to receive
# this report.
RECIPIENT="root@localhost"
# Run everything in a sub-shell to mail complete output
(
# For safety, use a minimum $PATH for generic commnds.
export PATH="/usr/bin:/usr/sbin:"
# Create temporary file to capture stderr
ERRFILE=`mktemp -d /tmp -p AAA`
# Get current date/time
DATE=`date 2>>$ERRFILE`
RC=$?
if [[ $RC -ne 0 ]]
then
echo "Daily iCAP Status Report"
echo "ERROR: Unable to run date command"
cat $ERRFILE
rm -f $ERRFILE
exit $RC
fi
# Report header
echo "Daily iCAP Status Report for: $DATE"
echo ""
# Make sure that we are pointing to the actual icapstatus command.
ICAPSTATUS="/usr/sbin/icapstatus"
# Check that icapstatus command is present.
if [[ ! -f "$ICAPSTATUS" ]]
then
echo "ERROR: icapstatus command not found: $ICAPSTATUS"
cat $ERRFILE
rm -f $ERRFILE
exit 1
fi
# Run icapstatus command once and capture output.
ICAPOUT=`$ICAPSTATUS 2>>$ERRFILE`
RC=$?
if [[ $RC -ne 0 ]]
then
echo "ERROR: Unable to run $ICAPSTATUS"
cat $ERRFILE
rm -f $ERRFILE
exit $RC
fi
IFS=" "
EXCEPTIONSTATE=No
typeset -i WARNINGS=0
typeset -i ERRORS=0
echo "$ICAPOUT" |
while read TOK1 TOK2 TOK3 TOK4 TOK5 TOK6 TOK7 TOK8 TOK9