[Nagiosplug-devel] Patch for check_fping (1.4alpha1/2.4x fping): return CRITICAL when %loss = 0 and xmit == 0

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Mon Feb 16 03:27:08 CET 2004


Dear Ladies and Gentlemen,

The check_fping plugin from the 1.4.0alpha1 plugin distro returns OK
when
  %loss == 0
regardless of how many packets have been transmitted.

I think this behaviour is bad because fping does not always transmit a
packet to a down host (it returns a failure status/return code in this
case that check_fping doesn't use) and the plugin will report OK in the
middle of a check-host-alive check (leading to repeated futile service
check rescheduling).

Here is a patch to report CRITICAL when
  %loss == 0 && xmit == 0

It is running in the local production Nag installation.

Thanks for great plugins; check_fping is a ripper. The CPU reduction and
the acceleration in down host detection is incredible.



Yours sincerely.


-- 
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.

tsitc> ping eros
PING eros.aipo.gov.au (10.0.100.72): 56 data bytes
ping: sendto: Host is down
ping: sendto: Host is down
^C
--- eros.aipo.gov.au ping statistics ---
8 packets transmitted, 0 packets received, 100% packet loss
tsitc> ./check_fping eros -v
/usr/local/sbin/fping -b 56 -c 1 eros

eros : xmt/rcv/%loss = 0/0/0%
FPING CRITICAL - eros (loss=0% )|loss=0%;;;0;100
tsitc> ./check_fping eros -v
/usr/local/sbin/fping -b 56 -c 1 eros

eros : xmt/rcv/%loss = 0/0/0%
FPING CRITICAL - eros (loss=0% )|loss=0%;;;0;100
tsitc> ./check_fping eros -v
/usr/local/sbin/fping -b 56 -c 1 eros

eros : xmt/rcv/%loss = 0/0/0%
FPING CRITICAL - eros (loss=0% )|loss=0%;;;0;100
tsitc> ./check_fping eros -v
/usr/local/sbin/fping -b 56 -c 1 eros

eros : xmt/rcv/%loss = 1/0/100%
FPING CRITICAL - eros (loss=100% )|loss=100%;;;0;100
tsitc> 


tsitc> cat check_fping.PAT 
--- check_fping.c.orig  Sun Feb 15 19:25:07 2004
+++ check_fping.c       Sun Feb 15 22:06:04 2004
@@ -122,10 +122,13 @@
 {
        char *rtastr = NULL;
        char *losstr = NULL;
+       char *xmtstr = NULL;
        double loss;
        double rta;
+       int xmt;
        int status = STATE_UNKNOWN;
 
        if (strstr (buf, "not found")) {
                die (STATE_CRITICAL, _("FPING unknown - %s not
found\n"), server_name);
 
@@ -172,10 +175,17 @@
        else if(strstr (buf, "xmt/rcv/%loss") ) {
                /* no min/max/avg if host was unreachable in fping
v2.2.b1 */
                losstr = strstr (buf, "=");
+               xmtstr = 2 + losstr;
+               xmt = atoi(xmtstr);
                losstr = 1 + strstr (losstr, "/");
                losstr = 1 + strstr (losstr, "/");
                loss = strtod (losstr, NULL);
                if (atoi(losstr) == 100)
+                       status = STATE_CRITICAL;
+               /*
+                * if no packets sent, %loss == 0 but this is _not_ OK
+                */
+               else if (atoi(losstr) == 0 && xmt == 0)
                        status = STATE_CRITICAL;
                else if (cpl_p == TRUE && loss > cpl)
                        status = STATE_CRITICAL;
tsitc> 


tsitc> ./check_fping -V
check_fping (nagios-plugins 1.4.0alpha1) 1.11
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may
redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
tsitc> fping -v
fping: Version 2.4b2_to $Date: 2002/01/16 00:33:42 $
fping: comments to david at remote.net
tsitc> uname -a
FreeBSD tsitc.aipo.gov.au 4.9-RELEASE-p1 FreeBSD 4.9-RELEASE-p1 #13: Fri
Dec 26 20:25:10 EST 2003
root at tsitc.aipo.gov.au:/usr/obj/usr/src/sys/TSITC  i386
tsitc> gcc -v
Using builtin specs.
gcc version 2.95.4 20020320 [FreeBSD]
tsitc> 


-- 
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.




More information about the Devel mailing list