summaryrefslogtreecommitdiffstats
path: root/plugins/check_ping.c
diff options
context:
space:
mode:
authorSubhendu Ghosh <sghosh@users.sourceforge.net>2002-06-19 03:09:10 (GMT)
committerSubhendu Ghosh <sghosh@users.sourceforge.net>2002-06-19 03:09:10 (GMT)
commitd36016a7adf28424d7f4adaa50612c41f1937c3b (patch)
tree88114a06b6c22f5716e6495cd5533f050cca0011 /plugins/check_ping.c
parent0db01536cb9cd5717ccbaca005fd9a6236dd7a6b (diff)
downloadmonitoring-plugins-d36016a7adf28424d7f4adaa50612c41f1937c3b.tar.gz
fixes for using POSIX return codes
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@54 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ping.c')
-rw-r--r--plugins/check_ping.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 5eada4f..420f148 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -121,8 +121,12 @@ main (int argc, char **argv)
121 else if (pl >= wpl || rta >= wrta) 121 else if (pl >= wpl || rta >= wrta)
122 result = STATE_WARNING; 122 result = STATE_WARNING;
123 else if (pl < wpl && rta < wrta && pl >= 0 && rta >= 0) 123 else if (pl < wpl && rta < wrta && pl >= 0 && rta >= 0)
124 result = max (result, STATE_OK); 124 /* cannot use the max function because STATE_UNKNOWN is now 3 gt STATE_OK
125 125 result = max (result, STATE_OK); */
126 if( !( (result == STATE_WARNING) || (result == STATE_CRITICAL) ) ) {
127 result = STATE_OK;
128 }
129
126 if (display_html == TRUE) 130 if (display_html == TRUE)
127 printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, server_address); 131 printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, server_address);
128 if (pl == 100) 132 if (pl == 100)
@@ -381,7 +385,12 @@ run_ping (char *command_line)
381 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { 385 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
382 386
383 if (strstr (input_buffer, "(DUP!)")) { 387 if (strstr (input_buffer, "(DUP!)")) {
384 result = max (result, STATE_WARNING); 388 /* cannot use the max function since STATE_UNKNOWN is max
389 result = max (result, STATE_WARNING); */
390 if( !(result == STATE_CRITICAL) ){
391 result = STATE_WARNING;
392 }
393
385 warn_text = realloc (warn_text, strlen (WARN_DUPLICATES) + 1); 394 warn_text = realloc (warn_text, strlen (WARN_DUPLICATES) + 1);
386 if (warn_text == NULL) 395 if (warn_text == NULL)
387 terminate (STATE_UNKNOWN, "unable to realloc warn_text"); 396 terminate (STATE_UNKNOWN, "unable to realloc warn_text");
@@ -445,6 +454,9 @@ run_ping (char *command_line)
445 else if (strstr (input_buffer, "Destination Host Unreachable")) 454 else if (strstr (input_buffer, "Destination Host Unreachable"))
446 terminate (STATE_CRITICAL, "PING CRITICAL - Host Unreachable (%s)", 455 terminate (STATE_CRITICAL, "PING CRITICAL - Host Unreachable (%s)",
447 server_address); 456 server_address);
457 else if (strstr (input_buffer, "unknown host" ) )
458 terminate (STATE_CRITICAL, "PING CRITICAL - Host not found (%s)",
459 server_address);
448 460
449 warn_text = 461 warn_text =
450 realloc (warn_text, strlen (warn_text) + strlen (input_buffer) + 2); 462 realloc (warn_text, strlen (warn_text) + strlen (input_buffer) + 2);
@@ -456,9 +468,15 @@ run_ping (char *command_line)
456 sprintf (warn_text, "%s %s", warn_text, input_buffer); 468 sprintf (warn_text, "%s %s", warn_text, input_buffer);
457 469
458 if (strstr (input_buffer, "DUPLICATES FOUND")) 470 if (strstr (input_buffer, "DUPLICATES FOUND"))
459 result = max (result, STATE_WARNING); 471 /* cannot use the max function since STATE_UNKNOWN is max
472 result = max (result, STATE_WARNING); */
473 if( !(result == STATE_CRITICAL) ){
474 result = STATE_WARNING;
475 }
460 else 476 else
461 result = max (result, STATE_CRITICAL); 477 /* cannot use the max function since STATE_UNKNOWN is max
478 result = max (result, STATE_CRITICAL); */
479 result = STATE_CRITICAL ;
462 } 480 }
463 (void) fclose (child_stderr); 481 (void) fclose (child_stderr);
464 482
@@ -469,7 +487,7 @@ run_ping (char *command_line)
469 487
470 return result; 488 return result;
471} 489}
472 490
473 491
474void 492void
475print_usage (void) 493print_usage (void)