Configuring Big Brother Tests for Miscellaneous Processes
August 7, 2007 – 8:33 pm Tip courtesy of Kyle Reynolds at http://www.camelrichard.org
On the machine running the process you wish to test for, create a script in the $BBHOME/ext
directory following the example script below. Change the `PROC_1` variable to reflect the process
you will `grep` for and the `BBPROG` variable to reflect the name of the script, and change the
`TEST` variable to reflect the name of the test as it will be displayed on the main BB html page.
the following example is to test for the SNMP daemon, `snmpdx`
!/bin/sh
bb-snmptest.sh
BIG BROTHER - MISC EXTERNAL SCRIPT
Kyle Reynolds
THIS SCRIPT TESTS FOR A PROCESS. IT CHECKS HOW MANY INSTANCES OF THE
PROCESS IS RUNNING AND COMPARES IT TO THE PANIC LEVEL
GREEN IS THE DEFAULT COLOR LEVEL
BBPROG=bb-snmptest.sh; export BBPROG
CHANGE THE FOLLOWING FIELDS TO MEET YOUR NEEDS
TEST=”snmp” - NAME OF THE FILE DISPLAYED ON THE
- BBDISPLAY AND SET IN bb-hosts.sh
BBHOME=/u01/app/bb/bbc BBHOME - BIG BROTHER HOME
PANIC_1=”1″ - SET THE NUMBER OF PROCESSES REQUIRED
PROC_1=”snmpdx” - NAME OF THE PROCESS TO GREP FOR
MACHINE=”blojszp1″ - HAS TO BE IN A,B,C FORM NOTE THE COMMAS
check basic environment setup
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
force green and clear tmp file
LINE=”"
COLOR=”green”
`rm $BBTMP/$TEST`
start the program
PROC_1_CURRENT=`ps -ef| grep -v grep| grep $PROC_1| wc -l| cut -c8`
if [ “$PROC_1_CURRENT” = “$PANIC_1″ ]
then
echo “<TR><TD>$PROC_1 - $PROC_1_CURRENT instances running<TD><TD>” >> $BBTMP/$TEST
echo “<IMG SRC=”../gifs/green.gif” ALT=”${PROC_1} :green” HEIGHT=16
WIDTH=16 BORDER=0><A><TD><TR>” >> $BBTMP/$TEST
else
LINE=”$LINE
WARNING! $PROC_1 NOT OK - $PROC_1_CURRENT instances are running”; export LINE
COLOR=”red” ; export COLOR
echo “<TR><TD>$PROC_1<TD><TD>” >> $BBTMP/$TEST
echo “<IMG SRC=”../gifs/$COLOR.gif” ALT=”${PROC_1} :$COLOR” HEIGHT=16
WIDTH=16 BORDER=0><A><TD><TR>” >> $BBTMP/$TEST
fi
format it for BB
LINE=”status $MACHINE.$TEST $COLOR `date`
$LINE
`cat $BBTMP/$TEST`”
NOW USE THE BB COMMAND TO SEND THE DATA ACROSS
$BB $BBDISP “$LINE” # SEND IT TO BBDISPLAY
add the following line (for the SNMP example) to etc/bb-bbexttab
`localhost : : bb-snmptest.sh`
restart BB on the client and after about 5-10 minutes, the new test should show
up on the BB server display.