NRPE: Unable to read output

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.
Locked
Pratapa
Posts: 144
Joined: Tue Oct 01, 2019 1:33 am

NRPE: Unable to read output

Post by Pratapa »

Hi,

We have configured Service check "Network Traffic" in one of the client machines.

But we are getting error while invoking from command prompt from Nagios server.

[root@nagios libexec]# ./check_nrpe -H host1 -c check_iftraffic
NRPE: Unable to read output

[root@nagios libexec]# ./check_nrpe -H host1
NRPE v3.2.1

Following is the entry in nrpe.cfg file on client's machine host1.

command[check_iftraffic]=/usr/lib64/nagios/plugins/ce/check_iftraffic_nrpe.pl -i eth0 -b 10000 -u m -w 85 -c 95


Following are the permissions of the file.

[root@host1 ce]# ls -l /usr/lib64/nagios/plugins/ce/check_iftraffic_nrpe.pl
-rwxr-xr-x. 1 root root 7806 Feb 14 17:22 /usr/lib64/nagios/plugins/ce/check_iftraffic_nrpe.pl

When we execute at command prompt, it is getting executed fine.

[root@host1 ce]# /usr/lib64/nagios/plugins/ce/check_iftraffic_nrpe.pl -i eth0 -b 10000 -u m -w 85 -c 95
Total RX Bytes: 1461785.40 MB, Total TX Bytes: 0.01 MB<br>Average Traffic: 31.10 kB/s (0.0%) in, 0.00 kB/s (0.0%) out| inUsage=0.0;85;95 outUsage=0.0;85;95 inBandwidth=31.10 outBandwidth=0.00 inAbsolut=1532793087445 outAbsolut=7209


We verified directory permissions also, they are fine.

[root@host1 ce]# ls -ld .
drwxr-xr-x. 2 root root 170 Feb 14 17:22 .


What could be the problem.
Pratapa
Posts: 144
Joined: Tue Oct 01, 2019 1:33 am

Re: NRPE: Unable to read output

Post by Pratapa »

Additional information :

[root@host1]# service nrpe status
Redirecting to /bin/systemctl status nrpe.service
● nrpe.service - Nagios Remote Program Executor
Loaded: loaded (/usr/lib/systemd/system/nrpe.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2020-02-14 20:16:18 AEDT; 30min ago
Docs: http://www.nagios.org/documentation
Process: 46177 ExecStopPost=/bin/rm -f /var/run/nrpe/nrpe.pid (code=exited, status=0/SUCCESS)
Main PID: 46179 (nrpe)
Tasks: 1
CGroup: /system.slice/nrpe.service
└─46179 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f

Feb 14 20:41:12 aeapsapwd01 nrpe[53420]: Warning: Could not set UID=995
Feb 14 20:44:21 aeapsapwd01 nrpe[54397]: Warning: Could not set effective GID=992
Feb 14 20:44:21 aeapsapwd01 nrpe[54397]: Warning: Unable to change supplementary groups using initgroups()
Feb 14 20:44:21 aeapsapwd01 nrpe[54397]: Warning: Could not set UID=995
Feb 14 20:44:56 aeapsapwd01 nrpe[54552]: Warning: Could not set effective GID=992
Feb 14 20:44:56 aeapsapwd01 nrpe[54552]: Warning: Unable to change supplementary groups using initgroups()
Feb 14 20:44:56 aeapsapwd01 nrpe[54552]: Warning: Could not set UID=995
Feb 14 20:46:11 aeapsapwd01 nrpe[54997]: Warning: Could not set effective GID=992
Feb 14 20:46:11 aeapsapwd01 nrpe[54997]: Warning: Unable to change supplementary groups using initgroups()
Feb 14 20:46:11 aeapsapwd01 nrpe[54997]: Warning: Could not set UID=995
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NRPE: Unable to read output

Post by benjaminsmith »

Hi Pratapa,

The permissions on the plugin are root and cannot be run by the nagios user. You can confirum this by logging in as nagios su - nagios and testing.
Following are the permissions of the file.
[root@host1 ce]# ls -l /usr/lib64/nagios/plugins/ce/check_iftraffic_nrpe.pl
-rwxr-xr-x. 1 root root 7806 Feb 14 17:22 /usr/lib64/nagios/plugins/ce/check_iftraffic_nrpe.pl
Change to and let me know if the issue is resolved.

Code: Select all

chmod 755 /path/*
chown root:nagios /path/*
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!
Pratapa
Posts: 144
Joined: Tue Oct 01, 2019 1:33 am

Re: NRPE: Unable to read output

Post by Pratapa »

We changed the permissions but still did not work.

We did further troubleshooting.

We added following two entries and checked from Nagios server.

command[check_iftraffic]=/usr/lib64/nagios/plugins/check_iftraffic_nrpe.pl -i eth0 -b 10000 -u m -w 85 -c 95
command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10


From Nagios server.

[root@nagios server]# ./check_nrpe -H host1 -c check_users
USERS OK - 1 users currently logged in |users=1;5;10;0
[root@nagios server]# ./check_nrpe -H host1 -c check_iftraffic
NRPE: Unable to read output


[root@host1 plugins]# ls -l check_users
-rwxr-xr-x. 1 root root 45336 Nov 22 2017 check_users
[root@host1 plugins]# ls -l check_iftraffic_nrpe.pl
-rwxr-xr-x. 1 root root 7806 Feb 17 19:59 check_iftraffic_nrpe.pl


[root@host1 plugins]# /usr/lib64/nagios/plugins/check_iftraffic_nrpe.pl -i eth0 -b 10000 -u m -w 85 -c 95
Total RX Bytes: 1469947.37 MB, Total TX Bytes: 0.01 MB<br>Average Traffic: 30.85 kB/s (0.0%) in, 0.00 kB/s (0.0%) out| inUsage=0.0;85;95 outUsage=0.0;85;95 inBandwidth=30.85 outBandwidth=0.00 inAbsolut=1541351533341 outAbsolut=7209


check_users and check_iftraffice_nrpe.pl are having same permissions and ownership and both the plugins are in the same directory.

check_users is working but check_iftraffic_nrpe.pl is not working.

We see that nothing wrong with the script and nothing wrong with the permissions. But still we are not getting the expected output..
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: NRPE: Unable to read output

Post by Box293 »

I googled that plugin and I found the following:

Code: Select all

# Path to  tmp files
my $TRAFFIC_FILE = "/tmp/traffic";
Does the nagios user have permission to write to this location?
A common issue is that a test is first done as a root user and the file created only has permissions for root. Then when nagios goes to run the nagios user doesn't have permission to that file.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Pratapa
Posts: 144
Joined: Tue Oct 01, 2019 1:33 am

Re: NRPE: Unable to read output

Post by Pratapa »

[root@host1 ce]# cat check_iftraffic_nrpe.pl|grep tmp
# Path to tmp files
my $TRAFFIC_FILE = "/tmp/traffic";
[root@host1 ce]# pwd
/usr/lib64/nagios/plugins/ce
[root@host1 ce]# cd /tmp
[root@host1 tmp]# ls -ld .
drwxrwxrwt. 11 root root 12288 Feb 18 17:10 .
[root@host1 tmp]# ls -l traffic
ls: cannot access traffic: No such file or directory
[root@host1 tmp]# cd traffic
-bash: cd: traffic: No such file or directory
[root@host1 tmp]# pwd
/tmp
[root@host1 tmp]# ls -l traffic_ifeth0
-rw-r--r--. 1 root root 24 Feb 18 16:42 traffic_ifeth0
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NRPE: Unable to read output

Post by scottwilkerson »

Pratapa wrote:[root@host1 tmp]# ls -l traffic_ifeth0
-rw-r--r--. 1 root root 24 Feb 18 16:42 traffic_ifeth0
My guess is this is the file it is trying to read/write to and cannot as NRPE is going to be running as the nagios user. this could be because the file was first created when you ran it from the command line as root

Lets do the following

Code: Select all

chmod +w /tmp/traffic_ifeth0
then try again
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Pratapa
Posts: 144
Joined: Tue Oct 01, 2019 1:33 am

Re: NRPE: Unable to read output

Post by Pratapa »

Yes, we did that

[root@host1 tmp]# chmod 666 /tmp/traffic_ifeth0


It's resolved.

Thank you very much.

You may lock the thread.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NRPE: Unable to read output

Post by scottwilkerson »

Pratapa wrote:Yes, we did that

[root@host1 tmp]# chmod 666 /tmp/traffic_ifeth0


It's resolved.

Thank you very much.

You may lock the thread.
Great!

Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked