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

From Wikibooks, open books for an open world
Jump to navigation Jump to search

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:


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
   set $L	# To get one line of output from bbhostgrep

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

   MSG="$BBHTAG status for host $MACHINEDOTS"

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

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

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/, and you add its description in ~hobbit/server/etc/hobbitlaunch.cfg:

   ENVFILE $BBTHOME/etc/hobbitserver.cfg
   CMD $BB/ext/
   LOGFILE $BB/logs/myscript.log

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