[monitoring-plugins] check_load: Add top x functionality to output

Lorenz Kästle git at monitoring-plugins.org
Sun Jul 6 23:40:12 CEST 2025


 Module: monitoring-plugins
 Branch: master
 Commit: b002a6870b6ef9333d3234cec58b8c2fc1acfeec
 Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
   Date: Sun Jul  6 21:58:55 2025 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b002a687

check_load: Add top x functionality to output

---

 plugins/check_load.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/plugins/check_load.c b/plugins/check_load.c
index f7e80fdb..78daa945 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -245,13 +245,15 @@ int main(int argc, char **argv) {
 		mp_subcheck top_proc_sc = mp_subcheck_init();
 		top_proc_sc = mp_set_subcheck_state(top_proc_sc, STATE_OK);
 		top_processes_result top_proc = print_top_consuming_processes(config.n_procs_to_show);
-		top_proc_sc.output = "";
+		xasprintf(&top_proc_sc.output, "Top %lu CPU time consuming processes", config.n_procs_to_show);
 
 		if (top_proc.errorcode == OK) {
 			for (int i = 0; i < config.n_procs_to_show; i++) {
 				xasprintf(&top_proc_sc.output, "%s\n%s", top_proc_sc.output, top_proc.top_processes[i]);
 			}
 		}
+
+		mp_add_subcheck_to_check(&overall, top_proc_sc);
 	}
 
 	mp_exit(overall);



More information about the Commits mailing list