[PATCH] check_fping and n etwork unreachable
Roel van Meer <[email protected]>
| Newsgroups | gmane.network.nagios.plugins.devel |
|---|---|
| Message-ID | <cone.1363946306.587393.3746.1000@bollix> |
Hi list, I ran into a problem where check_fping falsely reports nodes to be OK. This happened when no packets could be transmitted due to a prohibiting route. This patch fixes that by checking if the number of transmitted packets is greater than zero. Best regards, Roel ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar _______________________________________________________ Nagios Plugin Development Mailing List Nagiosplug-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Unsubscribe at https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel ::: Please include plugins version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null
nagios-plugins-1.4.15-check_fping.patch
(text/plain, 2 KB)
If a host cannot be contacted due to a prohibiting route, check_fping falsely reports OK. This patch fixes that by only reporting OK if packet loss is 0 if the number of transmitted packets is > 0. If the number of transmitted packets is 0 report CRITICAL and set loss to 100%. root@polar:~# ip route show | grep 10 prohibit 10.0.0.0/8 root@polar:~# ip route get 10.17.5.1 RTNETLINK answers: Network is unreachable root@polar:~# ping 10.17.5.1 connect: Network is unreachable root@polar:~# fping 10.17.5.1 10.17.5.1 error while sending ping: Network is unreachable 10.17.5.1 is unreachable root@polar:~# fping -b 56 -c 3 10.17.5.1 10.17.5.1 : xmt/rcv/%loss = 0/0/0% root@polar:~# check_fping 10.17.5.1 FPING OK - 10.17.5.1 (loss=0% )|loss=0%;;;0;100 root@polar:~# fping -v fping: Version 2.4b2_to $Date: 2013/03/22 09:57:13 $ fping: comments to noc-2q8n3HPGdXFWk0Htik3J/[email protected] diff -ruN nagios-plugins-1.4.15.a/plugins/check_fping.c nagios-plugins-1.4.15.b/plugins/check_fping.c --- nagios-plugins-1.4.15.a/plugins/check_fping.c 2010-07-27 22:47:16.000000000 +0200 +++ nagios-plugins-1.4.15.b/plugins/check_fping.c 2013-03-22 10:34:03.469606400 +0100 @@ -146,7 +146,9 @@ { char *rtastr = NULL; char *losstr = NULL; + char *xmtstr = NULL; double loss; + double xmt; double rta; int status = STATE_UNKNOWN; @@ -198,14 +200,20 @@ losstr = strstr (buf, "="); losstr = 1 + strstr (losstr, "/"); losstr = 1 + strstr (losstr, "/"); + xmtstr = strstr (buf, "="); + xmtstr = 1 + strstr (xmtstr, " "); loss = strtod (losstr, NULL); + xmt = strtod (xmtstr, NULL); if (atoi(losstr) == 100) status = STATE_CRITICAL; else if (cpl_p == TRUE && loss > cpl) status = STATE_CRITICAL; else if (wpl_p == TRUE && loss > wpl) status = STATE_WARNING; - else + else if (atoi(losstr) == 0 && atoi(xmtstr) == 0) { + status = STATE_CRITICAL; + loss = 100; + } else status = STATE_OK; /* loss=%.0f%%;%d;%d;0;100 */ die (status, _("FPING %s - %s (loss=%.0f%% )|%s\n"),