External Program Monitors
An external program monitor can be written in any language. The Traffic Manager passes command-line arguments to the executable:
domonitor --ipaddr=<machine_to_monitor> \
--node=<nodename> \
--port=<port_to_monitor>
The ipaddr, node, and port arguments are always passed to an external program monitor. The node argument is the hostname part of the node, as configured in the pool, and the ipaddr is the corresponding IP address.
You can also specify additional arguments for the monitor, which may be useful if you are using the same executable for several different monitoring tasks. Use the “Program Arguments” section of the Edit page for the monitor in question.
For example, if you configured two additional arguments (named “regex” and “interface”) and gave then appropriate values on the Edit page, the monitor executable would be invoked as follows:
domonitor --ipaddr=<machine_to_monitor> \
--node=<nodename> \
--port=<port_to_monitor> \
--interface=<interface_value> \
--regex=<regex_value>
A successful monitor should exit with an exit code of 0; a timeout or non-zero exit code is interpreted as failure, and in this case the contents of STDERR are written to the Event Log.
When you develop and test a monitor executable or script, you can easily run it from the command line, providing arguments in the format described above. Your monitor can emit debugging information to STDOUT.
When the monitor is used by the Traffic Manager, you can enable verbose mode. If the monitor is called in verbose mode, anything printed to STDOUT by the executable is written to the Event Log; verbose mode can be toggled on the monitor’s Edit page.
Uploading Monitors to the Traffic Manager
To upload, manage, and delete monitors on the Traffic Manager, click Catalog > Extra Files > Monitor Programs.
Writing Monitors in Perl
If you choose to write your monitor in Perl, use the helper module, Monitor.pm, included with your Traffic Manager. This includes a ParseArguments() function, as well as functions to exit with success or failure and to write out logs.
use Zeus::ZXTM::Monitor qw( ParseArguments
MonitorWorked
MonitorFailed
Log );
%ARGS = ParseArguments();
Log( "Running test" );
if( do_test( $ARGS{ipaddr}, $ARGS{port} ) ) {
MonitorWorked();
} else {
MonitorFailed( $error_message );
}
For more information on Monitor.pm, use the following command:
$ perldoc ZEUSHOME/zxtm/lib/perl/Zeus/ZXTM/Monitor.pm