X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcheck_ping.c;h=0c0f2e44f2872e0d4601e683c9b733dd596ecc3c;hb=773af31b84dda4732b1271ec87774479c384cf35;hp=56c9557bfdc0f3bfea4b358bb4ea808f24c29f08;hpb=1fb42320aa0519536b58994e8fdcf16c66dba246;p=nagiosplug.git diff --git a/plugins/check_ping.c b/plugins/check_ping.c index 56c9557..0c0f2e4 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c @@ -10,7 +10,7 @@ * *****************************************************************************/ -#define PROGNAME "check_ping" +const char *progname = "check_ping"; #define REVISION "$Revision$" #define COPYRIGHT "1999-2001" #define AUTHOR "Ethan Galstad/Karl DeBisschop" @@ -56,7 +56,6 @@ the contrib area of the downloads section at http://www.nagios.org\n\n" #define WARN_DUPLICATES "DUPLICATES FOUND! " int process_arguments (int, char **); -int call_getopt (int, char **); int get_threshold (char *, float *, int *); int validate_arguments (void); int run_ping (char *); @@ -89,11 +88,9 @@ main (int argc, char **argv) /* does the host address of number of packets argument come first? */ #ifdef PING_PACKETS_FIRST - command_line = - ssprintf (command_line, PING_COMMAND, max_packets, server_address); + asprintf (&command_line, PING_COMMAND, max_packets, server_address); #else - command_line = - ssprintf (command_line, PING_COMMAND, server_address, max_packets); + asprintf (&command_line, PING_COMMAND, server_address, max_packets); #endif /* Set signal handling and alarm */ @@ -151,7 +148,7 @@ main (int argc, char **argv) int process_arguments (int argc, char **argv) { - int c, i = 1; + int c = 1; #ifdef HAVE_GETOPT_H int option_index = 0; @@ -187,12 +184,12 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* usage */ - usage2 ("Unknown argument", optarg); + usage3 ("Unknown argument", optopt); case 'h': /* help */ print_help (); exit (STATE_OK); case 'V': /* version */ - print_revision (PROGNAME, REVISION); + print_revision (progname, REVISION); exit (STATE_OK); case 't': /* timeout period */ timeout_interval = atoi (optarg); @@ -455,15 +452,12 @@ run_ping (char *command_line) else sprintf (warn_text, "%s %s", warn_text, input_buffer); - if (strstr (input_buffer, "DUPLICATES FOUND")) - /* cannot use the max function since STATE_UNKNOWN is max - result = max (result, STATE_WARNING); */ + if (strstr (input_buffer, "DUPLICATES FOUND")) { if( !(result == STATE_CRITICAL) ){ result = STATE_WARNING; } + } else - /* cannot use the max function since STATE_UNKNOWN is max - result = max (result, STATE_CRITICAL); */ result = STATE_CRITICAL ; } (void) fclose (child_stderr); @@ -488,13 +482,13 @@ print_usage (void) " %s -h for detailed help\n" " %s -V for version information\n", #endif - PROGNAME, OPTIONS, PROGNAME, PROGNAME); + progname, OPTIONS, progname, progname); } void print_help (void) { - print_revision (PROGNAME, REVISION); + print_revision (progname, REVISION); printf ("Copyright (c) %s %s <%s>\n\n%s\n", COPYRIGHT, AUTHOR, EMAIL, SUMMARY);