Nagios xi services requiring sudo permissions don't work

This support forum board is for support questions relating to Nagios xi, our flagship commercial network monitoring solution.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Nagios xi services requiring sudo permissions don't work

Post by benjaminsmith »

Hi,

I spun up test system running Cent 8 and installed the Linux Agent (see: https://assets.nagios.com/downloads/nag ... _Agent.pdf) and I'm not able to repeat the error.

On the remote host side, here is my check command in nrpe.cfg.

Code: Select all

command[check_service]=/usr/local/nagios/libexec/check_init_service $ARG1$
I'm testing this against the cron service without any troubles.
[root@localhost libexec]# ./check_nrpe -H 192.168.8.94
NRPE v4.0.2
[root@localhost libexec]# ./check_nrpe -H 192.168.8.94 -c check_service -a 'crond'
active
[root@localhost libexec]#
Can you send over the NRPE.cfg file and provide the step you used to install NRPE and I can try to replicate this on my end. Thanks, Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
HIINNS
Posts: 172
Joined: Wed Mar 14, 2018 9:43 am

Re: Nagios xi services requiring sudo permissions don't work

Post by HIINNS »

I was able to install NRPE by running a nrpe.tar.gz file found in my "Error getting NRPE to install on Rewdhat 8" case. The nrpe.cfg file was posted previous to this.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Nagios xi services requiring sudo permissions don't work

Post by benjaminsmith »

HI,

Okay, just to confirm, did you follow the instructions below? Those are the official docs, I recommend following the guide below. NRPE is very mature open-source application so there are quite a few online tutorials, some good and some out of date.

https://support.nagios.com/kb/article/n ... .html#RHEL

I looked over the NRPE.CFG file, you'll need to add the command definition to this file. On the remote server, open this file up add add the following under #COMMAND DEFINITIONS.

Code: Select all

command[check_init_service]=sudo /usr/local/nagios/libexec/check_init_service $ARG1$
Restart NRPE, systemctl restart nrpe, and then test once more.

For more details on the process, please refer to the following kb article.

NRPE - Agent and Plugin Explained

Let me know if it's working now.

--Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
HIINNS
Posts: 172
Joined: Wed Mar 14, 2018 9:43 am

Re: Nagios xi services requiring sudo permissions don't work

Post by HIINNS »

Benjamin, nrpe does not run as a service. It is run under xinetd.
● nrpe.service not-found failed failed nrpe.service
HIINNS
Posts: 172
Joined: Wed Mar 14, 2018 9:43 am

Re: Nagios xi services requiring sudo permissions don't work

Post by HIINNS »

Added command[check_init_service]=sudo /usr/local/nagios/libexec/check_init_service $ARG1$ to nrpe..cfg. Restarted the xinetd service. Still get the same error.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Nagios xi services requiring sudo permissions don't work

Post by benjaminsmith »

Hi HIINNS,

If you installed it from the source, it would be configured as a standalone service and not running under xinetd. What is the output of the following command?

Code: Select all

 cat /etc/xinetd.d/nrpe
Let's turn on debug mode to see if we can get some details on why it's not able to run the check. Open up nrpe.cfg on the remote host and set the following values.

Code: Select all

# LOG FILE
# If a log file is specified in this option, nrpe will write to
# that file instead of using syslog.

log_file=/usr/local/nagios/var/nrpe.log

# DEBUGGING OPTION
# This option determines whether or not debugging messages are logged to the
# syslog facility.
# Values: 0=debugging off, 1=debugging on

debug=1
Then run the check again from the xi server and post the /usr/local/nagios/var/nrpe.log to the ticket.

Thanks,
Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Nagios xi services requiring sudo permissions don't work

Post by benjaminsmith »

Hi,

I reached out to another team member and there's a chance the check_init_service is not compatible with systemctl, so we'd like to check that.

Log into the remote system, and run the following commands and post the output.

Code: Select all

su - nagios
/usr/local/nagios/libexec/check_init_service crond
Then attach the following file to the thread. Thanks for your cooperation.

Code: Select all

/usr/local/nagios/libexec/check_init_service 
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
HIINNS
Posts: 172
Joined: Wed Mar 14, 2018 9:43 am

Re: Nagios xi services requiring sudo permissions don't work

Post by HIINNS »

cat /etc/xinetd.d/nrpe
# default: off
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
disable = no
per_source = 25
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
only_from = 127.0.0.1 <Nagios xi IP.
log_on_success =
}

/usr/local/nagios/var
[yypuppet@nsolsrd4 var]$ ls -la
total 0
drwxr-xr-x. 3 nagios nagios 19 Jul 1 16:06 .
drwxr-xr-x. 7 nagios nagios 67 Jul 1 16:06 ..
drwxr-xr-x. 2 nagios nagios 6 Jul 1 16:06 spool
No /usr/local/nagios/var directory

su - nagios
[nagios@nsolsrd4 ~]$ /usr/local/nagios/libexec/check_init_service crond
active
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Nagios xi services requiring sudo permissions don't work

Post by ssax »

What does /var/log/messages or /var/log/syslog show on the remote system when you run the check through nrpe?

Does calling it without any arguments work?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X
Change your check command to this:

Code: Select all

command[check_init_service]=sudo /usr/local/nagios/libexec/check_init_service $ARG1$ 2>&1
Then run the check again and send the full output:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <Red Hat 8 client> -t 30 -c check_init_service -a 'crond'
What is the output of these commands on the remote system?

Code: Select all

ps aux | grep nrpe
find / -name nrpe.cfg
HIINNS
Posts: 172
Joined: Wed Mar 14, 2018 9:43 am

Re: Nagios xi services requiring sudo permissions don't work

Post by HIINNS »

Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=PROCTITLE msg=audit(1627377439.495:231386461): proctitle="(systemd)"
Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=EOE msg=audit(1627377439.495:231386461):
Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=SYSCALL msg=audit(1627377439.496:231386462): arch=c000003e syscall=257 success=yes exit=14 a0=f a1=561bfea9e7d1 a2=2a0000 a3=0 items=1 ppid=1 pid=1251959 auid=7887 uid=7887 gid=400 euid=7887 suid=7887 fsuid=7887 egid=400 sgid=400 fsgid=400 tty=(none) ses=13396 comm="systemd" exe="/usr/lib/systemd/systemd" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key="successful-access" ARCH=x86_64 SYSCALL=openat AUID="mylogin" UID="mylogin" GID="nagroup" EUID="mylogin" SUID="mylogin" FSUID="mylogin" EGID="nagroup" SGID="nagroup" FSGID="nagroup"
Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=CWD msg=audit(1627377439.496:231386462): cwd="/"
Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=PATH msg=audit(1627377439.496:231386462): item=0 name="block" inode=45587 dev=00:15 mode=040755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:sysfs_t:s0 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0 OUID="root" OGID="root"
Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=PROCTITLE msg=audit(1627377439.496:231386462): proctitle="(systemd)"
Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=EOE msg=audit(1627377439.496:231386462):
Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=SYSCALL msg=audit(1627377439.496:231386463): arch=c000003e syscall=257 success=yes exit=15 a0=e a1=561bfea9e7d1 a2=2a0000 a3=0 items=1 ppid=1 pid=1251959 auid=7887 uid=7887 gid=400 euid=7887 suid=7887 fsuid=7887 egid=400 sgid=400 fsgid=400 tty=(none) ses=13396 comm="systemd" exe="/usr/lib/systemd/systemd" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key="successful-access" ARCH=x86_64 SYSCALL=openat AUID="mylogin" UID="mylogin" GID="nagroup" EUID="mylogin" SUID="mylogin" FSUID="mylogin" EGID="nagroup" SGID="nagroup" FSGID="nagroup"
Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=CWD msg=audit(1627377439.496:231386463): cwd="/"
Jul 27 05:17:19 nagclient audisp-syslog[1483]: node=nagclient type=PATH msg=audit(1627377439.496:231386463): item=0 name="dm-11" inode=48616 dev=00:15 mode=040755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:sysfs_t:s0 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0 OUID="root" OGID="root" - From /var/log/messages

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X
NRPE v4.0.3 - From Nagiosxi server

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X
-bash: /usr/local/nagios/libexec/check_nrpe: No such file or directory - From Nagios client

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X -t 30 -c check_init_service -a 'crond'
sh: sudo: command not found - After making change.

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X -t 30 -c check_init_service -a 'crond'
sh: sudo: command not found - From Nagios xi server

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X -t 30 -c check_init_service -a 'crond'
-bash: /usr/local/nagios/libexec/check_nrpe: No such file or directory - From RH8 client

ps aux | grep nrpe - This command shows nothing. NRPE runs under xinetd.

find / -name nrpe.cfg
/tmp/linux-nrpe-agent/subcomponents/nrpe/mods/cfg/nrpe.cfg
/usr/share/common/AIX/nagios/linux-nrpe-agent/agentstuff/etc/nrpe.cfg
/usr/share/common/AIX/nagios/linux-nrpe-agent/subcomponents/nrpe/mods/cfg/nrpe.cfg
/usr/share/common/AIX/nagios/brw/agentstuff/etc/nrpe.cfg
/usr/share/common/AIX/nagios/brw/subcomponents/nrpe/mods/cfg/nrpe.cfg
/usr/local/nagios/etc/nrpe.cfg
/tc/tcsoftware/usrid/Orchetstration/Nagios/Nagios-xi/linux-nrpe-agent/subcomponents/nrpe/mods/cfg/nrpe.cfg
/tc/tcsoftware/usrid/tc-nagios/Orig-installation-n-files/nrpe.cfg
/tc/tcsoftware/General_Software/Nagios/john-notes/linux-nrpe-agent/subcomponents/nrpe/mods/cfg/nrpe.cfg
/tc/tcsoftware/General_Software/Nagios/john-notes/nrpe.cfg
/tc/tcsoftware/General_Software/Nagios/linux-nrpe-agent/subcomponents/nrpe/mods/cfg/nrpe.cfg
/tc/tcsoftware/General_Software/Nagios/Linuxclient/linux-nrpe-agent/subcomponents/nrpe/mods/cfg/nrpe.cfg
/tc/tcsoftware/General_Software/Nagios/subcomponents/nrpe/nrpe-3.2.1/sample-config/nrpe.cfg
/tc/tcsoftware/General_Software/Nagios/subcomponents/nrpe/mods/cfg/nrpe.cfg
/tc/tcsoftware/General_Software/Nagios/subcomponents/nrpe/nrpe-4.0.2/sample-config/nrpe.cfg
/tc/tcsoftware/General_Software/Nagios/NRPE4/linux-nrpe-agent/subcomponents/nrpe/mods/cfg/nrpe.cfg