summaryrefslogtreecommitdiffstats
path: root/plugins/check_mrtg.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-09-15 13:18:17 +0200
committerGitHub <noreply@github.com>2025-09-15 13:18:17 +0200
commit8ef825d85fb4d09c32ca44c545d6eb8d995ddea4 (patch)
tree5ab7b18797dfd5849dec7827c87ca3bb5fcb0993 /plugins/check_mrtg.c
parenta3cf9041af810770daf5d9b83f1906fa9bb0dd11 (diff)
parent204cf956f0b3db90d079321ee957b3860da7e33f (diff)
downloadmonitoring-plugins-8ef825d85fb4d09c32ca44c545d6eb8d995ddea4.tar.gz
Merge pull request #2149 from RincewindsHat/clang-format
Clang format
Diffstat (limited to 'plugins/check_mrtg.c')
-rw-r--r--plugins/check_mrtg.c53
1 files changed, 36 insertions, 17 deletions
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c
index 5bd276dc..4a17049a 100644
--- a/plugins/check_mrtg.c
+++ b/plugins/check_mrtg.c
@@ -129,7 +129,8 @@ int main(int argc, char **argv) {
129 time_t current_time; 129 time_t current_time;
130 time(&current_time); 130 time(&current_time);
131 if (config.expire_minutes > 0 && (current_time - timestamp) > (config.expire_minutes * 60)) { 131 if (config.expire_minutes > 0 && (current_time - timestamp) > (config.expire_minutes * 60)) {
132 printf(_("MRTG data has expired (%d minutes old)\n"), (int)((current_time - timestamp) / 60)); 132 printf(_("MRTG data has expired (%d minutes old)\n"),
133 (int)((current_time - timestamp) / 60));
133 return STATE_WARNING; 134 return STATE_WARNING;
134 } 135 }
135 136
@@ -148,20 +149,29 @@ int main(int argc, char **argv) {
148 result = STATE_WARNING; 149 result = STATE_WARNING;
149 } 150 }
150 151
151 printf("%s. %s = %lu %s|%s\n", (config.use_average) ? _("Avg") : _("Max"), config.label, rate, config.units, 152 printf("%s. %s = %lu %s|%s\n", (config.use_average) ? _("Avg") : _("Max"), config.label, rate,
152 perfdata(config.label, (long)rate, config.units, config.value_warning_threshold_set, (long)config.value_warning_threshold, 153 config.units,
153 config.value_critical_threshold_set, (long)config.value_critical_threshold, 0, 0, 0, 0)); 154 perfdata(config.label, (long)rate, config.units, config.value_warning_threshold_set,
155 (long)config.value_warning_threshold, config.value_critical_threshold_set,
156 (long)config.value_critical_threshold, 0, 0, 0, 0));
154 157
155 return result; 158 return result;
156} 159}
157 160
158/* process command-line arguments */ 161/* process command-line arguments */
159check_mrtg_config_wrapper process_arguments(int argc, char **argv) { 162check_mrtg_config_wrapper process_arguments(int argc, char **argv) {
160 static struct option longopts[] = { 163 static struct option longopts[] = {{"logfile", required_argument, 0, 'F'},
161 {"logfile", required_argument, 0, 'F'}, {"expires", required_argument, 0, 'e'}, {"aggregation", required_argument, 0, 'a'}, 164 {"expires", required_argument, 0, 'e'},
162 {"variable", required_argument, 0, 'v'}, {"critical", required_argument, 0, 'c'}, {"warning", required_argument, 0, 'w'}, 165 {"aggregation", required_argument, 0, 'a'},
163 {"label", required_argument, 0, 'l'}, {"units", required_argument, 0, 'u'}, {"variable", required_argument, 0, 'v'}, 166 {"variable", required_argument, 0, 'v'},
164 {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0}}; 167 {"critical", required_argument, 0, 'c'},
168 {"warning", required_argument, 0, 'w'},
169 {"label", required_argument, 0, 'l'},
170 {"units", required_argument, 0, 'u'},
171 {"variable", required_argument, 0, 'v'},
172 {"version", no_argument, 0, 'V'},
173 {"help", no_argument, 0, 'h'},
174 {0, 0, 0, 0}};
165 175
166 check_mrtg_config_wrapper result = { 176 check_mrtg_config_wrapper result = {
167 .errorcode = OK, 177 .errorcode = OK,
@@ -242,7 +252,9 @@ check_mrtg_config_wrapper process_arguments(int argc, char **argv) {
242 if (is_intpos(argv[option_char])) { 252 if (is_intpos(argv[option_char])) {
243 result.config.expire_minutes = atoi(argv[option_char++]); 253 result.config.expire_minutes = atoi(argv[option_char++]);
244 } else { 254 } else {
245 die(STATE_UNKNOWN, _("%s is not a valid expiration time\nUse '%s -h' for additional help\n"), argv[option_char], progname); 255 die(STATE_UNKNOWN,
256 _("%s is not a valid expiration time\nUse '%s -h' for additional help\n"),
257 argv[option_char], progname);
246 } 258 }
247 } 259 }
248 260
@@ -334,25 +346,32 @@ void print_help(void) {
334 printf(" %s\n", _("\"Bytes Per Second\", \"%% Utilization\")")); 346 printf(" %s\n", _("\"Bytes Per Second\", \"%% Utilization\")"));
335 347
336 printf("\n"); 348 printf("\n");
337 printf(" %s\n", _("If the value exceeds the <vwl> threshold, a WARNING status is returned. If")); 349 printf(" %s\n",
350 _("If the value exceeds the <vwl> threshold, a WARNING status is returned. If"));
338 printf(" %s\n", _("the value exceeds the <vcl> threshold, a CRITICAL status is returned. If")); 351 printf(" %s\n", _("the value exceeds the <vcl> threshold, a CRITICAL status is returned. If"));
339 printf(" %s\n", _("the data in the log file is older than <expire_minutes> old, a WARNING")); 352 printf(" %s\n", _("the data in the log file is older than <expire_minutes> old, a WARNING"));
340 printf(" %s\n", _("status is returned and a warning message is printed.")); 353 printf(" %s\n", _("status is returned and a warning message is printed."));
341 354
342 printf("\n"); 355 printf("\n");
343 printf(" %s\n", _("This plugin is useful for monitoring MRTG data that does not correspond to")); 356 printf(" %s\n",
344 printf(" %s\n", _("bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth).")); 357 _("This plugin is useful for monitoring MRTG data that does not correspond to"));
345 printf(" %s\n", _("It can be used to monitor any kind of data that MRTG is monitoring - errors,")); 358 printf(" %s\n",
346 printf(" %s\n", _("packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows")); 359 _("bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)."));
360 printf(" %s\n",
361 _("It can be used to monitor any kind of data that MRTG is monitoring - errors,"));
362 printf(" %s\n",
363 _("packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows"));
347 printf(" %s\n", _("me to track processor utilization, user connections, drive space, etc and")); 364 printf(" %s\n", _("me to track processor utilization, user connections, drive space, etc and"));
348 printf(" %s\n\n", _("this plugin works well for monitoring that kind of data as well.")); 365 printf(" %s\n\n", _("this plugin works well for monitoring that kind of data as well."));
349 366
350 printf("%s\n", _("Notes:")); 367 printf("%s\n", _("Notes:"));
351 printf(" %s\n", _("- This plugin only monitors one of the two variables stored in the MRTG log")); 368 printf(" %s\n",
369 _("- This plugin only monitors one of the two variables stored in the MRTG log"));
352 printf(" %s\n", _("file. If you want to monitor both values you will have to define two")); 370 printf(" %s\n", _("file. If you want to monitor both values you will have to define two"));
353 printf(" %s\n", _("commands with different values for the <variable> argument. Of course,")); 371 printf(" %s\n", _("commands with different values for the <variable> argument. Of course,"));
354 printf(" %s\n", _("you can always hack the code to make this plugin work for you...")); 372 printf(" %s\n", _("you can always hack the code to make this plugin work for you..."));
355 printf(" %s\n", _("- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded from")); 373 printf(" %s\n",
374 _("- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded from"));
356 printf(" %s\n", "http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html"); 375 printf(" %s\n", "http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html");
357 376
358 printf(UT_SUPPORT); 377 printf(UT_SUPPORT);