Bad result code in a PERL 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.
andresrinaldi_uy
Posts: 13
Joined: Wed Oct 28, 2015 11:19 am

Bad result code in a PERL plugin

Post by andresrinaldi_uy »

Hello, I am having a extrange problem with a perl plugin:

check_iftraffic64.pl https://exchange.nagios.org/directory/P ... 64/details

This plugin checks the traffic using SNMP, and do the job fine but I have a problem when shows the results in the WEB-GUI which I could not resolv.

Image

As it can see in the image, the result is "OK" but the status is "UNKNOWN". I got in touch with the developer but he could not figure out what the problem was. I kept doing some researches and debugging but I do not know what to do, so I ask for your help. I got the same result in three Nagios installations (one of them a clean one).

Debug info:

Code: Select all

[1483644257.422936] [016.1] [pid=21070] Embedded Perl ran /usr/lib/nagios/plugins/check_iftraffic64.pl: return code=3, plugin output=OK - Average IN: 9.71KB (0.01%), Average OUT: 11.76KB (0.01%)Total RX: 1.06GBytes, Total TX: 417.88MBytes
|inUsage=0.01%;85;98 outUsage=0.01%;85;98 inBandwidth=9712.38B 
|outBandwidth=11759.16B inAbsolut=1056798111c outAbsolut=417877276c\n
return code=3

If I run the plugin from terminal and I do "echo $?" it returns code 0

I also created a perl file with:

Code: Select all

#!/usr/bin/perl -w
exit $STATUS_CODE{'OK'};
And it shows OK as result.

My command definition:

Code: Select all

define command{
        command_name    check_iftraffic64
        command_line    $USER1$/check_iftraffic64.pl -H $HOSTADDRESS$ $ARG1$
}

define service {
        use                     generic-service
        host                    hostname
        service_description     Check Traffic
        check_command         check_iftraffic64!-C nagios -i 11 -w 85 -c 98
}
OS: Debian 8.2
Nagios: Core 3.5.1 (from Debian Repository)
Apache: 2.4 (from Debian Repository)
Attachments
unknown.png
Last edited by dwhitfield on Thu Jan 12, 2017 10:21 am, edited 1 time in total.
Reason: marking with green check mark
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Bad result code in a PERL plugin

Post by dwhitfield »

What's the output of sestatus?

Did this ever work? If so, your apt log might be useful. Also, if it did work before, when did it stop working?

Is there a reason you are still running 3.5.1? Compiling from source only takes about 5 minutes. Instructions at https://support.nagios.com/kb/article.php?id=96. Do not compile from source over the top of the repo install. You'll have to uninstall if you choose to upgrade.
andresrinaldi_uy
Posts: 13
Joined: Wed Oct 28, 2015 11:19 am

Re: Bad result code in a PERL plugin

Post by andresrinaldi_uy »

Hi, thanks for your help, It never worked.

I am using this version of Nagios because it was in the Debian repositories when I installed it two years ago, I am thinking migrate to Nagios 4 as soon as can.

Could you explainme how I can see the output of setstatus?
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Bad result code in a PERL plugin

Post by dwhitfield »

andresrinaldi_uy wrote:Could you explainme how I can see the output of setstatus?
you've got a typo sestatus versus setstatus. If bash says it can't find it, then SELinux is probably not installed or not on.

You can also try cat /etc/sysconfig/selinux
andresrinaldi_uy
Posts: 13
Joined: Wed Oct 28, 2015 11:19 am

Re: Bad result code in a PERL plugin

Post by andresrinaldi_uy »

It was not installed

Code: Select all

SELinux status:     disabled
/etc/selinux/config

Code: Select all

SELINUX=permissive
SELINUXTPE=default
SETLOCALDEFS=0
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Bad result code in a PERL plugin

Post by avandemore »

When you run the plugin from the command line it should be like this:

Code: Select all

# su - nagios
$ /path/to/plugin $ARGs
Immediately after the plugin returns run:

Code: Select all

$ echo $?
Or even more concisely:

Code: Select all

# su - nagios
$ /path/to/plugin $ARGs; echo $?
Previous Nagios employee
andresrinaldi_uy
Posts: 13
Joined: Wed Oct 28, 2015 11:19 am

Re: Bad result code in a PERL plugin

Post by andresrinaldi_uy »

I have done this while I was testing and all seems to work fine, but in the WEB-GUI still orange it does not matter if OK or CRITICAL, the return code is always 3

Image
Attachments
cmd.png
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Bad result code in a PERL plugin

Post by dwhitfield »

Perhaps there is a permission error. What's the output of ls -la /usr/lib/nagios/plugins?
andresrinaldi_uy
Posts: 13
Joined: Wed Oct 28, 2015 11:19 am

Re: Bad result code in a PERL plugin

Post by andresrinaldi_uy »

I've already checked it, the same permissions that other plugins.

Code: Select all

-rwxr-xr-x 1 root root  39175 ene  9 18:07 check_iftraffic64.pl
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Bad result code in a PERL plugin

Post by rkennedy »

The original definition you have varies from the check command you posted above. The screenshot mentions -i 65539 where as your service definition is for 11. You'll want to match these up in order to see the same result across the board.
Former Nagios Employee
Locked