diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-14 00:04:02 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-14 00:04:02 +0100 |
| commit | 5eaeadbb3a50e254fb465bf22c6022de9ecbab2d (patch) | |
| tree | cc40200d56bfc444da01ccb49fe1e275275b9a35 | |
| parent | fedff97c96ec7f7866fa15bd38b9a349cf260cad (diff) | |
| download | monitoring-plugins-5eaeadbb3a50e254fb465bf22c6022de9ecbab2d.tar.gz | |
check_load: Actually allow output format configuring
| -rw-r--r-- | plugins/check_load.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/check_load.c b/plugins/check_load.c index 5d3e6237..bf3c89d8 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c | |||
| @@ -256,12 +256,18 @@ int main(int argc, char **argv) { | |||
| 256 | 256 | ||
| 257 | /* process command-line arguments */ | 257 | /* process command-line arguments */ |
| 258 | static check_load_config_wrapper process_arguments(int argc, char **argv) { | 258 | static check_load_config_wrapper process_arguments(int argc, char **argv) { |
| 259 | |||
| 260 | enum { | ||
| 261 | output_format_index = CHAR_MAX + 1, | ||
| 262 | }; | ||
| 263 | |||
| 259 | static struct option longopts[] = {{"warning", required_argument, 0, 'w'}, | 264 | static struct option longopts[] = {{"warning", required_argument, 0, 'w'}, |
| 260 | {"critical", required_argument, 0, 'c'}, | 265 | {"critical", required_argument, 0, 'c'}, |
| 261 | {"percpu", no_argument, 0, 'r'}, | 266 | {"percpu", no_argument, 0, 'r'}, |
| 262 | {"version", no_argument, 0, 'V'}, | 267 | {"version", no_argument, 0, 'V'}, |
| 263 | {"help", no_argument, 0, 'h'}, | 268 | {"help", no_argument, 0, 'h'}, |
| 264 | {"procs-to-show", required_argument, 0, 'n'}, | 269 | {"procs-to-show", required_argument, 0, 'n'}, |
| 270 | {"output-format", required_argument, 0, output_format_index}, | ||
| 265 | {0, 0, 0, 0}}; | 271 | {0, 0, 0, 0}}; |
| 266 | 272 | ||
| 267 | check_load_config_wrapper result = { | 273 | check_load_config_wrapper result = { |
| @@ -283,6 +289,18 @@ static check_load_config_wrapper process_arguments(int argc, char **argv) { | |||
| 283 | } | 289 | } |
| 284 | 290 | ||
| 285 | switch (option_index) { | 291 | switch (option_index) { |
| 292 | case output_format_index: { | ||
| 293 | parsed_output_format parser = mp_parse_output_format(optarg); | ||
| 294 | if (!parser.parsing_success) { | ||
| 295 | // TODO List all available formats here, maybe add anothoer usage function | ||
| 296 | printf("Invalid output format: %s\n", optarg); | ||
| 297 | exit(STATE_UNKNOWN); | ||
| 298 | } | ||
| 299 | |||
| 300 | result.config.output_format_set = true; | ||
| 301 | result.config.output_format = parser.output_format; | ||
| 302 | break; | ||
| 303 | } | ||
| 286 | case 'w': /* warning time threshold */ { | 304 | case 'w': /* warning time threshold */ { |
| 287 | parsed_thresholds warning_range = get_threshold(optarg); | 305 | parsed_thresholds warning_range = get_threshold(optarg); |
| 288 | result.config.th_load[0].warning = warning_range.load[0]; | 306 | result.config.th_load[0].warning = warning_range.load[0]; |
| @@ -381,6 +399,7 @@ void print_help(void) { | |||
| 381 | printf(" %s\n", _("Number of processes to show when printing the top consuming processes.")); | 399 | printf(" %s\n", _("Number of processes to show when printing the top consuming processes.")); |
| 382 | printf(" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0")); | 400 | printf(" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0")); |
| 383 | 401 | ||
| 402 | printf(UT_OUTPUT_FORMAT); | ||
| 384 | printf(UT_SUPPORT); | 403 | printf(UT_SUPPORT); |
| 385 | } | 404 | } |
| 386 | 405 | ||
