#!/bin/bash
# Netbackup messages monitoring script
# Gianluca Rossi - grossi@acantho.net
# TEST NAME: THIS WILL BECOME A COLUMN ON THE DISPLAY
# IT SHOULD BE AS SHORT AS POSSIBLE TO SAVE SPACE...
# NOTE YOU CAN ALSO CREATE A HELP FILE FOR YOUR TEST
# WHICH SHOULD BE PUT IN www/help/$TEST.html. IT WILL
# BE LINKED INTO THE DISPLAY AUTOMATICALLY.
#
TEST="nbackup"
#
# BBHOME CAN BE SET MANUALLY WHEN TESTING.
# OTHERWISE IT SHOULD BE SET FROM THE BB ENVIRONMENT
#
# BBHOME=/home/sean/bb; export BBHOME # FOR TESTING
if test "$BBHOME" = ""
then
echo "BBHOME is not set... exiting"
exit 1
fi
if test ! "$BBTMP" # GET DEFINITIONS IF NEEDED
then
# echo "*** LOADING BBDEF ***"
. $BBHOME/etc/bbdef.sh # INCLUDE STANDARD DEFINITIONS
fi
#
# include Netbackup configuration
#
. $BBHOME/ext/nb.cfg
WARNING="`$BPERROR -U -s WARNING -hoursago 1 2>/dev/null | sed '1d'| head -10`"
ERROR="`$BPERROR -U -s ERROR -hoursago 1 2>/dev/null | sed '1d'| head -30`"
CRITICAL="`$BPERROR -U -s CRITICAL -hoursago 1 2>/dev/null | sed '1d'| head -30`"
INFO="`$BPERROR -U -s INFO -hoursago 1 2>/dev/null | sed '1d' | head -10`"
LINE=""
COLOR="green"
STATUS="Netbackup OK"
if [ ! -z "$INFO" ]
then
LINE=`printf "\n - - - INFO MESSAGES- - -\n${INFO}\n${LINE}"`
fi
if [ ! -z "$WARNING" ]
then
LINE=`printf "\n - - - WARNING MESSAGES - - -\n${WARNING}\n${LINE}"`
COLOR="yellow"
STATUS="Netbackup - Warning"
fi
if [ ! -z "$ERROR" ]
then
LINE=`printf "\n - - - ERROR MESSAGES - - -\n${ERROR}\n${LINE}"`
COLOR="red"
STATUS="Netbackup - Error"
fi
if [ ! -z "$CRITICAL" ]
then
LINE=`printf "\n - - - CRITICAL MESSAGES - - -\n${CRITICAL}\n${LINE}"`
COLOR="red"
STATUS="Netbackup - Critical"
fi
#
# AT THIS POINT WE HAVE OUR RESULTS. NOW WE HAVE TO SEND IT TO
# THE BBDISPLAY TO BE DISPLAYED...
#
$BB $BBDISP "status $MACHINE.$TEST $COLOR `date` - $STATUS $LINE"