Is there a way to treat the message "No output returned from plugin" as WARNING or CRITICAL state. In my Nagios XI it is judged as OK. Thanks.
Olaf
No output returned from plugin
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: No output returned from plugin
Hello, @enas. Do you know why the plugin isn't returning any output? I'd say this is an unusual behavior. As far as return states, you will probably need to modify the source code. You can take a look at this Development guideline for a better understanding:
http://nagios-plugins.org/doc/guidelines.html
Also, can you upload the plugin here? If the source code is easy enough to be changed in a few minutes I may be able to help you fix it.
http://nagios-plugins.org/doc/guidelines.html
Also, can you upload the plugin here? If the source code is easy enough to be changed in a few minutes I may be able to help you fix it.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: No output returned from plugin
Hello,
the reason why I'm asking is that: I monitored APC UPS in the past. Now we replaced them by Eaton UPS. I changed some of the OIDs and got OK results. But the other Tests unexpectedly were looking OK as well even with no output from the plugin. I would have to adjust the OIDs.
But it would be great if Nagios would show in such a case a state of UNKNOWN instead of OK. One would possibly oversee the problems.
Is there a way to tell Nagios: set a "No output" result as UNKNOWN?
Thanks
Olaf
the reason why I'm asking is that: I monitored APC UPS in the past. Now we replaced them by Eaton UPS. I changed some of the OIDs and got OK results. But the other Tests unexpectedly were looking OK as well even with no output from the plugin. I would have to adjust the OIDs.
But it would be great if Nagios would show in such a case a state of UNKNOWN instead of OK. One would possibly oversee the problems.
Is there a way to tell Nagios: set a "No output" result as UNKNOWN?
Thanks
Olaf
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: No output returned from plugin
@enas, Are you using the check snmp plugin? Can you check the version number?
You should see the version number at the top.
Please also send us the command that you're running and the returned output. A screenshot of an empty output in XI may be helpful as well.
Code: Select all
cd /usr/local/nagios/libexec/
./check_snmp --help
Please also send us the command that you're running and the returned output. A screenshot of an empty output in XI may be helpful as well.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: No output returned from plugin
In the screenshot of Nagios view you can see, what I meant. In the upper lines there is no output with an UNKNOWN state. That's what I would expect. But in the lowest lines you see also "No output" but with a OK state. That's what I like to prevent.
BTW, the plugin is self-written. I have 4 UPS identically configured in Nagios. With one of the UPS I get these UNKNOWN failures. When testing in bash under user nagios the plugin works:
[nagios@nagios libexec]# ./check_eaton_ups.sh -H enspw2-1 -l -c 60 -w 50
OK - Output load is at 35 % of rated capacity.
When testing from CCM I'm getting also a result. (second screenshot)
But the Nagios view shows me "Could not get value ..". Why?
The only log entry I could find is:
Dec 11 09:44:50 nagios nagios: SERVICE ALERT: enspwe-1.intern.enas.fraunhofer.de;checks ups battery state prio2;UNKNOWN;HARD;4;UNKNOWN - Batterytest has unexpected state. ()
BTW, the plugin is self-written. I have 4 UPS identically configured in Nagios. With one of the UPS I get these UNKNOWN failures. When testing in bash under user nagios the plugin works:
[nagios@nagios libexec]# ./check_eaton_ups.sh -H enspw2-1 -l -c 60 -w 50
OK - Output load is at 35 % of rated capacity.
When testing from CCM I'm getting also a result. (second screenshot)
But the Nagios view shows me "Could not get value ..". Why?
The only log entry I could find is:
Dec 11 09:44:50 nagios nagios: SERVICE ALERT: enspwe-1.intern.enas.fraunhofer.de;checks ups battery state prio2;UNKNOWN;HARD;4;UNKNOWN - Batterytest has unexpected state. ()
You do not have the required permissions to view the files attached to this post.
Re: No output returned from plugin
Strictly speaking, this scenario should be handled in your plugin's logic. Allowing Nagios Core to determine status codes beyond what was returned as the exit code is a whole can of worms that could lead to some poor design patterns in community plugins. Just my 2 cents on that topic.enas wrote:Is there a way to treat the message "No output returned from plugin" as WARNING or CRITICAL state.
...
But in the lowest lines you see also "No output" but with a OK state. That's what I like to prevent.
As to why this is happening with your plugin, awk and sed both strip the unix exit codes of the original command that is piped in (credit to @Box293 for teaching me this). I notice your plugin uses awk extensively. Unless you're feeding awk total junk, it's going to always return 0 for the exit code regardless of what happened in the snmpget.
As one potential solution, you could leverage Bash's $PIPESTATUS variable to make sure you aren't losing your snmpget exit codes once they're passed into awk. Like so:
https://stackoverflow.com/questions/122 ... us-in-bash
I haven't looked thoroughly at the plugin, and I'm not really a Bash guy, so perhaps you've already addressed this. I thought it was worth mentioning anyway
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: No output returned from plugin
@enas, In addition to @mcapra post, i'd like to add that in CCM you may select the "initial state" for this particular service. You may choose Warning or Critical, and that should force the service state to be Warning or Critical unless the plugin actually returns a different status code.
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.