tips

Error loading plugin struct
ParseError: syntax error, unexpected 'fn' (T_STRING), expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
More info is available in the error log.

This is an old revision of the document!


Coming Soon

What do the little red/yellow/green icons mean ?

Client side tests are missing

Clients using odd hostnames

Where are the bbmv/bbrm commands?

How do I delete a test status?

How do I delete a host?

How do I rename a host ?

I cannot get the Apache graphs to work

How can I add MRTG graphs to the Xymon webpages?

Updating more frequently

I want my temperature graphs to show Fahrenheit

How do I remove the HTML links from the alert messages?

I cannot see the the man-pages on the web

My alert emails come without a subject

Does Xymon support receiving SNMP traps?

How can I create a custom test script?

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:

   #!/bin/sh

   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
   then
      COLOR=red
      MSG="${MSG}
 
      `cat /tmp/badstuff`
      "
   else
      MSG="${MSG}

      All is OK
      "
   fi

   # Tell Xymon about it
   $XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`

   ${MSG}
   "

   exit 0

You will notice that some environment variables are pre-defined: XYMON, XYMSRV, MACHINE are all provided by Xymon when you run your script via xymonlaunch. 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 ~xymon/client/ext/ directory (i.e. in the ext/ directory off where you installed the Xymon client), then add a new section to the ~xymon/client/etc/clientlaunch.cfg file like this:

   [myscript]
	ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
	CMD $XYMONCLIENTHOME/ext/myscript.sh
	LOGFILE $XYMONCLIENTHOME/logs/myscript.log
	INTERVAL 5m

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

   #!/bin/sh

   HOSTTAG=foo          # What we put in hosts.cfg to trigger this test
   COLUMN=$HOSTTAG	# Name of the column, often same as tag in hosts.cfg

   $XYMONHOME/bin/xymongrep $HOSTTAG | while read L
   do
      set $L	# To get one line of output from xymongrep

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

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

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

      $XYMON $XYMSRV "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 hosts.cfg file, and send one status message for each host. Other than that, it is just like the client-side tests.

How can I make the menus work on my iPad?

The menu system uses the CSS “hover” tag, but this is not supported on tablets and other touch-screen interfaces like the iPad. Mark Hinkle provides this solution to the problem:

In the ~xymon/server/etc/xymonmenu.cfg file, I added the '<a href=“javascript:;”>' anchor around the top-level menu items. Like:

<span class="menutag"><a href="javascript:;">Views</a><span class="invis">:</span></span>

How can I send data to Xymon without installing the client?

If you cannot install any “foreign” tools on your system, then sending data to Xymon may be a challenge. But if you have access to either Perl, BASH or telnet on the system then it is possible.

Perl version:

#!/usr/bin/perl
#
sub sendToXymon {
	use IO::Socket;
	my($server,$port,$msg) = @_ ;
	my $response;
	my $sock = new IO::Socket::INET (
			PeerAddr => $server,
			PeerPort => $port,
			Proto => 'tcp',
		);
	die "Could not create socket: $!\n" unless $sock;
	print $sock $msg;
	shutdown($sock, 1);
	while ($response=<$sock>)
	{
		print "$response";
	}
	close($sock);
}
 
$host = $ARGV[0];
if ($#ARGV != 2) {
  $port = 1984;
  $msg = $ARGV[1];
}
else {
  $port = $ARGV[1];
  $msg = $ARGV[2];
}
 
sendToXymon($host, $port, $msg);

BASH version:

#!/bin/bash
#
HOST="$1" ; shift
if test $# -gt 1; then
  PORT="$1"
  shift
else
  PORT="1984"
fi
MSG="$1"
 
exec 3<>/dev/tcp/$HOST/$PORT || exit 1
echo "$MSG" >&3
 
exit 0

NOTE: The BASH support for using TCP sockets may be disabled at compile-time - some believe it is a security risk to have such an easy way of doing network I/O without requiring any special tools.

Bourne / Korn shell (requires telnet):

#!/bin/sh
#
HOST="$1" ; shift
if test $# -gt 1; then
  PORT="$1"
  shift
else
  PORT="1984"
fi
MSG="$1"

( echo "$MSG"; sleep 1 ) | telnet $HOST $PORT 2>&1 >/dev/null | grep -v "closed by foreign host"

Both of these take 2 or 3 parameters: The Xymon host (hostname or IP-address), optionally the portnumber (1984 by default if not specified), and the message that will be sent to Xymon. The Perl version will both send data to Xymon and print out any response that is sent back - the shell-versions can only be used to send data to Xymon.

Oyvind Bjorge provided the core of the Perl script, and Jeremy Laidman provided the core of the shell-scripts in this thread on the Xymon mailing list.

  • tips.1499391323.txt.gz
  • Last modified: 2017/07/07 01:35
  • by wikiadmin