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

Re: Check Script not able to run

Post by cyberportnoc »

Dear Box,

Below are the result:

[root@ccnagios01 libexec]# ./check_nrpe -H 192.168.38.144 -c nagios_memory
log from client:
May 31 17:48:01 rhel64-02 nrpe[32592]: Connection from 192.168.38.142 port 4290
May 31 17:48:01 rhel64-02 nrpe[32592]: Host address is in allowed_hosts
May 31 17:48:01 rhel64-02 nrpe[32592]: Handling the connection...
May 31 17:48:01 rhel64-02 nrpe[32592]: Host is asking for command 'nagios_memory' to be run...
May 31 17:48:01 rhel64-02 nrpe[32592]: Running command: /etc/nagios/nrpe.d/check_mem -uC -w 70 -c 90
May 31 17:48:01 rhel64-02 nrpe[32592]: Command completed with return code 3 and output:
May 31 17:48:01 rhel64-02 nrpe[32592]: Return Code: 3, Output: NRPE: Unable to read output
May 31 17:48:01 rhel64-02 nrpe[32592]: Connection from ▒Q{▒#177 closed.

[root@ccnagios01 libexec]# ./check_nrpe -H 192.168.38.144 -c nagios_cpu
log from client:
May 31 17:48:08 rhel64-02 nrpe[32596]: Connection from 192.168.38.142 port 6850
May 31 17:48:08 rhel64-02 nrpe[32596]: Host address is in allowed_hosts
May 31 17:48:08 rhel64-02 nrpe[32596]: Handling the connection...
May 31 17:48:08 rhel64-02 nrpe[32596]: Host is asking for command 'nagios_cpu' to be run...
May 31 17:48:08 rhel64-02 nrpe[32596]: Running command: /etc/nagios/nrpe.d/nagios_cpu.sh
May 31 17:48:10 rhel64-02 nrpe[32596]: Command completed with return code 0 and output: OK #012 user: 0%, system: 0%, iowait: 0%, idle: 100% #012 | cpu_user=0%;70;90; cpu_sys=0%;70;90; cpu_iowait=0%;70;90; cpu_idle=100%;
May 31 17:48:10 rhel64-02 nrpe[32596]: Return Code: 0, Output: OK #012 user: 0%, system: 0%, iowait: 0%, idle: 100% #012 | cpu_user=0%;70;90; cpu_sys=0%;70;90; cpu_iowait=0%;70;90; cpu_idle=100%;
May 31 17:48:10 rhel64-02 nrpe[32596]: Connection from ▒Q{▒#177 closed.


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 that the nrpe account on the remote server is set to /sbin/nologin and that could cause the plugin to not function.
Ca you edit the /etc/passwd file and change this line from

Code: Select all

nrpe:x:497:498:NRPE user for the NRPE service:/var/run/nrpe:/sbin/nologin
to

Code: Select all

nrpe:x:497:498:NRPE user for the NRPE service:/var/run/nrpe:/bin/bash
Also, can you edit the nrpe.cfg file and change your command from

Code: Select all

/etc/nagios/nrpe.d/check_mem -uC -w 70 -c 90
to

Code: Select all

/etc/nagios/nrpe.d/check_mem -u -C -w 70 -c 90
Make sure you restart the daemon that controls the startup of the nrpe agent so it will reload the changes.
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,

I modify the passwd file and nrpe.cfg. We also restarted the service.
[root@rhel64-02 ~]# cat /etc/passwd | grep nrpe
nrpe:x:497:498:NRPE user for the NRPE service:/var/run/nrpe:/bin/bash

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

However, the output is still same
[root@ccnagios01 libexec]# ./check_nrpe -H 192.168.38.144 -c nagios_memory
NRPE: Unable to read output

Jun 1 09:35:51 rhel64-02 nrpe[5536]: Connection from 192.168.38.142 port 15342
Jun 1 09:35:51 rhel64-02 nrpe[5536]: Host address is in allowed_hosts
Jun 1 09:35:51 rhel64-02 nrpe[5536]: Handling the connection...
Jun 1 09:35:51 rhel64-02 nrpe[5536]: Host is asking for command 'nagios_memory' to be run...
Jun 1 09:35:51 rhel64-02 nrpe[5536]: Running command: /etc/nagios/nrpe.d/check_mem -u -C -w 70 -c 90
Jun 1 09:35:51 rhel64-02 nrpe[5536]: Command completed with return code 3 and output:
Jun 1 09:35:51 rhel64-02 nrpe[5536]: Return Code: 3, Output: NRPE: Unable to read output
Jun 1 09:35:51 rhel64-02 nrpe[5536]: Connection from closed.

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 »

Can you login to the remote host, run the following commands and post the output?

chmod 777 /etc/nagios/nrpe.d/check_mem
su nrpe
/etc/nagios/nrpe.d/check_mem -u -C -w 70 -c 90
echo $?
getenforce
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,

Below are information for you:
[root@rhel64-02 ~]# cat /etc/passwd | grep nrpe
nrpe:x:497:498:NRPE user for the NRPE service:/var/run/nrpe:/bin/bash
[root@rhel64-02 ~]# cat /etc/nagios/nrpe.cfg | grep memory
#command[nagios_memory]=/etc/nagios/nrpe.d/nagios_memory.sh -w 70 -c 90
command[nagios_memory]=/etc/nagios/nrpe.d/check_mem -u -C -w 70 -c 90
command[nagios_guest_memory]=/etc/nagios/nrpe.d/nagios_guest_memory.sh
[root@rhel64-02 ~]# chmod 777 /etc/nagios/nrpe.d/check_mem
[root@rhel64-02 ~]# su nrpe
bash-4.1$ /etc/nagios/nrpe.d/check_mem -u -C -w 70 -c 90
OK - 5.6% (5551468 kB) used.|TOTAL=99005228KB;;;; USED=5551468KB;69303659;89104705;; FREE=93453760KB;;;; CACHES=92491656KB;;;;
bash-4.1$ echo $?
0
bash-4.1$ getenforce
Enforcing

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:bash-4.1$ getenforce
Enforcing
This may be the cause of your problems.

This command will set SELinux to Permissive:

Code: Select all

sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config 
Run the command, reboot the server and test.
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,

Any risk for set SELINUX to permissive

Please advise.

Thanks,
Kelvin
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Check Script not able to run

Post by rkennedy »

Nope, Permissive will just have it set to log everything, but not follow any actions.
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 Box,

Any other way instead of disable selinux?

Please advise.
Since it is production server, it turn on selinux for long time.
So, any other way instead of disable selinux

Please advise.
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 »

No sorry, I do not know.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked