Need help with a new plugin

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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Need help with a new plugin

Post by tmcdonald »

MaxHeadroom wrote:
tmcdonald wrote:The exit code of 0 through 3 determines the OK, WARNING, CRITICAL, or UNKNOWN status
When you say "Exit code", you don't actually mean the plugin exits, do you?
Yes I do. A plugin is run on a schedule by Nagios, usually every 5 minutes. Nagios (in C-lingo) uses, I believe, execv() to run the plugin and capture the output and exit code. The code is used to determine the state of the host/service that the plugin is ran for.
MaxHeadroom wrote: These look like command line options. What if I have dozens of thresholds? thanks for the great dialog.
Randy
Then you should either create dozens of services, one for each different type of threshold, or you should code your plugin in such a way that it considers all of those thresholds and knows what to do with them.

If you are familiar with the UNIX philosophy of things, it's "Write programs that do one thing, and do it well". Plugins should be written this way. They should be only as configurable as they need to be - if an email-checking plugin starts considering DHCP offers, it is probably time to split it into two plugins. In your case, with that many thresholds I almost wonder if your plugin is doing too much.
Former Nagios employee
MaxHeadroom
Posts: 6
Joined: Tue Jun 30, 2015 6:27 am

Re: Need help with a new plugin

Post by MaxHeadroom »

Thanks for the information.

The plugins appear to implement a polling pattern (I.e., check_temp, check_snmp, check_uptime.) How do I handle a status that is pushed to me?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Need help with a new plugin

Post by tmcdonald »

Not quite sure what you mean by "polling pattern" in this context. Can you link to the plugin or otherwise provide an example of it running?

In regards to a status that is pushed, do you mean a remote agent/machine is sending results to Nagios? If so that is called a passive check and follows a similar requirement of needing an exit code and status output.
Former Nagios employee
Locked