System Monitoring with Xymon/Other Docs/HOWTO/Custom Server Scripts

Server-side scripts look almost the same as client-side scripts, but they will typically use the bbhostgrep utility to pick out hosts in the bb-hosts file that have a special tag defined, and then send one status message for each of those hosts. Like this:

#!/bin/sh

BBHTAG=foo           # What we put in bb-hosts to trigger this test
COLUMN=$BBHTAG	# Name of the column, often same as tag in bb-hosts

$BBHOME/bin/bbhostgrep $BBHTAG | while read L
do
   set $L	# To get one line of output from bbhostgrep

   HOSTIP="$1"
   MACHINEDOTS="$2"
   MACHINE=`echo $2 | $SED -e's/\./,/g'`

   COLOR=green
   MSG="$BBHTAG status for host $MACHINEDOTS"

   #... do the test, perhaps modify COLOR and MSG

   $BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date`

   ${MSG}
   "
done
 
exit 0

Note that for server side tests, you need to loop over the list of hosts found in the bb-hosts file, and send one status message for each host. Other than that, it is just like the client-side tests.

This script is saved in ~/hobbit/server/ext/my_script.sh, and you add its description in ~hobbit/server/etc/hobbitlaunch.cfg:

[foo]
   ENVFILE $BBTHOME/etc/hobbitserver.cfg
   CMD $BB/ext/my_script.sh
   LOGFILE $BB/logs/myscript.log
   INTERVAL 5m

The service can now be added to the bb-hosts file:

127.0.0.1 my_server # foo