Page 1 of 1

Writing a custom sensor - how to mark feedback as error

Posted: Wed Jan 09, 2013 5:31 am
by tzemljak
Hi all,
i'm writing a custom sensor , it does a curl query and reports feedback as result. There are two possible feedbacks, one is similar to "{:status 0, :desc "Alive: 29741}" and it means service is ok, and reports it's PID, other is similar to "{:status 0, :desc "Started: 2012-08-30-10:13"}," and it's a error - it reports service was last seen alive at mentioned date.

How can i get a green/red indicator in nagios for mentioned sensor feedbacks ? Desired behavior is 'ALL GREEN' while sensor reports 'Alive' , and 'RED/CRIT' for anything else.
Sensor works like this:
ServerA monitors ServerB via NRPE. On serverB there is a custom NRPE sensor that runs a bash script that has a curl query in it.
ServerA runs Nagios Core on Debian linux, ServerB runs NRPE on CentOS 6.x linux.

Thank you in advance.

Re: Writing a custom sensor - how to mark feedback as error

Posted: Wed Jan 09, 2013 10:44 am
by slansing
Have you added return codes into your plugin? This is the main modifier used by Nagios when passing check results to it.

Re: Writing a custom sensor - how to mark feedback as error

Posted: Wed Jan 09, 2013 10:49 am
by abrist
You should read through the plugin development guidelines as this is covered there:

http://nagiosplug.sourceforge.net/devel ... html#AEN76

You will need to make your plugin return exit codes.

From the dev guidelines:

Code: Select all

0 - OK (green in nagios)
The plugin was able to check the service and it appeared to be functioning properly

1 - Warning (yellow)
The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly

2 - Critical (red)
The plugin detected that either the service was not running or it was above some "critical" threshold

3 - Unknown (orange)
Invalid command line arguments were supplied to the plugin or low-level failures internal to the plugin (such as unable to fork, or open a tcp socket) that prevent it from performing the specified operation. Higher-level errors (such as name resolution errors, socket timeouts, etc) are outside of the control of plugins and should generally NOT be reported as UNKNOWN states. 

Re: Writing a custom sensor - how to mark feedback as error

Posted: Thu Jan 10, 2013 7:45 am
by tzemljak
Thank you, i paired up exit codes and text feedback. One more thing to watch out for is that code+text has to be in one line.
*Solved*