From de392a81ede00fef1c25e220ee253d487453f6cd Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 12 Mar 2025 02:16:41 +0100 Subject: Refactor check_pgsql --- plugins/check_pgsql.d/config.h | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 plugins/check_pgsql.d/config.h (limited to 'plugins/check_pgsql.d') diff --git a/plugins/check_pgsql.d/config.h b/plugins/check_pgsql.d/config.h new file mode 100644 index 00000000..2d4b8b89 --- /dev/null +++ b/plugins/check_pgsql.d/config.h @@ -0,0 +1,61 @@ +#pragma once + +#include "../../config.h" +#include "thresholds.h" +#include +#include + +#define DEFAULT_DB "template1" + +enum { + DEFAULT_WARN = 2, + DEFAULT_CRIT = 8, +}; + +typedef struct { + char *pghost; /* host name of the backend server */ + char *pgport; /* port of the backend server */ + char *pgoptions; /* special options to start up the backend server */ + char *pgtty; /* debugging tty for the backend server */ + char dbName[NAMEDATALEN]; + char *pguser; + char *pgpasswd; + char *pgparams; + char *pgquery; + char *pgqueryname; + + double twarn; + double tcrit; + thresholds *qthresholds; + char *query_warning; + char *query_critical; +} check_pgsql_config; + +/* begin, by setting the parameters for a backend connection if the + * parameters are null, then the system will try to use reasonable + * defaults by looking up environment variables or, failing that, + * using hardwired constants + * this targets .pgoptions and .pgtty + */ + +check_pgsql_config check_pgsql_config_init() { + check_pgsql_config tmp = { + .pghost = NULL, + .pgport = NULL, + .pgoptions = NULL, + .pgtty = NULL, + .dbName = DEFAULT_DB, + .pguser = NULL, + .pgpasswd = NULL, + .pgparams = NULL, + .pgquery = NULL, + .pgqueryname = NULL, + + .twarn = (double)DEFAULT_WARN, + .tcrit = (double)DEFAULT_CRIT, + .qthresholds = NULL, + .query_warning = NULL, + .query_critical = NULL, + }; + return tmp; +} -- cgit v1.2.3-74-g34f1