Hostname puppet is my nagios server.
On remote server, nrpe can be executed against itself. This was achieved by modifying /etc/xinetd/nrpe file by adding ip of agent2 in allowed_host attribute.[root@puppet ~]# nmap 192.168.1.4
Starting Nmap 5.51 ( http://nmap.org ) at 2016-06-22 17:32 AEST
Nmap scan report for agent2 (192.168.1.4)
Host is up (0.00032s latency).
Not shown: 998 filtered ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
MAC Address: 08:00:27:E5:CE:60 (Cadmus Computer Systems)
Nmap done: 1 IP address (1 host up) scanned in 5.12 seconds
[root@puppet ~]# ping -c 7 192.168.1.4
PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.
64 bytes from 192.168.1.4: icmp_seq=1 ttl=64 time=0.313 ms
64 bytes from 192.168.1.4: icmp_seq=2 ttl=64 time=0.489 ms
64 bytes from 192.168.1.4: icmp_seq=3 ttl=64 time=0.349 ms
64 bytes from 192.168.1.4: icmp_seq=4 ttl=64 time=0.506 ms
64 bytes from 192.168.1.4: icmp_seq=5 ttl=64 time=0.321 ms
64 bytes from 192.168.1.4: icmp_seq=6 ttl=64 time=0.204 ms
64 bytes from 192.168.1.4: icmp_seq=7 ttl=64 time=0.275 ms
--- 192.168.1.4 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6002ms
rtt min/avg/max/mdev = 0.204/0.351/0.506/0.101 ms
[root@puppet ~]# /usr/local/nagios/libexec/check_nrpe -H agent2
connect to address 192.168.1.4 port 5666: No route to host
connect to host agent2 port 5666: No route to host[root@puppet ~]#
[root@puppet ~]#
So far nagios server is concerned its not able to establish communication to remote server and I am guessing that port for xinetd is not open on remote server for incoming connection??