Writing a custom sensor - how to mark feedback as error

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
tzemljak
Posts: 5
Joined: Tue Jan 08, 2013 3:42 am

Writing a custom sensor - how to mark feedback as error

Post 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.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

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

Post by slansing »

Have you added return codes into your plugin? This is the main modifier used by Nagios when passing check results to it.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post 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. 
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
tzemljak
Posts: 5
Joined: Tue Jan 08, 2013 3:42 am

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

Post 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*
Locked