I created a Nagios check which checks our pacemaker using the crm_mon
command.
The check is configured in the same way on both Nagios server and client's nrpe.cfg
:
The command definition in nrpe.cfg
looks like that:
[root@Nagios_clt plugins]# grep pacemaker /etc/nagios/nrpe.cfg
command[check_pacemaker]=/usr/bin/sudo /usr/sbin/crm_mon -s
I did two tests: In the first one, I'm just using the line you see above and then from the Nagios server I get:
[root@Nagios_srv ]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.57.157 -c check_pacemaker
NRPE: Unable to read output
[root@Nagios_srv ]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.57.157
NRPE v2.14
In the second one, I wrote a different command definition:
[root@Nagios_srv ]# grep pacemaker /etc/nagios/nrpe.cfg
command[check_pacemaker]=/usr/lib64/nagios/plugins/check_pacemaker.sh
While /usr/lib64/nagios/plugins/check_pacemaker.sh
looks like that:
[root@Nagios_svr ]# cat /usr/lib64/nagios/plugins/check_pacemaker.sh
#!/bin/bash
/usr/bin/sudo /usr/sbin/crm_mon -s
I've chmod +x the check_pacemaker.sh
file.
None of these worked.
If I run the check_pacemaker.sh
file locally on the Nagios client, I get the correct result:
[root@Nagios_clt ]# /usr/lib64/nagios/plugins/check_pacemaker.sh
Ok: 2 nodes online, 10 resources configured
If I run the command locally using check_nrpe
I get this result:
[root@Nagios_clt plugins]# /usr/lib64/nagios/plugins/check_nrpe -H localhost
NRPE v2.14
[root@Nagios_clt plugins]# /usr/lib64/nagios/plugins/check_nrpe -H localhost -c check_pacemaker
NRPE: Unable to read output
Some other stuff I've configured:
[root@Nagios_clt plugins]# grep Defaults /etc/sudoers
#Defaults requiretty
[root@Nagios_clt plugins]# grep nagios /etc/sudoers
nagios ALL=NOPASSWD:/usr/lib64/nagios/plugins/*
The check_command looks like that:
define command{
command_name check_pacemaker
command_line /usr/lib64/nagios/plugins/check_pacemaker.sh
}
[root@Nagios_clt plugins]# service iptables status
iptables: Firewall is not running.
Other checks on this server are working using nrpe:
And I don't understand why, does anyone have an idea?