|
@@ -41,6 +41,7 @@ int validate_arguments (void);
|
|
|
void print_help(void);
|
|
void print_help(void);
|
|
|
void print_usage(void);
|
|
void print_usage(void);
|
|
|
|
|
|
|
|
|
|
+int verbose = false;
|
|
|
char *log_file = NULL;
|
|
char *log_file = NULL;
|
|
|
int expire_minutes = -1;
|
|
int expire_minutes = -1;
|
|
|
int use_average = TRUE;
|
|
int use_average = TRUE;
|
|
@@ -88,6 +89,7 @@ main (int argc, char **argv)
|
|
|
usage4 (_("Unable to open MRTG log file"));
|
|
usage4 (_("Unable to open MRTG log file"));
|
|
|
|
|
|
|
|
line = 0;
|
|
line = 0;
|
|
|
|
|
+
|
|
|
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
|
|
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
|
|
|
|
|
|
|
|
line++;
|
|
line++;
|
|
@@ -104,22 +106,32 @@ main (int argc, char **argv)
|
|
|
/* grab the timestamp */
|
|
/* grab the timestamp */
|
|
|
temp_buffer = strtok (input_buffer, " ");
|
|
temp_buffer = strtok (input_buffer, " ");
|
|
|
timestamp = strtoul (temp_buffer, NULL, 10);
|
|
timestamp = strtoul (temp_buffer, NULL, 10);
|
|
|
|
|
+ if (verbose)
|
|
|
|
|
+ printf("%s %lu\n", _("Found timestamp of:"), timestamp);
|
|
|
|
|
|
|
|
/* grab the average incoming transfer rate */
|
|
/* grab the average incoming transfer rate */
|
|
|
temp_buffer = strtok (NULL, " ");
|
|
temp_buffer = strtok (NULL, " ");
|
|
|
average_incoming_rate = strtoul (temp_buffer, NULL, 10);
|
|
average_incoming_rate = strtoul (temp_buffer, NULL, 10);
|
|
|
|
|
+ if (verbose)
|
|
|
|
|
+ printf("%s %lu\n", _("Found average incoming rate of:"), average_incoming_rate);
|
|
|
|
|
|
|
|
/* grab the average outgoing transfer rate */
|
|
/* grab the average outgoing transfer rate */
|
|
|
temp_buffer = strtok (NULL, " ");
|
|
temp_buffer = strtok (NULL, " ");
|
|
|
average_outgoing_rate = strtoul (temp_buffer, NULL, 10);
|
|
average_outgoing_rate = strtoul (temp_buffer, NULL, 10);
|
|
|
|
|
+ if (verbose)
|
|
|
|
|
+ printf("%s %lu\n", _("Found average outgoing rate of:"), average_outgoing_rate);
|
|
|
|
|
|
|
|
/* grab the maximum incoming transfer rate */
|
|
/* grab the maximum incoming transfer rate */
|
|
|
temp_buffer = strtok (NULL, " ");
|
|
temp_buffer = strtok (NULL, " ");
|
|
|
maximum_incoming_rate = strtoul (temp_buffer, NULL, 10);
|
|
maximum_incoming_rate = strtoul (temp_buffer, NULL, 10);
|
|
|
|
|
+ if (verbose)
|
|
|
|
|
+ printf("%s %lu\n", _("Found maximum incoming rate of:"), maximum_incoming_rate);
|
|
|
|
|
|
|
|
/* grab the maximum outgoing transfer rate */
|
|
/* grab the maximum outgoing transfer rate */
|
|
|
temp_buffer = strtok (NULL, " ");
|
|
temp_buffer = strtok (NULL, " ");
|
|
|
maximum_outgoing_rate = strtoul (temp_buffer, NULL, 10);
|
|
maximum_outgoing_rate = strtoul (temp_buffer, NULL, 10);
|
|
|
|
|
+ if (verbose)
|
|
|
|
|
+ printf("%s %lu\n", _("Found maximum outgoing rate of:"), maximum_outgoing_rate);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* close the log file */
|
|
/* close the log file */
|
|
@@ -138,10 +150,12 @@ main (int argc, char **argv)
|
|
|
|
|
|
|
|
/* else check the incoming/outgoing rates */
|
|
/* else check the incoming/outgoing rates */
|
|
|
if (use_average == TRUE) {
|
|
if (use_average == TRUE) {
|
|
|
|
|
+ if (verbose) printf("%s\n", _("Using average rates not maximum."));
|
|
|
incoming_rate = average_incoming_rate;
|
|
incoming_rate = average_incoming_rate;
|
|
|
outgoing_rate = average_outgoing_rate;
|
|
outgoing_rate = average_outgoing_rate;
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
|
|
+ if (verbose) printf("%s\n", _("Using default maximum rates."));
|
|
|
incoming_rate = maximum_incoming_rate;
|
|
incoming_rate = maximum_incoming_rate;
|
|
|
outgoing_rate = maximum_outgoing_rate;
|
|
outgoing_rate = maximum_outgoing_rate;
|
|
|
}
|
|
}
|
|
@@ -224,6 +238,7 @@ process_arguments (int argc, char **argv)
|
|
|
{"aggregation", required_argument, 0, 'a'},
|
|
{"aggregation", required_argument, 0, 'a'},
|
|
|
{"critical", required_argument, 0, 'c'},
|
|
{"critical", required_argument, 0, 'c'},
|
|
|
{"warning", required_argument, 0, 'w'},
|
|
{"warning", required_argument, 0, 'w'},
|
|
|
|
|
+ {"verbose", no_argument, 0, 'v'},
|
|
|
{"version", no_argument, 0, 'V'},
|
|
{"version", no_argument, 0, 'V'},
|
|
|
{"help", no_argument, 0, 'h'},
|
|
{"help", no_argument, 0, 'h'},
|
|
|
{0, 0, 0, 0}
|
|
{0, 0, 0, 0}
|
|
@@ -242,7 +257,7 @@ process_arguments (int argc, char **argv)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
|
while (1) {
|
|
|
- c = getopt_long (argc, argv, "hVF:e:a:c:w:", longopts, &option);
|
|
|
|
|
|
|
+ c = getopt_long (argc, argv, "hVvF:e:a:c:w:", longopts, &option);
|
|
|
|
|
|
|
|
if (c == -1 || c == EOF)
|
|
if (c == -1 || c == EOF)
|
|
|
break;
|
|
break;
|
|
@@ -268,6 +283,9 @@ process_arguments (int argc, char **argv)
|
|
|
sscanf (optarg, "%lu,%lu", &incoming_warning_threshold,
|
|
sscanf (optarg, "%lu,%lu", &incoming_warning_threshold,
|
|
|
&outgoing_warning_threshold);
|
|
&outgoing_warning_threshold);
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case 'v':
|
|
|
|
|
+ verbose = true;
|
|
|
|
|
+ break;
|
|
|
case 'V': /* version */
|
|
case 'V': /* version */
|
|
|
print_revision (progname, NP_VERSION);
|
|
print_revision (progname, NP_VERSION);
|
|
|
exit (STATE_OK);
|
|
exit (STATE_OK);
|
|
@@ -356,9 +374,11 @@ print_help (void)
|
|
|
printf (" %s\n", _("Warning threshold pair <incoming>,<outgoing>"));
|
|
printf (" %s\n", _("Warning threshold pair <incoming>,<outgoing>"));
|
|
|
printf (" %s\n", "-c, --critical");
|
|
printf (" %s\n", "-c, --critical");
|
|
|
printf (" %s\n", _("Critical threshold pair <incoming>,<outgoing>"));
|
|
printf (" %s\n", _("Critical threshold pair <incoming>,<outgoing>"));
|
|
|
|
|
+ printf (" %s\n", _("-v, --verbose"));
|
|
|
|
|
+ printf (" %s\n", _("Verbose output durring plugin runtime."));
|
|
|
|
|
|
|
|
printf ("\n");
|
|
printf ("\n");
|
|
|
- printf ("%s\n", _("Notes:"));
|
|
|
|
|
|
|
+ printf ("%s\n", _("Notes:"));
|
|
|
printf (" %s\n", _("- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from"));
|
|
printf (" %s\n", _("- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from"));
|
|
|
printf (" %s\n", " http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html");
|
|
printf (" %s\n", " http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html");
|
|
|
printf (" %s\n", _("- While MRTG can monitor things other than traffic rates, this"));
|
|
printf (" %s\n", _("- While MRTG can monitor things other than traffic rates, this"));
|