nagios-plugins/nagios-plugins — pull request #37 by madrisan (2014-05-07 20:16:58+00:00)
Title: Let 'np_net_connect ()' be more verbose when a network error is detected

This patch will add the IP and port, or socket name, to the error message and thus simplify the problem debugging: no need to check for this information in the Nagios configuration.
This function is only used by 'check_tcp.c'.

Without the patch:

$ ./plugins/check_tcp -H 127.0.0.1 -p 21
Connection refused
$ ./plugins/check_tcp -H /var/spool/nagios/cmd/nagios.cmd
Permission denied

With the patch:

$ ./plugins/check_tcp -H 127.0.0.1 -p 21
connect to address 127.0.0.1 and port 21: Connection refused
$ ./plugins/check_tcp -H /var/spool/nagios/cmd/nagios.cmd
connect to socket /var/spool/nagios/cmd/nagios.cmd: Permission denied