Check Script not able to run

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
cyberportnoc
Posts: 66
Joined: Tue Nov 24, 2015 1:14 am

Check Script not able to run

Post by cyberportnoc »

Dear support,

We placed the check_mem.pl into a client of nagios:
[root@rhel64-02 nagios]# cat nrpe.cfg | grep check_mem.pl
command[nagios_memory]=sudo /etc/nagios/nrpe.d/check_mem.pl -uC -w 70 -c 90
sudo /etc/nagios/nrpe.d/check_mem.pl -uC -w 70 -c 90
OK - 5.7% (5617476 kB) used.|TOTAL=99005228KB;;;; USED=5617476KB;69303659;89104705;; FREE=93387752KB;;;; CACHES=93034200KB;;;;

However, when i try to run the remote check from nagios server, it reply Unable to read output
[root@ccnagios01 libexec]# ./check_nrpe -H 192.168.38.144 -c nagios_memory
NRPE: Unable to read output

Please advise. Thanks
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Check Script not able to run

Post by bwallace »

The "Unable to read output" error is only caused by a few things:
1. NRPE not running.
2. Incorrect plugin path in nrpe.cfg
3. Permission issues with the plugin.

This doc addresses all of the above, have you already worked through it?
https://assets.nagios.com/downloads/nag ... 1456514247
Be sure to check out the Knowledgebase for helpful articles and solutions!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Check Script not able to run

Post by rkennedy »

Can you also post your sudoers file for us to look at?

Also, from RHEL64-02, as the nagios user, please post the full output of sudo /etc/nagios/nrpe.d/check_mem.pl -uC -w 70 -c 90
Former Nagios Employee
cyberportnoc
Posts: 66
Joined: Tue Nov 24, 2015 1:14 am

Re: Check Script not able to run

Post by cyberportnoc »

Dear rkenned,

If i modify memory use the default nagios memory check script in client . it is able to get the output from nagios server.
==========
[root@rhel64-02 nagios]# cat nrpe.cfg | grep memory
command[nagios_memory]=/etc/nagios/nrpe.d/nagios_memory.sh -w 70 -c 90

[root@ccnagios01 libexec]# ./check_nrpe -H 192.168.38.144 -c nagios_memory
99.6701% Used:CRITICAL
96365 / 96684 MB (99.6701%) Used Memory, Shared: 0 MB, Buffers: 212 MB, Cached: 90427 MB
| used=99.6701%;70;90;0;100
==========

However, if i change it to use check_mem.pl, then it will return unable to read output
==========
[root@rhel64-02 nagios]# cat nrpe.cfg | grep memory
command[nagios_memory]=/etc/nagios/nrpe.d/check_mem.pl -uC -w 70 -c 90

[root@ccnagios01 libexec]# ./check_nrpe -H 192.168.38.144 -c nagios_memory
NRPE: Unable to read output
==========

Below is output of sudo

[root@rhel64-02 nagios]# sudo /etc/nagios/nrpe.d/check_mem.pl -uC -w 70 -c 90
OK - 5.6% (5561000 kB) used.|TOTAL=99005228KB;;;; USED=5561000KB;69303659;89104705;; FREE=93444228KB;;;; CACHES=93084484KB;;;;

Please advise.

Thanks,
Kelvin
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Check Script not able to run

Post by Box293 »

cyberportnoc wrote:Below is output of sudo

[root@rhel64-02 nagios]# sudo /etc/nagios/nrpe.d/check_mem.pl -uC -w 70 -c 90
OK - 5.6% (5561000 kB) used.|TOTAL=99005228KB;;;; USED=5561000KB;69303659;89104705;; FREE=93444228KB;;;; CACHES=93084484KB;;;;

Please advise.

Thanks,
Kelvin
When nrpe goes to execute the command, it does it as the nagios user. I can see your test is as the root user. Can you please re-test your command as the nagios user:

Code: Select all

su nagios
sudo /etc/nagios/nrpe.d/check_mem.pl -uC -w 70 -c 90
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
cyberportnoc
Posts: 66
Joined: Tue Nov 24, 2015 1:14 am

Re: Check Script not able to run

Post by cyberportnoc »

Dear Box,

There are no nagios user exist in server.
It is run by nrpe process

[root@rhel64-02 ~]# cat /etc/passwd | grep nagios
nagios:x:498:499::/var/spool/nagios:/sbin/nologin
[root@rhel64-02 ~]# cat /etc/passwd | grep nrpe
nrpe:x:497:498:NRPE user for the NRPE service:/var/run/nrpe:/sbin/nologin
[root@rhel64-02 ~]# su nrpe
This account is currently not available.
[root@rhel64-02 ~]#

Please advise.

Thanks,
Kelvin
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Check Script not able to run

Post by tgriep »

It could be a permission issue with the perl plugin. Can you run the following and post the output?

Code: Select all

ls -l /etc/nagios/nrpe.d/
Does the nrpe user have the ability to read and execute that script?
If not, make sure that account is setup with the ability to do so.
Be sure to check out our Knowledgebase for helpful articles and solutions!
cyberportnoc
Posts: 66
Joined: Tue Nov 24, 2015 1:14 am

Re: Check Script not able to run

Post by cyberportnoc »

Dear tgriep,

[root@rhel64-02 ~]# ls -l /etc/nagios/nrpe.d/
total 88
-rwxr-xr-x. 1 root root 12330 May 17 18:50 check_mem
-rw-r-xr-x. 1 root root 9244 Aug 4 2014 nagios_cpu.sh
-rw-r-xr-x. 1 root root 2018 Aug 4 2014 nagios_diskio.sh
-rw-r-xr-x. 1 root root 4004 Sep 12 2014 nagios_diskspace.sh
-rw-r-xr-x. 1 root root 4004 Sep 12 2014 nagios_diskspace.sh.old
-rw-r-xr-x. 1 root root 5885 Aug 13 2014 nagios_guest_cpu.sh
-rw-r-xr-x. 1 root root 6249 Aug 13 2014 nagios_guest_diskio.sh
-rw-r-xr-x. 1 root root 5155 Aug 13 2014 nagios_guest_memory.sh
-rw-r-xr-x. 1 root root 7188 Aug 13 2014 nagios_guest_networkio.sh
---------x. 1 root root 2624 Aug 13 2014 nagios_guest_sudo.sh
-rw-r-xr-x. 1 root root 3287 Aug 4 2014 nagios_memory.sh
-rw-r-xr-x. 1 root root 6588 Aug 13 2014 nagios_networkio.sh

How can i verify on "nrpe user have the ability to read and execute that script?"

Please advise.

Thanks,
Kelvin
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Check Script not able to run

Post by tgriep »

It looks like the command that is defined in the nrpe.cfg file needs to be updated as the file name of the plugin doesn't match the command.
Can you edit the nrpe.cfg file and change the following line from

Code: Select all

command[nagios_memory]=sudo /etc/nagios/nrpe.d/check_mem.pl -uC -w 70 -c 90
to

Code: Select all

command[nagios_memory]=sudo /etc/nagios/nrpe.d/check_mem -uC -w 70 -c 90
Save that file and restart xinetd and that should solve the issue for you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
cyberportnoc
Posts: 66
Joined: Tue Nov 24, 2015 1:14 am

Re: Check Script not able to run

Post by cyberportnoc »

Dear tgriep,

In client side:
[root@rhel64-02 ~]# cat /etc/nagios/nrpe.cfg | grep memory
command[nagios_memory]=/etc/nagios/nrpe.d/check_mem -f -w 70 -c 90

[root@rhel64-02 ~]# service nrpe restart
Shutting down nrpe: [ OK ]
Starting nrpe: [ OK ]

In server side.
[root@ccnagios01 libexec]# ./check_nrpe -H 192.168.38.144 -c nagios_memory
NRPE: Unable to read output

Please advise.

Thanks,
Kelvin
Locked