aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_fping.c
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <Sven.Nierlein@consol.de> 2013-09-13 15:36:10 +0200
committerGravatar Sven Nierlein <sven@consol.de> 2013-09-13 17:14:33 +0200
commit8b1c57429806e1e98b77d38567956a0181f3d781 (patch)
tree5d36474059f02f9bd14c07222b84d803b566953b /plugins/check_fping.c
parent8f5e92e1ed143bf2afd095a44ae6bb597ab7a5dc (diff)
downloadmonitoring-plugins-8b1c57429806e1e98b77d38567956a0181f3d781.tar.gz
fping: some fping versions set loss to 0% by mistake
fping v2.4b2 returns 10.99.0.1 : xmt/rcv/%loss = 0/0/0% for a failed host, so we assume the host is down if xmt is zero
Diffstat (limited to 'plugins/check_fping.c')
-rw-r--r--plugins/check_fping.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index c7cce97d..dad000e6 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -177,8 +177,10 @@ textscan (char *buf)
{
char *rtastr = NULL;
char *losstr = NULL;
+ char *xmtstr = NULL;
double loss;
double rta;
+ double xmt;
int status = STATE_UNKNOWN;
if (strstr (buf, "not found")) {
@@ -230,7 +232,12 @@ textscan (char *buf)
}
else if(strstr (buf, "xmt/rcv/%loss") ) {
/* no min/max/avg if host was unreachable in fping v2.2.b1 */
+ /* in v2.4b2: 10.99.0.1 : xmt/rcv/%loss = 0/0/0% */
losstr = strstr (buf, "=");
+ xmtstr = 1 + losstr;
+ xmt = strtod (xmtstr, NULL);
+ if(xmt == 0)
+ die (STATE_CRITICAL, _("FPING CRITICAL - %s is down\n"), server_name);
losstr = 1 + strstr (losstr, "/");
losstr = 1 + strstr (losstr, "/");
loss = strtod (losstr, NULL);