no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | tutorials:devel [2009/02/01 03:09] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | 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: | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/sh | ||
+ | |||
+ | COLUMN=mytest # | ||
+ | COLOR=green # | ||
+ | MSG=" | ||
+ | |||
+ | # Do whatever you need to test for something | ||
+ | # As an example, go red if / | ||
+ | if test -f / | ||
+ | then | ||
+ | COLOR=red | ||
+ | MSG=" | ||
+ | |||
+ | `cat / | ||
+ | " | ||
+ | else | ||
+ | MSG=" | ||
+ | |||
+ | All is OK | ||
+ | " | ||
+ | fi | ||
+ | |||
+ | # Tell Xymon about it | ||
+ | $BB $BBDISP " | ||
+ | |||
+ | ${MSG} | ||
+ | " | ||
+ | exit 0 | ||
+ | </ | ||
+ | You will notice that some environment variables are pre-defined: | ||
+ | |||
+ | To run this, save your script in the ~hobbit/ | ||
+ | |||
+ | < | ||
+ | [myscript] | ||
+ | ENVFILE $HOBBITCLIENTHOME/ | ||
+ | CMD $HOBBITCLIENTHOME/ | ||
+ | LOGFILE $HOBBITCLIENTHOME/ | ||
+ | INTERVAL 5m | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | **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: | ||
+ | <code bash> | ||
+ | #!/bin/sh | ||
+ | |||
+ | BBHTAG=foo | ||
+ | COLUMN=$BBHTAG # | ||
+ | |||
+ | $BBHOME/ | ||
+ | do | ||
+ | set $L # To get one line of output from bbhostgrep | ||
+ | |||
+ | HOSTIP=" | ||
+ | MACHINEDOTS=" | ||
+ | MACHINE=`echo $2 | $SED -e' | ||
+ | |||
+ | COLOR=green | ||
+ | MSG=" | ||
+ | |||
+ | #... do the test, perhaps modify COLOR and MSG | ||
+ | |||
+ | $BB $BBDISP " | ||
+ | |||
+ | ${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. |