From 8ab4382617ae4627c7d680e0a8a4eae030f59c7f Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 10 Feb 2008 16:40:58 +0100 Subject: [PATCH] contrib/exec-nagios.px: Added a Perl script which handles Nagios plugins. It handles most of the Nagios plugin API, including multi-line output (a Nagios 3 feature) and performance data. It's basic on purpose so that easy stuff is possible but complex stuff is about as hard as rewriting the plugin ;) --- contrib/exec-nagios.conf | 13 ++ contrib/exec-nagios.px | 395 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 408 insertions(+) create mode 100644 contrib/exec-nagios.conf create mode 100755 contrib/exec-nagios.px diff --git a/contrib/exec-nagios.conf b/contrib/exec-nagios.conf new file mode 100644 index 00000000..26dd621c --- /dev/null +++ b/contrib/exec-nagios.conf @@ -0,0 +1,13 @@ +# Run `perldoc exec-nagios.px' for details on this config file. + +Interval 300 + + + + diff --git a/contrib/exec-nagios.px b/contrib/exec-nagios.px new file mode 100755 index 00000000..3a847241 --- /dev/null +++ b/contrib/exec-nagios.px @@ -0,0 +1,395 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +=head1 NAME + +exec-nagios.px + +=head1 DESCRIPTION + +This script allows you to use plugins that were written for Nagios with +collectd's C. If the plugin checks some kind of threshold, please +consider configuring the threshold using collectd's own facilities instead of +using this transition layer. + +=cut + +use Sys::Hostname ('hostname'); +use File::Basename ('basename'); +use Config::General ('ParseConfig'); +use Regexp::Common ('number'); + +our $ConfigFile = '/etc/exec-nagios.conf'; +our $TypeMap = {}; +our $Scripts = []; +our $Interval = 300; + +main (); +exit (0); + +# Configuration +# {{{ + +=head1 CONFIGURATION + +This script reads it's configuration from F. The +configuration is read using C which understands a Apache-like +config syntax, so it's very similar to the F syntax, too. + +Here's a short sample config: + + Interval 300 + + + +The options have the following semantic (i.Ee. meaning): + +=over 4 + +=item B I + +Sets the interval in which the plugins are executed. This doesn't need to match +the interval setting of the collectd daemon. Usually, you want to execute the +Nagios plugins much less often, e.Eg. every 300 seconds versus every 10 +seconds. + +=item EB