From 992a4555ac975285f959dd2d3228b1d71ab23123 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Mon, 8 Jun 2026 07:35:45 +0200 Subject: check_ups: implement modern output (#2272) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lorenz Kästle --- plugins/check_ups.d/config.h | 79 ++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 33 deletions(-) (limited to 'plugins/check_ups.d') diff --git a/plugins/check_ups.d/config.h b/plugins/check_ups.d/config.h index e05edceb..900363fd 100644 --- a/plugins/check_ups.d/config.h +++ b/plugins/check_ups.d/config.h @@ -1,31 +1,36 @@ #pragma once #include "../../config.h" +#include "thresholds.h" #include -#define UPS_NONE 0 /* no supported options */ -#define UPS_UTILITY 1 /* supports utility line */ -#define UPS_BATTPCT 2 /* supports percent battery remaining */ -#define UPS_STATUS 4 /* supports UPS status */ -#define UPS_TEMP 8 /* supports UPS temperature */ -#define UPS_LOADPCT 16 /* supports load percent */ -#define UPS_REALPOWER 32 /* supports real power */ - -#define UPSSTATUS_NONE 0 -#define UPSSTATUS_OFF 1 -#define UPSSTATUS_OL 2 -#define UPSSTATUS_OB 4 -#define UPSSTATUS_LB 8 -#define UPSSTATUS_CAL 16 -#define UPSSTATUS_RB 32 /*Replace Battery */ -#define UPSSTATUS_BYPASS 64 -#define UPSSTATUS_OVER 128 -#define UPSSTATUS_TRIM 256 -#define UPSSTATUS_BOOST 512 -#define UPSSTATUS_CHRG 1024 -#define UPSSTATUS_DISCHRG 2048 -#define UPSSTATUS_UNKNOWN 4096 -#define UPSSTATUS_ALARM 8192 +typedef enum { + UPS_NONE = 0, /* no supported options */ + UPS_UTILITY = 1, /* supports utility line */ + UPS_BATTPCT = 2, /* supports percent battery remaining */ + UPS_STATUS = 4, /* supports UPS status */ + UPS_TEMP = 8, /* supports UPS temperature */ + UPS_LOADPCT = 16, /* supports load percent */ + UPS_REALPOWER = 32, /* supports real power */ +} ups_test_type; + +typedef enum { + UPSSTATUS_NONE = 0, + UPSSTATUS_OFF = 1, + UPSSTATUS_OL = 2, + UPSSTATUS_OB = 4, + UPSSTATUS_LB = 8, + UPSSTATUS_CAL = 16, + UPSSTATUS_RB = 32, /*Replace Battery */ + UPSSTATUS_BYPASS = 64, + UPSSTATUS_OVER = 128, + UPSSTATUS_TRIM = 256, + UPSSTATUS_BOOST = 512, + UPSSTATUS_CHRG = 1024, + UPSSTATUS_DISCHRG = 2048, + UPSSTATUS_UNKNOWN = 4096, + UPSSTATUS_ALARM = 8192, +} ups_status_type; enum { PORT = 3493 @@ -35,20 +40,28 @@ typedef struct ups_config { unsigned int server_port; char *server_address; char *ups_name; - double warning_value; - double critical_value; - bool check_warn; - bool check_crit; - int check_variable; + + mp_thresholds utility_thresholds; + mp_thresholds battery_thresholds; + mp_thresholds load_thresholds; + mp_thresholds real_power_thresholds; + mp_thresholds temperature_thresholds; + bool temp_output_c; } check_ups_config; check_ups_config check_ups_config_init(void) { - check_ups_config tmp = {0}; - tmp.server_port = PORT; - tmp.server_address = NULL; - tmp.ups_name = NULL; - tmp.check_variable = UPS_NONE; + check_ups_config tmp = { + .server_port = PORT, + .server_address = NULL, + .ups_name = NULL, + + .utility_thresholds = mp_thresholds_init(), + .battery_thresholds = mp_thresholds_init(), + .load_thresholds = mp_thresholds_init(), + .real_power_thresholds = mp_thresholds_init(), + .temperature_thresholds = mp_thresholds_init(), + }; return tmp; } -- cgit v1.2.3-74-g34f1