From c57381d789fb246602966fccfcb80131a7fb0461 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Mon, 6 Apr 2026 11:55:27 +0200 Subject: Revert check_disk performance data back to used space (#2243) * Implement simple output shortcut for ranges If ranges start with zero (e.g. 0:10), the zero and the colon can be left out. This patch implements this by default, since some systems (icinga2) do not fully implement the whole range format and this reduces errors in the common case of just an upper border. * switch check_disk perfdata back to used space --- lib/perfdata.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/perfdata.c') diff --git a/lib/perfdata.c b/lib/perfdata.c index f4eaf843..e3710ec7 100644 --- a/lib/perfdata.c +++ b/lib/perfdata.c @@ -251,7 +251,16 @@ char *mp_range_to_string(const mp_range input) { if (input.start_infinity) { asprintf(&result, "%s~:", result); } else { - asprintf(&result, "%s%s:", result, pd_value_to_string(input.start)); + // check for zeroes, so we can use the short form + if ((input.start.type == PD_TYPE_NONE) || + ((input.start.type == PD_TYPE_INT) && (input.start.pd_int == 0)) || + ((input.start.type == PD_TYPE_UINT) && (input.start.pd_uint == 0)) || + ((input.start.type == PD_TYPE_DOUBLE) && (input.start.pd_double == 0))){ + // nothing to do here + } else { + // Start value is an actual value + asprintf(&result, "%s%s:", result, pd_value_to_string(input.start)); + } } if (!input.end_infinity) { -- cgit v1.2.3-74-g34f1