aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_fping.c
diff options
context:
space:
mode:
authorGravatar Subhendu Ghosh <sghosh@users.sourceforge.net> 2002-06-19 05:11:52 +0000
committerGravatar Subhendu Ghosh <sghosh@users.sourceforge.net> 2002-06-19 05:11:52 +0000
commitf4c6f7f09305c1c9916da6ac4f7aadcb31e319e0 (patch)
treebec7f042f90eac26b30122806846fc6a0e3f13b7 /plugins/check_fping.c
parentd36016a7adf28424d7f4adaa50612c41f1937c3b (diff)
downloadmonitoring-plugins-f4c6f7f09305c1c9916da6ac4f7aadcb31e319e0.tar.gz
more POSIX return value comparison related code fixes
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@55 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_fping.c')
-rw-r--r--plugins/check_fping.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index f6531a54..9a2dd557 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -93,21 +93,22 @@ main (int argc, char **argv)
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
if (verbose)
printf ("%s", input_buffer);
- status = max (status, textscan (input_buffer));
+ status = max_state (status, textscan (input_buffer));
}
/* If we get anything on STDERR, at least set warning */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
- status = max (status, STATE_WARNING);
+ status = max_state (status, STATE_WARNING);
if (verbose)
printf ("%s", input_buffer);
- status = max (status, textscan (input_buffer));
+ status = max_state (status, textscan (input_buffer));
}
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
- status = max (status, STATE_WARNING);
+ /* need to use max_state not max */
+ status = max_state (status, STATE_WARNING);
printf ("FPING %s - %s\n", state_text (status), server_name);
@@ -166,8 +167,27 @@ textscan (char *buf)
state_text (status), server_name, loss, rta);
}
+ else if(strstr (buf, "xmt/rcv/%loss") ) {
+ /* no min/max/avg if host was unreachable in fping v2.2.b1 */
+ losstr = strstr (buf, "=");
+ losstr = 1 + strstr (losstr, "/");
+ losstr = 1 + strstr (losstr, "/");
+ loss = strtod (losstr, NULL);
+ if (loss == 100)
+ status = STATE_CRITICAL;
+ else if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
+ status = STATE_CRITICAL;
+ else if (wpl != UNKNOWN_PACKET_LOSS && loss > wpl)
+ status = STATE_WARNING;
+ else
+ status = STATE_OK;
+
+ terminate (status, "FPING %s - %s (loss=%f%% )\n",
+ state_text (status), server_name, loss );
+
+ }
else {
- status = max (status, STATE_WARNING);
+ status = max_state (status, STATE_WARNING);
}
return status;