Getting Invalid Output On Nagios

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.
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Getting Invalid Output On Nagios

Post by rlinux57 »

I have created my own plugin to check the number of testing email accounts on linux server.

It gives valid output on remote host:
#/usr/lib/nagios/plugins/check_testaccounts -w 1 -c 2
1

When i have run that plugin on nagios server it gives an invalid output:
#/usr/local/nagios/libexec/check_nrpe -c check_testaccounts -H spelljob.com 1 2


Please find the attachment plugin.
Attachments
tplugin.txt
(174 Bytes) Downloaded 310 times
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Getting Invalid Output On Nagios

Post by tmcdonald »

Plugins need to have a valid exit code of 0 for OK, 1 for Warning, 2 for Critical, or 3 for Unknown. Simply outputting the results of the check will not suffice.

Also, did you configure NRPE to allow arbitrary plugin arguments?
Former Nagios employee
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Re: Getting Invalid Output On Nagios

Post by rlinux57 »

I have allow the arguments in nrpe.cfg
Kindly check the attachment plugin i have edit exit code as per your direction.
Attachments
tplugin.txt
(763 Bytes) Downloaded 298 times
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Getting Invalid Output On Nagios

Post by Box293 »

Please show us the nrpe command definition for this on the remote host.

Also, did you test this on the remote host as the user nagios?

Code: Select all

su nagios
/usr/lib/nagios/plugins/check_testaccounts -w 1 -c 2
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Re: Getting Invalid Output On Nagios

Post by rlinux57 »

On remote host working fine:
#/usr/lib/nagios/plugins/check_testaccounts -w 1 -c 2
WARNING

nrpe.cfg command definition on remote host:
command[check_testaccounts]=/usr/lib/nagios/plugins/check_testaccounts -w 1 -c 2
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Getting Invalid Output On Nagios

Post by Box293 »

A couple of things here.
rlinux57 wrote:When i have run that plugin on nagios server it gives an invalid output:
#/usr/local/nagios/libexec/check_nrpe -c check_testaccounts -H spelljob.com 1 2
rlinux57 wrote:nrpe.cfg command definition on remote host:
command[check_testaccounts]=/usr/lib/nagios/plugins/check_testaccounts -w 1 -c 2
So in your nrpe command definition you have defined the warning and critical thresholds, so you don't need to use them in your nrpe command:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -c check_testaccounts -H spelljob.com
If you did want to send them, then you would need:

Code: Select all

command[check_testaccounts]=/usr/lib/nagios/plugins/check_testaccounts -w $ARG1$ -c $ARG2$

Code: Select all

/usr/local/nagios/libexec/check_nrpe -c check_testaccounts -H spelljob.com -a 1 2
NOTE: To send arguments you must use the -a flag.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Re: Getting Invalid Output On Nagios

Post by rlinux57 »

Still it shows on nagios server:
[root@monitors ~]# /usr/local/nagios/libexec/check_nrpe -c check_testaccounts -H spelljob.com -a 1 2
NRPE: Unable to read output
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Getting Invalid Output On Nagios

Post by Box293 »

To remove dns as an issue, instead of using spelljob.com, use the IP Address.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Re: Getting Invalid Output On Nagios

Post by rlinux57 »

Still getting error.

I have define command in nagios server as:
define command{
command_name check_testaccounts
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_testaccounts $ARG1$ $ARG2$
}
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Getting Invalid Output On Nagios

Post by jdalrymple »

rlinux57 wrote:On remote host working fine:
#/usr/lib/nagios/plugins/check_testaccounts -w 1 -c 2
WARNING
It looks like you're running it as root when you test it. When nrpe runs the test script it runs as user nagios. Can you test as user nagios and see if it works. If it does then we will look elsewhere. If it doesn't, you need to resolve that.
Locked