#!/bin/bash
########################################################
# Author: Brian T. Hunter
# Date: 8/29/2023
# Script: bb-system.sh
########################################################
# Add to the bottom of file /etc/xymon/tasks.cfg
#
# [system]
# ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
# CMD $XMONCLIENTHOME/ext/bb-system.sh
# LOGFILE $XYMONCLIENTLOGS/bb-system.log
# INTERVAL 5m
#
# THEN RESTART XYMON: sudo systemctl restart xymon
#
########################################################
COLUMN=system
COLOR=green
MSG="SYSTEM HEALTH"
LOGFILE=/tmp/check_health.out
EXT=/usr/lib/xymon/client/ext
$EXT/check_health.pl > $LOGFILE
ALERTCNT=`grep ALERT $LOGFILE | wc -l`
if [ ! -f $LOGFILE ]
then
COLOR=red
MESSAGE="$LOGFILE NOT FOUND"
MSG="${MESSAGE}
`cat $LOGFILE`
"
elif [ $ALERTCNT -ne '0' ]
then
COLOR=red
MESSAGE="ALERT FOUND"
MSG="${MESSAGE}
`cat $LOGFILE`
"
else
MESSAGE="ALL IS OK"
MSG="${MESSAGE}
`cat $LOGFILE`
"
fi
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`
${MSG}
"
exit 0