diff options
Diffstat (limited to 'plugins/check_pgsql.d/config.h')
| -rw-r--r-- | plugins/check_pgsql.d/config.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/plugins/check_pgsql.d/config.h b/plugins/check_pgsql.d/config.h new file mode 100644 index 00000000..7cf0637b --- /dev/null +++ b/plugins/check_pgsql.d/config.h | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../../config.h" | ||
| 4 | #include "output.h" | ||
| 5 | #include "perfdata.h" | ||
| 6 | #include "thresholds.h" | ||
| 7 | #include <stddef.h> | ||
| 8 | #include <pg_config_manual.h> | ||
| 9 | |||
| 10 | #define DEFAULT_DB "template1" | ||
| 11 | |||
| 12 | enum { | ||
| 13 | DEFAULT_WARN = 2, | ||
| 14 | DEFAULT_CRIT = 8, | ||
| 15 | }; | ||
| 16 | |||
| 17 | typedef struct { | ||
| 18 | char *pghost; /* host name of the backend server */ | ||
| 19 | char *pgport; /* port of the backend server */ | ||
| 20 | char *pgoptions; /* special options to start up the backend server */ | ||
| 21 | char *pgtty; /* debugging tty for the backend server */ | ||
| 22 | char dbName[NAMEDATALEN]; | ||
| 23 | char *pguser; | ||
| 24 | char *pgpasswd; | ||
| 25 | char *pgparams; | ||
| 26 | char *pgquery; | ||
| 27 | char *pgqueryname; | ||
| 28 | |||
| 29 | mp_thresholds time_thresholds; | ||
| 30 | mp_thresholds qthresholds; | ||
| 31 | |||
| 32 | bool output_format_is_set; | ||
| 33 | mp_output_format output_format; | ||
| 34 | } check_pgsql_config; | ||
| 35 | |||
| 36 | /* begin, by setting the parameters for a backend connection if the | ||
| 37 | * parameters are null, then the system will try to use reasonable | ||
| 38 | * defaults by looking up environment variables or, failing that, | ||
| 39 | * using hardwired constants | ||
| 40 | * this targets .pgoptions and .pgtty | ||
| 41 | */ | ||
| 42 | |||
| 43 | check_pgsql_config check_pgsql_config_init() { | ||
| 44 | check_pgsql_config tmp = { | ||
| 45 | .pghost = NULL, | ||
| 46 | .pgport = NULL, | ||
| 47 | .pgoptions = NULL, | ||
| 48 | .pgtty = NULL, | ||
| 49 | .dbName = DEFAULT_DB, | ||
| 50 | .pguser = NULL, | ||
| 51 | .pgpasswd = NULL, | ||
| 52 | .pgparams = NULL, | ||
| 53 | .pgquery = NULL, | ||
| 54 | .pgqueryname = NULL, | ||
| 55 | |||
| 56 | .time_thresholds = mp_thresholds_init(), | ||
| 57 | .qthresholds = mp_thresholds_init(), | ||
| 58 | |||
| 59 | .output_format_is_set = false, | ||
| 60 | }; | ||
| 61 | |||
| 62 | mp_range tmp_range = mp_range_init(); | ||
| 63 | tmp_range = mp_range_set_end(tmp_range, mp_create_pd_value(DEFAULT_WARN)); | ||
| 64 | tmp.time_thresholds = mp_thresholds_set_warn(tmp.time_thresholds, tmp_range); | ||
| 65 | |||
| 66 | tmp_range = mp_range_set_end(tmp_range, mp_create_pd_value(DEFAULT_CRIT)); | ||
| 67 | tmp.time_thresholds = mp_thresholds_set_crit(tmp.time_thresholds, tmp_range); | ||
| 68 | |||
| 69 | return tmp; | ||
| 70 | } | ||
