Plugin Development|
Plugins for monitor are small programs, that does the actual monitoring of host and services. They may be written in any programming language, although C and Perl are most common. They also need to follow a few rules, in order for monitor to interpret their results.
Arguments are passed from monitor to the plugin in the standard way through command-line switches. There are a few arguments that most well-written plugins support:
TimeoutIn order to accomplish a bounded run-time on the plugin the alarm() function is used to send a SIGALRM signal to the process. use lib "/opt/plugins"; # Import predefined status-codes and timeout variable use utils qw($TIMEOUT %ERRORS); $TIMEOUT = 15; # use 15 seconds as timeout # Timeout handler used $SIG{'ALRM'} = sub { print "CRITICAL: Plugin timed out after $TIMEOUT seconds\n"; exit($ERRORS{'CRITICAL'}); }; # Install timeout handler, so that the plugin does not hang indefinitely. alarm($TIMEOUT);
#include "common.h" #include "utils.h" this includes the timeout_alarm_handler() function. In order to make it fire after some time: signal (SIGALRM, timeout_alarm_handler); alarm (timeout_interval); ExamplesSince many people find examples an easy way of learning, the following links provides an example of a really simple plugin written in both Perl and C. The plugin takes one argument, a filename, and returns OK if the file exists and CRITICAL if it does not. They also include timeout-handling. Links |
|||||||||||||||||||||
