diff options
| -rw-r--r-- | lib/output.c | 2 | ||||
| -rw-r--r-- | plugins/check_load.c | 16 |
2 files changed, 7 insertions, 11 deletions
diff --git a/lib/output.c b/lib/output.c index 54d505d9..3c04d63d 100644 --- a/lib/output.c +++ b/lib/output.c | |||
| @@ -420,7 +420,7 @@ static inline char *fmt_subcheck_output(mp_output_format output_format, mp_subch | |||
| 420 | // add the rest (if any) | 420 | // add the rest (if any) |
| 421 | if (have_residual_chars) { | 421 | if (have_residual_chars) { |
| 422 | char *tmp = check.output; | 422 | char *tmp = check.output; |
| 423 | xasprintf(&check.output, "%s\n%s%s", intermediate_string, | 423 | xasprintf(&check.output, "%s%s%s", intermediate_string, |
| 424 | generate_indentation_string(indentation + 1), tmp); | 424 | generate_indentation_string(indentation + 1), tmp); |
| 425 | } else { | 425 | } else { |
| 426 | check.output = intermediate_string; | 426 | check.output = intermediate_string; |
diff --git a/plugins/check_load.c b/plugins/check_load.c index 60fa646f..7995408e 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c | |||
| @@ -65,7 +65,7 @@ typedef struct { | |||
| 65 | int errorcode; | 65 | int errorcode; |
| 66 | char **top_processes; | 66 | char **top_processes; |
| 67 | } top_processes_result; | 67 | } top_processes_result; |
| 68 | static top_processes_result print_top_consuming_processes(unsigned long n_procs_to_show); | 68 | static top_processes_result get_top_consuming_processes(unsigned long n_procs_to_show); |
| 69 | 69 | ||
| 70 | typedef struct { | 70 | typedef struct { |
| 71 | mp_range load[3]; | 71 | mp_range load[3]; |
| @@ -158,7 +158,7 @@ int main(int argc, char **argv) { | |||
| 158 | 158 | ||
| 159 | mp_subcheck scaled_load_sc = mp_subcheck_init(); | 159 | mp_subcheck scaled_load_sc = mp_subcheck_init(); |
| 160 | scaled_load_sc = mp_set_subcheck_default_state(scaled_load_sc, STATE_OK); | 160 | scaled_load_sc = mp_set_subcheck_default_state(scaled_load_sc, STATE_OK); |
| 161 | scaled_load_sc.output = "Scaled Load (divided by number of CPUs"; | 161 | scaled_load_sc.output = "Scaled Load (divided by number of CPUs)"; |
| 162 | 162 | ||
| 163 | mp_perfdata pd_scaled_load1 = perfdata_init(); | 163 | mp_perfdata pd_scaled_load1 = perfdata_init(); |
| 164 | pd_scaled_load1.label = "scaled_load1"; | 164 | pd_scaled_load1.label = "scaled_load1"; |
| @@ -248,12 +248,13 @@ int main(int argc, char **argv) { | |||
| 248 | if (config.n_procs_to_show > 0) { | 248 | if (config.n_procs_to_show > 0) { |
| 249 | mp_subcheck top_proc_sc = mp_subcheck_init(); | 249 | mp_subcheck top_proc_sc = mp_subcheck_init(); |
| 250 | top_proc_sc = mp_set_subcheck_state(top_proc_sc, STATE_OK); | 250 | top_proc_sc = mp_set_subcheck_state(top_proc_sc, STATE_OK); |
| 251 | top_processes_result top_proc = print_top_consuming_processes(config.n_procs_to_show); | 251 | top_processes_result top_proc = get_top_consuming_processes(config.n_procs_to_show); |
| 252 | xasprintf(&top_proc_sc.output, "Top %lu CPU time consuming processes", | 252 | xasprintf(&top_proc_sc.output, "Top %lu CPU time consuming processes", |
| 253 | config.n_procs_to_show); | 253 | config.n_procs_to_show); |
| 254 | 254 | ||
| 255 | if (top_proc.errorcode == OK) { | 255 | if (top_proc.errorcode == OK) { |
| 256 | for (unsigned long i = 0; i < config.n_procs_to_show; i++) { | 256 | // +1 here since the string list contains the header line |
| 257 | for (unsigned long i = 0; i < config.n_procs_to_show +1; i++) { | ||
| 257 | xasprintf(&top_proc_sc.output, "%s\n%s", top_proc_sc.output, | 258 | xasprintf(&top_proc_sc.output, "%s\n%s", top_proc_sc.output, |
| 258 | top_proc.top_processes[i]); | 259 | top_proc.top_processes[i]); |
| 259 | } | 260 | } |
| @@ -286,11 +287,6 @@ static check_load_config_wrapper process_arguments(int argc, char **argv) { | |||
| 286 | .config = check_load_config_init(), | 287 | .config = check_load_config_init(), |
| 287 | }; | 288 | }; |
| 288 | 289 | ||
| 289 | if (argc < 2) { | ||
| 290 | result.errorcode = ERROR; | ||
| 291 | return result; | ||
| 292 | } | ||
| 293 | |||
| 294 | while (true) { | 290 | while (true) { |
| 295 | int option = 0; | 291 | int option = 0; |
| 296 | int option_index = getopt_long(argc, argv, "Vhrc:w:n:", longopts, &option); | 292 | int option_index = getopt_long(argc, argv, "Vhrc:w:n:", longopts, &option); |
| @@ -448,7 +444,7 @@ int cmpstringp(const void *p1, const void *p2) { | |||
| 448 | } | 444 | } |
| 449 | #endif /* PS_USES_PROCPCPU */ | 445 | #endif /* PS_USES_PROCPCPU */ |
| 450 | 446 | ||
| 451 | static top_processes_result print_top_consuming_processes(unsigned long n_procs_to_show) { | 447 | static top_processes_result get_top_consuming_processes(unsigned long n_procs_to_show) { |
| 452 | top_processes_result result = { | 448 | top_processes_result result = { |
| 453 | .errorcode = OK, | 449 | .errorcode = OK, |
| 454 | }; | 450 | }; |
