From f4c6f7f09305c1c9916da6ac4f7aadcb31e319e0 Mon Sep 17 00:00:00 2001 From: Subhendu Ghosh Date: Wed, 19 Jun 2002 05:11:52 +0000 Subject: 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 --- plugins/check_fping.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'plugins/check_fping.c') 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); @@ -165,9 +166,28 @@ textscan (char *buf) terminate (status, "FPING %s - %s (loss=%f%%, rta=%f ms)\n", 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; -- cgit v1.2.3-74-g34f1