I wrote a monitor for the error database to notify me when transactions exsist.
Warning First
First things frist: This is a KSH script, not a tcl. Also you may use this code
and distribute it anywhere you would like without
Use
With that being stated:
This script when ran as a cron job checks the number of lines in the error database. If it contains more than 8 rows ( the normal headers of the db) an e-mail will be created and sent. To setup add your e-mail address to the “to:” variable and place any address in the “from:” variable. The script will complete a long listing of the error and then remove it from the database. The script requires a directory “error” to be created and placed in the same location as the script. A log file with the date.txt will be placed in that directory for review and the e-mail will point you to that location.
The script requires the following args to be passed:
$1 = root (complete path i.e. “/hci/root3.8.1P”)
$2 = site (site to check i.e. “live”)
complete call to execute “db_check.ksh /hci/root3.8.1P live”
To place in cron use something like this to create a log in a dir called logs. This would have the scritp run 1 min after midnight everyday.
“01 00 * * * /hcidata_scripts/live/db_check.ksh /hci/root3.8.1P/ live >> /hcidata_scripts/live/logs/db_check.log 2>&1”
If you have any questions or improvements please post them here so that we all may take advantage of them.
FILEDIR=/hcidata_scripts/live/error
from= addaddress@yoursite.com
to= youraddress@yoursite.com
subject=”$2 – Error Database contains transactions”
mailfile=`echo “$0” | sed ‘s/.ksh/.msg/1’`
a=${#*}
status=1
if test $a -lt 2
then
echo “COMMAND LINE AURGUMENT FORMAT ERROR:”;
echo “COMMAND LINE AURGUMENT FORMAT ERROR:” >> $mailfile;
echo “Command Line Format:
echo “Command Line Format:
echo “Actual Command Line: $0 $1 $2”;
echo “Actual Command Line: $0 $1 $2” >> $mailfile;
status=0;email=1;
fi
if [ “$status” -eq 1 ]
then
# Save passed arguments
hciroot=$1
hcisite=$2
eval `/hci/bin/hcisetenv -root ksh $hciroot $hcisite`
fi
lines=`hcidbdump -e | wc -l`
#echo “Lines: $lines”
today=`date +%Y%m%d`
#echo $today
if [[ “$lines” != “8” ]]
then
#pipe the data to a file then remove the transactions
`hcidbdump -e -D -F -L >> $FILEDIR/$today.txt`
echo “To: $to” > $mailfile
echo “Reply-To: $to” >> $mailfile
echo “Subject: $subject” >> $mailfile
echo “” >> $mailfile
echo “ATTENTION CLOVERLEAF DEVELOPERS:” >> $mailfile
echo “” >> $mailfile
echo “A Cloverleaf Interface Engine cron job may have found a problem with the Error DB.” >> $mailfile
echo “Please review the following file for more information:” >> $mailfile
echo “=====================================================================” >> $mailfile
echo “The $hcisite error database contains $lines lines, in file $FILEDIR/$today.txt.” >> $mailfile
echo “=====================================================================” >> $mailfile
# echo “Script Completed: c” >> $mailfile
/usr/sbin/sendmail -f$from -t < $mailfile >/dev/null
else
echo “The database did not contain any errors!”
fi
exit
[/b]