X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcheck_mrtgtraf.c;h=21791ae9f25f7b89db2012872c87368fad8b5669;hb=831d03cd768cb4d1f96d3cabd6262a0a55f904e7;hp=d33ebd9ce17a100ac045d9ecc738fd6f0067bb7b;hpb=2a68978c564e53cddc90882ee7776a43839dfcff;p=nagiosplug.git diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c index d33ebd9..21791ae 100644 --- a/plugins/check_mrtgtraf.c +++ b/plugins/check_mrtgtraf.c @@ -52,7 +52,7 @@ #include "common.h" #include "utils.h" -#define PROGNAME "check_mrtgtraf" +const char *progname = "check_mrtgtraf"; int process_arguments (int, char **); int validate_arguments (void); @@ -197,27 +197,26 @@ main (int argc, char **argv) if (incoming_rate > incoming_critical_threshold || outgoing_rate > outgoing_critical_threshold) { result = STATE_CRITICAL; - asprintf (&error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s", - (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate, - incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max", + asprintf (&error_message, "Traffic CRITICAL %s. In = %0.1f %s, %s. Out = %0.1f %s", + (use_average == TRUE) ? "Avg" : "Max", adjusted_incoming_rate, + incoming_speed_rating, (use_average == TRUE) ? "Avg" : "Max", adjusted_outgoing_rate, outgoing_speed_rating); } else if (incoming_rate > incoming_warning_threshold || outgoing_rate > outgoing_warning_threshold) { result = STATE_WARNING; - asprintf (&error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s", - (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate, - incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max", + asprintf (&error_message, "Traffic WARNING %s. In = %0.1f %s, %s. Out = %0.1f %s", + (use_average == TRUE) ? "Avg" : "Max", adjusted_incoming_rate, + incoming_speed_rating, (use_average == TRUE) ? "Avg" : "Max", adjusted_outgoing_rate, outgoing_speed_rating); } - - if (result == STATE_OK) - printf ("Traffic ok - %s. In = %0.1f %s, %s. Out = %0.1f %s\n", - (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate, - incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max", + else if (result == STATE_OK) + printf ("Traffic OK - %s. In = %0.1f %s, %s. Out = %0.1f %s\n", + (use_average == TRUE) ? "Avg" : "Max", adjusted_incoming_rate, + incoming_speed_rating, (use_average == TRUE) ? "Avg" : "Max", adjusted_outgoing_rate, outgoing_speed_rating); else - printf ("%s\n", error_message); + printf ("UNKNOWN %s\n", error_message); return result; } @@ -232,7 +231,6 @@ process_arguments (int argc, char **argv) { int c; -#ifdef HAVE_GETOPT_H int option_index = 0; static struct option longopts[] = { {"logfile", required_argument, 0, 'F'}, @@ -246,7 +244,6 @@ process_arguments (int argc, char **argv) {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; -#endif if (argc < 2) return ERROR; @@ -261,11 +258,7 @@ process_arguments (int argc, char **argv) } while (1) { -#ifdef HAVE_GETOPT_H - c = getopt_long (argc, argv, "hVF:e:a:c:w:", longopts, &option_index); -#else - c = getopt (argc, argv, "hVF:e:a:c:w:"); -#endif + c = getopt_long (argc, argv, "hVF:e:a:c:w:", longopts, &option_index); if (c == -1 || c == EOF) break; @@ -292,7 +285,7 @@ process_arguments (int argc, char **argv) &outgoing_warning_threshold); break; case 'V': /* version */ - print_revision (PROGNAME, "$Revision$"); + print_revision (progname, "$Revision$"); exit (STATE_OK); case 'h': /* help */ print_help (); @@ -356,7 +349,7 @@ validate_arguments (void) void print_help (void) { - print_revision (PROGNAME, "$Revision$"); + print_revision (progname, "$Revision$"); printf ("Copyright (c) 2000 Tom Shields/Karl DeBisschop\n\n" "This plugin tests the UPS service on the specified host.\n\n"); @@ -390,5 +383,5 @@ print_usage (void) ("Usage: %s -F -a -v -w -c \n" " [-e expire_minutes] [-t timeout] [-v]\n" " %s --help\n" - " %s --version\n", PROGNAME, PROGNAME, PROGNAME); + " %s --version\n", progname, progname, progname); }