Anything that can be automated via a script or a custom program can be added into Xymon. A lot of extension scripts are available for Big Brother at the www.deadcat.net archive, and these will typically work without modifications if you run them in Xymon. Sometimes a few minor tweaks are needed - the Xymon mailing list can help you if you don't know how to go about that.

But if you have something unique you need to test, writing an extension script is pretty simple. You need to figure out some things:

  • What name will you use for the column?
  • How will you test it?
  • What criteria should decide if the test goes red, yellow or green?
  • What extra data from the test will you include in the status message ?

A simple client-side extension script looks like this:

COLUMN=mytest	# Name of the column
COLOR=green		# By default, everything is OK
MSG="Bad stuff status"
# Do whatever you need to test for something
# As an example, go red if /tmp/badstuff exists.
if test -f /tmp/badstuff
      `cat /tmp/badstuff`
      All is OK
# Tell Xymon about it
exit 0

You will notice that some environment variables are pre-defined: BB, BBDISP, MACHINE are all provided by Xymon when you run your script via hobbitlaunch. Also note how the MSG variable is used to build the status message - it starts out with just the “Bad stuff status”, then you add data to the message when we decided what the status is.

To run this, save your script in the ~hobbit/client/ext/ directory (i.e. in the ext/ directory off where you installed the Xymon client), then add a new section to the ~hobbit/client/etc/clientlaunch.cfg file like this:

	ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg
	CMD $HOBBITCLIENTHOME/ext/myscript.sh

Server-side scripts look almost the same, 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.

  • tutorials/devel.txt
  • Last modified: 2009/02/01 03:09
  • by