[monitoring-plugins] Ok summary (#2270)

GitHub git at monitoring-plugins.org
Mon Jun 8 08:30:14 CEST 2026


    Module: monitoring-plugins
    Branch: master
    Commit: 9bbc76483888c9e2ef2f4ed281c0ab8f2aab7bb6
    Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
 Committer: GitHub <noreply at github.com>
      Date: Mon Jun  8 08:23:44 2026 +0200
       URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=9bbc7648

Ok summary (#2270)

* lib: implement functionality to set ok summary

* check_load: implement setting ok summary

* OK summary for ntp_peer, ntp_time and users

* check_apt: implement ok summary

* check_curl: implement ok summary

* check_disk: implement ok summary

* check_dbi: implement ok summary

* check_ldap: auto formatting

* check_ldap: implement ok summary

* check_ssh: implement ok summary

* check_tcp: implement ok summary

* fixup! check_curl: implement ok summary

* fixup! check_dbi: implement ok summary

* fixup! check_ldap: implement ok summary

* fixup! check_ssh: implement ok summary

* fixup! check_tcp: implement ok summary

* check_apt: remove illegal free

* check_mrtg: fix link

* check_mrtg: implement ok summary

* check_mrtgtraf: fix link

* check_mrtgtraf: implement ok summary

* check_mysql: implement ok summary

* check_mysql_query: implement ok summary

* check_pgsql: implement ok summary

* check_radius: implement ok summary

* check_real: implement ok summary

* check_smtp: implement ok summary

* check_snmp: implement ok summary

* check_swap: implement ok summary

* check_ups: add OK summary

---------

Co-authored-by: Lorenz Kästle <lorenz.kaestle at netways.de>

---

 lib/output.c                | 26 +++++++++++++-------------
 lib/output.h                |  2 ++
 plugins/check_apt.c         |  9 +++++++++
 plugins/check_curl.c        |  2 ++
 plugins/check_dbi.c         |  2 ++
 plugins/check_disk.c        |  3 +++
 plugins/check_ldap.c        |  4 +++-
 plugins/check_load.c        | 13 ++++++++++++-
 plugins/check_mrtg.c        |  4 +++-
 plugins/check_mrtgtraf.c    |  5 ++++-
 plugins/check_mysql.c       |  2 ++
 plugins/check_mysql_query.c |  3 +++
 plugins/check_ntp_peer.c    |  2 ++
 plugins/check_ntp_time.c    |  2 ++
 plugins/check_pgsql.c       |  2 ++
 plugins/check_radius.c      |  3 +++
 plugins/check_real.c        |  3 +++
 plugins/check_smtp.c        |  3 +++
 plugins/check_snmp.c        |  2 ++
 plugins/check_ssh.c         |  2 ++
 plugins/check_swap.c        |  3 +++
 plugins/check_tcp.c         |  2 ++
 plugins/check_ups.c         |  2 ++
 plugins/check_users.c       |  7 ++++++-
 24 files changed, 90 insertions(+), 18 deletions(-)

diff --git a/lib/output.c b/lib/output.c
index 9bcd02d9..b1e91231 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -105,6 +105,7 @@ static inline char *fmt_subcheck_perfdata(mp_subcheck check) {
  */
 mp_check mp_check_init(void) {
 	mp_check check = {
+		.ok_summary = NULL,
 		.evaluation_function = &mp_eval_check_default,
 		.default_output_override = NULL,
 		.default_output_override_content = NULL,
@@ -211,6 +212,14 @@ int mp_add_subcheck_to_subcheck(mp_subcheck check[static 1], mp_subcheck subchec
  */
 void mp_set_summary(mp_check check[static 1], char *summary) { check->summary = strdup(summary); }
 
+/*
+ * set the summary for the OK state
+ * this allows to set the content in the first line of the plugin
+ * if the overall state is OK
+ */
+void mp_set_ok_summary(mp_check check[static 1], char *ok_summary) {
+	check->ok_summary = strdup(ok_summary);
+}
 /*
  * Generate the summary string of a mp_check object based on its subchecks
  */
@@ -255,21 +264,12 @@ char *get_subcheck_summary(mp_check check) {
 	}
 
 	if (result == NULL) {
-		if (ok_count > 0) {
+		// Nothing in result yet, we must be in an OK state
+		if (check.ok_summary != NULL) {
+			asprintf(&result, "%s", check.ok_summary);
+		} else if (ok_count > 0) {
 			asprintf(&result, "ok=%d", ok_count);
 		}
-
-		if (warning_count > 0) {
-			asprintf(&result, "%swarning=%d", (result == NULL ? "" : ", "), warning_count);
-		}
-
-		if (critical_count > 0) {
-			asprintf(&result, "%scritical=%d", (result == NULL ? "" : ", "), critical_count);
-		}
-
-		if (unknown_count > 0) {
-			asprintf(&result, "%sunknown=%d", (result == NULL ? "" : ", "), unknown_count);
-		}
 	}
 
 	return result;
diff --git a/lib/output.h b/lib/output.h
index 6ca63cfe..b9cdb07d 100644
--- a/lib/output.h
+++ b/lib/output.h
@@ -66,6 +66,7 @@ mp_output_detail_level mp_get_level_of_detail(void);
 typedef struct mp_check mp_check;
 struct mp_check {
 	char *summary; // Overall summary, if not set a summary will be automatically generated
+	char *ok_summary; // (optional) Summary if the overall state is OK
 	mp_subcheck_list *subchecks;
 
 	// the evaluation_functions computes the state of check
@@ -88,6 +89,7 @@ int mp_add_subcheck_to_subcheck(mp_subcheck check[static 1], mp_subcheck);
 void mp_add_perfdata_to_subcheck(mp_subcheck check[static 1], mp_perfdata);
 
 void mp_set_summary(mp_check check[static 1], char *summary);
+void mp_set_ok_summary(mp_check check[static 1], char *ok_summary);
 
 mp_state_enum mp_compute_check_state(mp_check);
 mp_state_enum mp_compute_subcheck_state(mp_subcheck);
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index 9ed5b6cf..345b8414 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -204,6 +204,15 @@ int main(int argc, char **argv) {
 	mp_add_subcheck_to_check(&overall, sc_security_updates);
 	mp_add_subcheck_to_check(&overall, sc_other_updates);
 
+	char *ok_summary = NULL;
+
+	if (packages_available == 0) {
+		ok_summary = "No pending updates";
+	} else {
+		xasprintf(&ok_summary, "%zu pending updates", packages_available);
+	}
+	mp_set_ok_summary(&overall, ok_summary);
+
 	mp_exit(overall);
 }
 
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 3f44c86b..adafc620 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -161,6 +161,8 @@ int main(int argc, char **argv) {
 	mp_check overall = mp_check_init();
 	mp_subcheck sc_test = check_http(config, working_state, 0);
 
+	mp_set_ok_summary(&overall, "Connection test succeeded");
+
 	mp_add_subcheck_to_check(&overall, sc_test);
 
 	mp_exit(overall);
diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c
index dd466d00..9c5c8574 100644
--- a/plugins/check_dbi.c
+++ b/plugins/check_dbi.c
@@ -220,6 +220,8 @@ int main(int argc, char **argv) {
 
 	mp_check overall = mp_check_init();
 
+	mp_set_ok_summary(&overall, "DBI check was successful");
+
 	mp_subcheck sc_connection_time = mp_subcheck_init();
 	sc_connection_time = mp_set_subcheck_default_state(sc_connection_time, STATE_OK);
 	xasprintf(&sc_connection_time.output, "Connection time: %f", conn_time);
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index e773e56c..65169105 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -162,6 +162,9 @@ int main(int argc, char **argv) {
 	}
 
 	mp_check overall = mp_check_init();
+
+	mp_set_ok_summary(&overall, "Filesystem checks succeeded");
+
 	if (config.path_select_list.length == 0) {
 		mp_subcheck none_sc = mp_subcheck_init();
 		xasprintf(&none_sc.output, "No filesystems were found for the provided parameters");
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index 0e8c5804..ea4b3b1e 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -98,6 +98,8 @@ int main(int argc, char *argv[]) {
 
 	mp_check overall = mp_check_init();
 
+	mp_set_ok_summary(&overall, "LDAP check succeeded");
+
 	LDAP *ldap_connection;
 	/* initialize ldap */
 	{
@@ -428,7 +430,7 @@ check_ldap_config_wrapper process_arguments(int argc, char **argv) {
 				die(STATE_UNKNOWN, "failed to parse number of entries critical threshold");
 			}
 			result.config.entries_thresholds =
-				 mp_thresholds_set_crit(result.config.entries_thresholds, tmp.range);
+				mp_thresholds_set_crit(result.config.entries_thresholds, tmp.range);
 		} break;
 #ifdef HAVE_LDAP_SET_OPTION
 		case '2':
diff --git a/plugins/check_load.c b/plugins/check_load.c
index 7995408e..66d6a4b7 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -145,6 +145,12 @@ int main(int argc, char **argv) {
 		mp_set_format(config.output_format);
 	}
 
+	char *ok_summary = NULL;
+	xasprintf(&ok_summary, "Load: 1m: %f - 5m: %f - 15m: %f", load_values[0], load_values[1],
+			  load_values[2]);
+	mp_set_ok_summary(&overall, ok_summary);
+	free(ok_summary);
+
 	bool is_using_scaled_load_values = false;
 	long numcpus;
 	if (config.take_into_account_cpus && ((numcpus = GET_NUMBER_OF_CPUS()) > 0)) {
@@ -156,6 +162,11 @@ int main(int argc, char **argv) {
 			load_values[2] / numcpus,
 		};
 
+		xasprintf(&ok_summary, "Scaled Load (%ld CPUs): 1m: %f - 5m: %f - 15m: %f", numcpus,
+				  load_values[0], load_values[1], load_values[2]);
+		mp_set_ok_summary(&overall, ok_summary);
+		free(ok_summary);
+
 		mp_subcheck scaled_load_sc = mp_subcheck_init();
 		scaled_load_sc = mp_set_subcheck_default_state(scaled_load_sc, STATE_OK);
 		scaled_load_sc.output = "Scaled Load (divided by number of CPUs)";
@@ -254,7 +265,7 @@ int main(int argc, char **argv) {
 
 		if (top_proc.errorcode == OK) {
 			// +1 here since the string list contains the header line
-			for (unsigned long i = 0; i < config.n_procs_to_show +1; i++) {
+			for (unsigned long i = 0; i < config.n_procs_to_show + 1; i++) {
 				xasprintf(&top_proc_sc.output, "%s\n%s", top_proc_sc.output,
 						  top_proc.top_processes[i]);
 			}
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c
index bb38fcc5..5c05426d 100644
--- a/plugins/check_mrtg.c
+++ b/plugins/check_mrtg.c
@@ -72,6 +72,8 @@ int main(int argc, char **argv) {
 
 	mp_check overall = mp_check_init();
 
+	mp_set_ok_summary(&overall, "Values in MRTG log are OK");
+
 	/* open the MRTG log file for reading */
 	mp_subcheck sc_open_mrtg_log_file = mp_subcheck_init();
 	FILE *mtrg_log_file = fopen(config.log_file, "r");
@@ -436,7 +438,7 @@ void print_help(void) {
 	printf("   %s\n", _("you can always hack the code to make this plugin work for you..."));
 	printf(" %s\n",
 		   _("- MRTG stands for the Multi Router Traffic Grapher.  It can be downloaded from"));
-	printf("   %s\n", "http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html");
+	printf("   %s\n", "https://oss.oetiker.ch/mrtg/");
 
 	printf(UT_SUPPORT);
 }
diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c
index 46b94f57..be9f67b2 100644
--- a/plugins/check_mrtgtraf.c
+++ b/plugins/check_mrtgtraf.c
@@ -70,6 +70,9 @@ int main(int argc, char **argv) {
 	}
 
 	mp_check overall = mp_check_init();
+
+	mp_set_ok_summary(&overall, "Transfer rates in MRTG are OK");
+
 	mp_subcheck sc_open_mrtg_log_file = mp_subcheck_init();
 
 	/* open the MRTG log file for reading */
@@ -440,7 +443,7 @@ void print_help(void) {
 	printf("\n");
 	printf("%s\n", _("Notes:"));
 	printf(" %s\n", _("- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from"));
-	printf(" %s\n", "  http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html");
+	printf(" %s\n", "  https://oss.oetiker.ch/mrtg/");
 	printf(" %s\n", _("- While MRTG can monitor things other than traffic rates, this"));
 	printf(" %s\n", _("  plugin probably won't work with much else without modification."));
 	printf(" %s\n", _("- The calculated i/o rates are a little off from what MRTG actually"));
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index b70e0e22..eee32e71 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -121,6 +121,8 @@ int main(int argc, char **argv) {
 
 	mp_check overall = mp_check_init();
 
+	mp_set_ok_summary(&overall, "Mariadb/MySQL seems to be ok");
+
 	mp_subcheck sc_connection = mp_subcheck_init();
 	/* establish a connection to the server and check for errors */
 	if (!mysql_real_connect(&mysql, config.db_host, config.db_user, config.db_pass, config.db,
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c
index fc0966d3..ff86e219 100644
--- a/plugins/check_mysql_query.c
+++ b/plugins/check_mysql_query.c
@@ -92,6 +92,9 @@ int main(int argc, char **argv) {
 	}
 
 	mp_check overall = mp_check_init();
+
+	mp_set_ok_summary(&overall, "MySQL query is OK");
+
 	mp_subcheck sc_connect = mp_subcheck_init();
 
 	/* establish a connection to the server and error checking */
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index b5cfb460..34686cb9 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -708,6 +708,8 @@ int main(int argc, char *argv[]) {
 	const ntp_request_result ntp_res = ntp_request(config);
 	mp_check overall = mp_check_init();
 
+	mp_set_ok_summary(&overall, "NTP Server seems to be OK");
+
 	mp_subcheck sc_offset = mp_subcheck_init();
 	xasprintf(&sc_offset.output, "offset");
 	if (ntp_res.offset_result == STATE_UNKNOWN) {
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index 4e3a55db..3e23d0bf 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -696,6 +696,8 @@ int main(int argc, char *argv[]) {
 
 	mp_check overall = mp_check_init();
 
+	mp_set_ok_summary(&overall, "NTP time synchronisation seems to be working");
+
 	mp_subcheck sc_offset = mp_subcheck_init();
 	offset_request_wrapper offset_result =
 		offset_request(config.server_address, config.port, config.time_offset);
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 8cbaaeeb..9e6b0f41 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -214,6 +214,8 @@ int main(int argc, char **argv) {
 
 	mp_check overall = mp_check_init();
 
+	mp_set_ok_summary(&overall, "Postgres check is OK");
+
 	mp_subcheck sc_connection = mp_subcheck_init();
 
 	if (PQstatus(conn) == CONNECTION_BAD) {
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 03153926..9f9af3cc 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -171,6 +171,9 @@ int main(int argc, char **argv) {
 #endif
 
 	mp_check overall = mp_check_init();
+
+	mp_set_ok_summary(&overall, "Radius check is OK");
+
 	mp_subcheck sc_read_config = mp_subcheck_init();
 
 	char *str = strdup("dictionary");
diff --git a/plugins/check_real.c b/plugins/check_real.c
index b415578f..0dd649e1 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -83,6 +83,9 @@ int main(int argc, char **argv) {
 	time(&start_time);
 
 	mp_check overall = mp_check_init();
+
+	mp_set_ok_summary(&overall, "REAL check is OK");
+
 	mp_subcheck sc_connect = mp_subcheck_init();
 
 	/* try to connect to the host at the given port number */
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 19e2a58f..e1f2842e 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -187,6 +187,9 @@ int main(int argc, char **argv) {
 		my_tcp_connect(config.server_address, config.server_port, &socket_descriptor);
 
 	mp_check overall = mp_check_init();
+
+	mp_set_ok_summary(&overall, "SMTP connection check is OK");
+
 	mp_subcheck sc_tcp_connect = mp_subcheck_init();
 	char buffer[MAX_INPUT_BUFFER];
 	bool ssl_established = false;
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 09196dc4..b595066a 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -295,6 +295,8 @@ int main(int argc, char **argv) {
 
 	mp_check overall = mp_check_init();
 
+	mp_set_ok_summary(&overall, "SNMP query is OK");
+
 	if (response.errorcode == OK) {
 		mp_subcheck sc_successfull_query = mp_subcheck_init();
 		xasprintf(&sc_successfull_query.output, "SNMP query was successful");
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index 911f6787..df85b815 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -93,6 +93,8 @@ int main(int argc, char **argv) {
 		mp_set_format(config.output_format);
 	}
 
+	mp_set_ok_summary(&overall, "SSH check was successful");
+
 	/* initialize alarm signal handling */
 	signal(SIGALRM, socket_timeout_alarm_handler);
 	alarm(socket_timeout);
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index dbf53a00..3d7e3260 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -100,6 +100,9 @@ int main(int argc, char **argv) {
 
 	double percent_used;
 	mp_check overall = mp_check_init();
+
+	mp_set_ok_summary(&overall, "Swap check is OK");
+
 	if (config.output_format_is_set) {
 		mp_set_format(config.output_format);
 	}
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 924322e4..8f1044ea 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -249,6 +249,8 @@ int main(int argc, char **argv) {
 		mp_set_format(config.output_format);
 	}
 
+	mp_set_ok_summary(&overall, "Connection succeeded");
+
 	/* set up the timer */
 	signal(SIGALRM, socket_timeout_alarm_handler);
 	alarm(socket_timeout);
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index ac6bf574..7bced308 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -91,6 +91,8 @@ int main(int argc, char **argv) {
 
 	mp_check overall = mp_check_init();
 
+	mp_set_ok_summary(&overall, "UPS check is OK");
+
 	mp_subcheck sc_retrieve_status = mp_subcheck_init();
 
 	/* get the ups status if possible */
diff --git a/plugins/check_users.c b/plugins/check_users.c
index 4027d21a..8e0e2c35 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -111,8 +111,13 @@ int main(int argc, char **argv) {
 		mp_add_subcheck_to_check(&overall, sc_users);
 		mp_exit(overall);
 	}
-	/* check the user count against warning and critical thresholds */
 
+	char *ok_summary = NULL;
+	xasprintf(&ok_summary, "Users on the system: %d", user_wrapper.users);
+	mp_set_ok_summary(&overall, ok_summary);
+	free(ok_summary);
+
+	/* check the user count against warning and critical thresholds */
 	mp_perfdata users_pd = {
 		.label = "users",
 		.value = mp_create_pd_value(user_wrapper.users),



More information about the Commits mailing list