Script for Monitoring iCAP Systems (August 2010)

3
Script
#!/usr/bin/sh
# set -x
#
# File: icapreport.sh
# Purpose: This script is meant to be run as a cron job on a daily
# basis for the purpose of notifying the system administrator
# when certain iCAP issues need attention.
# Instructions:
# 1. Save this file in a directory such as /usr/local/bin.
# 2. Modify the RECIPIENT variable to be either a user's e-mail
# address to receive this report or an e-mail alias for a
# distribution list.
# 3. Add an entry to root's crontab -- see crontab(1).
# An example crontab entry would be:
# 00 03 * * * /usr/local/bin/icapreport.sh
# That would generate a report every day at 03:00am
#
# Limitations: This script is compatible with versions 8.x, 9.x and 10.x
# of the iCAP software. It explicitly does not work
# with earlier versions of iCAP.
#
# (C) Copyright 2010 Hewlett-Packard Development Company, L.P.
#
# Disclaimer: This script is meant to be an example that should be
# modified by the user to meet their specific needs.
#
# DISCLAIMER OF WARRANTY
# The following software: icapreport.sh is experimental and is provided as
# a courtesy, free of charge, "AS-IS" by Hewlett-Packard Company ("HP").
# HP shall have no obligation to maintain or support this software.
# HP MAKES NO EXPRESS OR IMPLIED WARRANTY OF ANY KIND REGARDING THIS SOFTWARE
# INCLUDING ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE, TITLE OR NON-INFRINGEMENT. HP SHALL NOT BE LIABLE FOR ANY DIRECT,
# INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, WHETHER BASED ON
# CONTRACT, TORT OR ANY OTHER LEGAL THEORY, IN CONNECTION WITH OR ARISING
# OUT OF THE FURNISHING, PERFORMANCE OR USE OF THIS SOFTWARE.
# Capture everything to be mailed in this file
MSGFILE=`mktemp -d /tmp -p AAA`
# Make sure that we are pointing to the actual mailx command.
MAILX="/usr/bin/mailx"
# Check that mailx command is present.
if [[ ! -f "$MAILX" ]]
then
echo "Daily iCAP Status Report"
echo "ERROR: mailx command not found: $MAILX"
rm -f $MSGFILE
exit 1
fi
# Specify recipient to mail report to.