Page 1 of 2

Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 1:36 pm
by CanadianLuke
Nagios Core 4.4.3 (I know there's an update available, I'll be updating during the holidays)

NRPE Version 3.2.1.

Issue: Trying to check a remote service on Debian Linux. Locally, it succeeds. I am trying to check it remotely, but it keeps failing as per below:

Code: Select all

# /usr/lib/nagios/plugins/check_nrpe -H 10.32.10.1 -t 30 -c check_service -a 'smbd'
NRPE: Command 'check_service!smbd' not defined
Nagios command configuration:

Code: Select all

define command {
    command_name        check_nrpe
    command_line        /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$
}
NRPE Server Command Configuration (and other settings):

Code: Select all

nrpe_user=nagios
nrpe_group=nagios
allowed_hosts=127.0.0.1,10.32.10.12
dont_blame_nrpe=1
command[check_service]=/usr/lib/nagios/plugins/check_service -s $ARG1$
The log on the target server shows:

Code: Select all

Dec 20 10:25:24 fs1 nrpe[3302]: Connection from 10.32.10.12 port 35559
Dec 20 10:25:24 fs1 nrpe[3302]: Host address is in allowed_hosts
Dec 20 10:25:25 fs1 nrpe[3302]: Host 10.32.10.12 is asking for command 'check_service' to be run...
Dec 20 10:25:25 fs1 nrpe[3302]: Running command: /usr/lib/nagios/plugins/check_service -s
Dec 20 10:25:25 fs1 nrpe[3302]: Command completed with return code 2 and output: CRITICAL: Service  is not running!
Dec 20 10:25:25 fs1 nrpe[3302]: Return Code: 2, Output: CRITICAL: Service  is not running!
Dec 20 10:25:25 fs1 nrpe[3302]: Connection from 10.32.10.12 closed.
Any thoughts/ideas?

Re: Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 1:54 pm
by scottwilkerson
Can you show what $ARG1$ is set to for the service in Nagios?

Re: Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 1:56 pm
by CanadianLuke

Code: Select all

define service {
    use                 local-service
    host_name           fs1
    service_description Samba Daemon
    check_command       check_nrpe!check_service!smbd
}

Re: Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 2:00 pm
by scottwilkerson
Ok, so
$ARG1$ = check_service
$ARG2$ = smbd

Your check command is

Code: Select all

define command {
    command_name        check_nrpe
    command_line        /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$
}
When you populate this with the arguments it doesn't built the command you want as you do not have $ARG2$ in the command

Change your service definition to

Code: Select all

define service {
    use                 local-service
    host_name           fs1
    service_description Samba Daemon
    check_command       check_nrpe!check_service -a smbd
}

Re: Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 2:04 pm
by CanadianLuke
On the GUI:

NRPE: Command 'check_service!smbd' not defined

Service Definition:

Code: Select all

define service {
    use                 local-service
    host_name           fs1
    service_description Samba Daemon
    check_command       check_nrpe!check_service -a smbd
}
On the NRPE Server:

Code: Select all

Dec 20 11:03:31 fs1 nrpe[4031]: Connection from 10.32.10.12 port 33515
Dec 20 11:03:31 fs1 nrpe[4031]: Host address is in allowed_hosts
Dec 20 11:03:31 fs1 nrpe[4031]: Host 10.32.10.12 is asking for command 'check_service!smbd' to be run...
Dec 20 11:03:31 fs1 nrpe[4031]: NRPE: Command 'check_service!smbd' not defined
Dec 20 11:03:31 fs1 nrpe[4031]: Return Code: 2, Output: NRPE: Command 'check_service!smbd' not defined
Dec 20 11:03:31 fs1 nrpe[4031]: Connection from 10.32.10.12 closed.

Re: Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 2:06 pm
by scottwilkerson
Did you restart Nagios after making the change?

Re: Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 2:08 pm
by CanadianLuke
Yes, I restarted Nagios on my server, and also the Nagios-NRPE-Server service on the target. No change, same error message in both the log and the GUI as before.

Re: Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 2:13 pm
by scottwilkerson

Code: Select all

# /usr/lib/nagios/plugins/check_nrpe -H 10.32.10.1 -t 30 -c check_service -a 'smbd'
NRPE: Command 'check_service!smbd' not defined
this is really bizzarre, I see no reason why this would ever concatenation the check command and argument into check_service!smbd

Is your check_nrpe working on other servers/services?

Can you show the output of the following on the client

Code: Select all

ps -ef|grep nrpe

Re: Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 2:18 pm
by CanadianLuke

Code: Select all

# ps -ef | grep nrpe
nagios    4121     1  0 11:06 ?        00:00:00 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f
root      4424  2929  0 11:17 pts/0    00:00:00 grep nrpe
Yes, it works for other checks that are in my nrpe.cfg file. However, this is the only one that accepts (or, at least, I hope accepts) arguments.

Re: Remotely checking Debian services failing

Posted: Fri Dec 20, 2019 2:43 pm
by scottwilkerson
Can you show the output of running the following command

Code: Select all

/usr/sbin/nrpe
Also, can you attach your whole /etc/nagios/nrpe.cfg