[Nagiosplug-checkins] CVS: nagiosplug/plugins check_mrtg.c,1.10,1.11
Karl DeBisschop
kdebisschop at users.sourceforge.net
Thu Oct 30 20:20:07 CET 2003
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv31331
Modified Files:
check_mrtg.c
Log Message:
add perf data
fix bug where stale data message would get overwritten
Index: check_mrtg.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_mrtg.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** check_mrtg.c 22 Aug 2003 06:22:38 -0000 1.10
--- check_mrtg.c 31 Oct 2003 04:19:03 -0000 1.11
***************
*** 36,41 ****
unsigned long value_warning_threshold = 0L;
unsigned long value_critical_threshold = 0L;
! char *value_label;
! char *units_label;
int
--- 36,41 ----
unsigned long value_warning_threshold = 0L;
unsigned long value_critical_threshold = 0L;
! char *label;
! char *units;
int
***************
*** 48,56 ****
char *temp_buffer;
time_t current_time;
! char error_message[MAX_INPUT_BUFFER];
time_t timestamp = 0L;
unsigned long average_value_rate = 0L;
unsigned long maximum_value_rate = 0L;
! unsigned long value_rate = 0L;
setlocale (LC_ALL, "");
--- 48,56 ----
char *temp_buffer;
time_t current_time;
! char* message;
time_t timestamp = 0L;
unsigned long average_value_rate = 0L;
unsigned long maximum_value_rate = 0L;
! unsigned long rate = 0L;
setlocale (LC_ALL, "");
***************
*** 112,116 ****
if (line <= 2) {
result = STATE_UNKNOWN;
! sprintf (error_message, _("Unable to process MRTG log file\n"));
}
--- 112,116 ----
if (line <= 2) {
result = STATE_UNKNOWN;
! asprintf (&message, _("Unable to process MRTG log file\n"));
}
***************
*** 121,125 ****
&& (current_time - timestamp) > (expire_minutes * 60)) {
result = STATE_WARNING;
! sprintf (error_message, _("MRTG data has expired (%d minutes old)\n"),
(int) ((current_time - timestamp) / 60));
}
--- 121,125 ----
&& (current_time - timestamp) > (expire_minutes * 60)) {
result = STATE_WARNING;
! asprintf (&message, _("MRTG data has expired (%d minutes old)\n"),
(int) ((current_time - timestamp) / 60));
}
***************
*** 128,147 ****
/* else check the incoming/outgoing rates */
if (result == STATE_OK) {
-
if (use_average == TRUE)
! value_rate = average_value_rate;
else
! value_rate = maximum_value_rate;
! if (value_rate > value_critical_threshold)
result = STATE_CRITICAL;
! else if (value_rate > value_warning_threshold)
result = STATE_WARNING;
}
! sprintf (error_message, "%s. %s = %lu %s",
! (use_average == TRUE) ? _("Ave") : _("Max"), value_label, value_rate,
! units_label);
! printf ("%s\n", error_message);
return result;
--- 128,151 ----
/* else check the incoming/outgoing rates */
if (result == STATE_OK) {
if (use_average == TRUE)
! rate = average_value_rate;
else
! rate = maximum_value_rate;
! if (rate > value_critical_threshold)
result = STATE_CRITICAL;
! else if (rate > value_warning_threshold)
result = STATE_WARNING;
+
+ asprintf (&message, "%s. %s = %lu %s|%s",
+ (use_average == TRUE) ? _("Avg") : _("Max"),
+ label, rate, units,
+ perfdata(label, rate, units,
+ value_warning_threshold, value_warning_threshold,
+ value_critical_threshold, value_critical_threshold,
+ 0, 0, 0, 0));
}
! printf ("%s\n", message);
return result;
***************
*** 214,221 ****
break;
case 'l': /* label */
! value_label = optarg;
break;
case 'u': /* timeout */
! units_label = optarg;
break;
case 'V': /* version */
--- 218,225 ----
break;
case 'l': /* label */
! label = optarg;
break;
case 'u': /* timeout */
! units = optarg;
break;
case 'V': /* version */
***************
*** 269,278 ****
}
! if (argc > c && strlen (value_label) == 0) {
! value_label = argv[c++];
}
! if (argc > c && strlen (units_label) == 0) {
! units_label = argv[c++];
}
--- 273,282 ----
}
! if (argc > c && strlen (label) == 0) {
! label = argv[c++];
}
! if (argc > c && strlen (units) == 0) {
! units = argv[c++];
}
***************
*** 286,294 ****
usage (_("You must supply the variable number\n"));
! if (value_label == NULL)
! value_label = strdup ("");
! if (units_label == NULL)
! units_label = strdup ("");
return OK;
--- 290,298 ----
usage (_("You must supply the variable number\n"));
! if (label == NULL)
! label = strdup ("value");
! if (units == NULL)
! units = strdup ("");
return OK;
More information about the Commits
mailing list