Based on some feedback, I tested some minor changes on the module.  Here they 
are:

#!/bin/sh
PREFIX=/usr/local/libexec/nagios
PLUGIN=${1}
shift 1
OUTPUT=`$PREFIX/$PLUGIN $@`
EXIT=$?
/bin/echo "=output=$OUTPUT"
case "$EXIT" in
        '0')
                echo "+nagios_plugin_${PLUGIN}_ok"
        ;;
        '1')
                echo "+nagios_plugin_${PLUGIN}_warning"
        ;;
        '2')
                echo "+nagios_plugin_${PLUGIN}_critical"
        ;;
        '3')
                echo "+nagios_plugin_${PLUGIN}_unknown"
        ;;
        *)
                echo "+nagios_plugin_${PLUGIN}_protocol_error"
        ;;
esac

I replaced the $* with a $@.  I also added a fall through for nagios plugins 
that return a non-protocol exit code.  The module is based on the Nagios 
plug-in development guidelines:

 http://nagiosplug.sourceforge.net/developer-guidelines.html

Best,

   --Bruce



On Jan 21, 2011, at 7:31 AM, Deb Heller wrote:

> Just so that you know you're not along... This is something I've been 
> considering for cfengine to do, but haven't had any cycles to do more 
> than think about it.  We're monitoring FreeBSD 7.3 and CentOS and Redhat 
> Linux 5.x flavors...
> 
> At the moment I have only moral support to offer you. :-)
> 
> deb
> 
> On 1/20/11 9:34 PM, Robert "Bruce" Carleton wrote:
>> I'm experimenting with a module that wraps nagios plugins.  I figured I'd 
>> share and see if others are doing anything like this.  I wanted to be able 
>> to set classes based on the results of the nagios plugin execution.  Here's 
>> the module shell script:
>> 
>> #!/bin/sh
>> PREFIX=/usr/local/libexec/nagios
>> PLUGIN=${1}
>> shift 1
>> OUTPUT=`$PREFIX/$PLUGIN $*`
>> EXIT=$?
>> /bin/echo "=output=$OUTPUT"
>> case "$EXIT" in
>>      '0')
>>              echo "+nagios_plugin_${PLUGIN}_ok"
>>      ;;
>>      '1')
>>              echo "+nagios_plugin_${PLUGIN}_warning"
>>      ;;
>>      '2')
>>              echo "+nagios_plugin_${PLUGIN}_critical"
>>      ;;
>>      '3')
>>              echo "+nagios_plugin_${PLUGIN}_unknown"
>>      ;;
>> esac
>> 
>> Here's the bundle I'm using for testing:
>> 
>> bundle agent nagios_mailq_check
>> {
>> classes:
>> 
>> "nagios_mailq_alert" or =>  {
>>      "nagios_plugin_check_mailq_warning",
>>      "nagios_plugin_check_mailq_critical",
>>      "nagios_plugin_check_mailq_unknown"
>>      };
>> 
>> commands:
>> 
>> my_mta_host.Hr00::
>> 
>> "/usr/local/cfengine/modules/nagios_plugin_wrapper check_mailq -w 10 -c 20"
>>      module =>  "true";
>> 
>> reports:
>> 
>> nagios_mailq_alert::
>>              "$(nagios_plugin_wrapper.output)";
>> }
>> 
>> My test configuration is FreeBSD 7.3-RELEASE-p2, running cfengine-3.0.5p1 
>> and nagios-plugins-1.4.15_1,1 from ports.
>> 
>> I guess there might be a better way to do this, but it's what I have so far. 
>>  I'd be curious to know if anyone else is trying to do a generalized nagios 
>> plugin wrapper module.  I'm not suggesting this is a better way to do host 
>> checks, but there are a lot of people cranking out nagios plugins of various 
>> kinds.  I figured this would be a way to have Cfengine be able to make use 
>> of that work.
>> 
>> Best,
>> 
>>                      --Bruce
>> 
>> 
>> 
>> _______________________________________________
>> Help-cfengine mailing list
>> Help-cfengine@cfengine.org
>> https://cfengine.org/mailman/listinfo/help-cfengine
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to