summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM. Sean Finney <seanius@users.sourceforge.net>2005-10-13 09:58:12 (GMT)
committerM. Sean Finney <seanius@users.sourceforge.net>2005-10-13 09:58:12 (GMT)
commit866709d4b53c05ed065b9cae4aa0dc68d57bc5f4 (patch)
tree658eef300d25cd19409d4c023a08bfa9117aeebd
parentf1cef328a6f38e4da3c33a7154a0e0b89f2daa5a (diff)
downloadmonitoring-plugins-866709d4b53c05ed065b9cae4aa0dc68d57bc5f4.tar.gz
was this plugin even working? i don't think the if/else logic
was doing what was intended. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1245 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_mrtg.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c
index 067429c..6b08195 100644
--- a/plugins/check_mrtg.c
+++ b/plugins/check_mrtg.c
@@ -49,7 +49,6 @@ main (int argc, char **argv)
49 char input_buffer[MAX_INPUT_BUFFER]; 49 char input_buffer[MAX_INPUT_BUFFER];
50 char *temp_buffer; 50 char *temp_buffer;
51 time_t current_time; 51 time_t current_time;
52 char* message;
53 time_t timestamp = 0L; 52 time_t timestamp = 0L;
54 unsigned long average_value_rate = 0L; 53 unsigned long average_value_rate = 0L;
55 unsigned long maximum_value_rate = 0L; 54 unsigned long maximum_value_rate = 0L;
@@ -112,43 +111,37 @@ main (int argc, char **argv)
112 111
113 /* if we couldn't read enough data, return an unknown error */ 112 /* if we couldn't read enough data, return an unknown error */
114 if (line <= 2) { 113 if (line <= 2) {
115 result = STATE_UNKNOWN; 114 printf (_("Unable to process MRTG log file\n"));
116 asprintf (&message, _("Unable to process MRTG log file\n")); 115 return STATE_UNKNOWN;
117 } 116 }
118 117
119 /* make sure the MRTG data isn't too old */ 118 /* make sure the MRTG data isn't too old */
120 if (result == STATE_OK) { 119 time (&current_time);
121 time (&current_time); 120 if (expire_minutes > 0
122 if (expire_minutes > 0 121 && (current_time - timestamp) > (expire_minutes * 60)) {
123 && (current_time - timestamp) > (expire_minutes * 60)) { 122 printf (_("MRTG data has expired (%d minutes old)\n"),
124 result = STATE_WARNING; 123 (int) ((current_time - timestamp) / 60));
125 asprintf (&message, _("MRTG data has expired (%d minutes old)\n"), 124 return STATE_WARNING;
126 (int) ((current_time - timestamp) / 60));
127 }
128 } 125 }
129 126
130 /* else check the incoming/outgoing rates */ 127 /* else check the incoming/outgoing rates */
131 if (result == STATE_OK) { 128 if (use_average == TRUE)
132 if (use_average == TRUE) 129 rate = average_value_rate;
133 rate = average_value_rate; 130 else
134 else 131 rate = maximum_value_rate;
135 rate = maximum_value_rate; 132
136 133 if (rate > value_critical_threshold)
137 if (rate > value_critical_threshold) 134 result = STATE_CRITICAL;
138 result = STATE_CRITICAL; 135 else if (rate > value_warning_threshold)
139 else if (rate > value_warning_threshold) 136 result = STATE_WARNING;
140 result = STATE_WARNING; 137
141 138 printf("%s. %s = %lu %s|%s\n",
142 asprintf (&message, "%s. %s = %lu %s|%s", 139 (use_average == TRUE) ? _("Avg") : _("Max"),
143 (use_average == TRUE) ? _("Avg") : _("Max"), 140 label, rate, units,
144 label, rate, units, 141 perfdata(label, (long) rate, units,
145 perfdata(label, (long) rate, units, 142 (int) value_warning_threshold, (long) value_warning_threshold,
146 (int) value_warning_threshold, (long) value_warning_threshold, 143 (int) value_critical_threshold, (long) value_critical_threshold,
147 (int) value_critical_threshold, (long) value_critical_threshold, 144 0, 0, 0, 0));
148 0, 0, 0, 0));
149 }
150
151 printf ("%s\n", message);
152 145
153 return result; 146 return result;
154} 147}