Page 5 of 6

Re: Check Script not able to run

Posted: Tue May 31, 2016 4:50 am
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

Re: Check Script not able to run

Posted: Tue May 31, 2016 12:41 pm
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.

Re: Check Script not able to run

Posted: Tue May 31, 2016 8:38 pm
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

Re: Check Script not able to run

Posted: Wed Jun 01, 2016 11:01 am
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

Re: Check Script not able to run

Posted: Wed Jun 01, 2016 10:48 pm
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

Re: Check Script not able to run

Posted: Thu Jun 02, 2016 2:11 am
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.

Re: Check Script not able to run

Posted: Thu Jun 02, 2016 2:40 am
by cyberportnoc
Dear Box,

Any risk for set SELINUX to permissive

Please advise.

Thanks,
Kelvin

Re: Check Script not able to run

Posted: Thu Jun 02, 2016 10:13 am
by rkennedy
Nope, Permissive will just have it set to log everything, but not follow any actions.

Re: Check Script not able to run

Posted: Thu Jun 02, 2016 8:20 pm
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.

Re: Check Script not able to run

Posted: Thu Jun 02, 2016 8:44 pm
by Box293
No sorry, I do not know.