diff options
Diffstat (limited to 'plugins/check_pgsql.d/config.h')
-rw-r--r-- | plugins/check_pgsql.d/config.h | 61 |
1 files changed, 61 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..2d4b8b89 --- /dev/null +++ b/plugins/check_pgsql.d/config.h | |||
@@ -0,0 +1,61 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include "../../config.h" | ||
4 | #include "thresholds.h" | ||
5 | #include <stddef.h> | ||
6 | #include <pg_config_manual.h> | ||
7 | |||
8 | #define DEFAULT_DB "template1" | ||
9 | |||
10 | enum { | ||
11 | DEFAULT_WARN = 2, | ||
12 | DEFAULT_CRIT = 8, | ||
13 | }; | ||
14 | |||
15 | typedef struct { | ||
16 | char *pghost; /* host name of the backend server */ | ||
17 | char *pgport; /* port of the backend server */ | ||
18 | char *pgoptions; /* special options to start up the backend server */ | ||
19 | char *pgtty; /* debugging tty for the backend server */ | ||
20 | char dbName[NAMEDATALEN]; | ||
21 | char *pguser; | ||
22 | char *pgpasswd; | ||
23 | char *pgparams; | ||
24 | char *pgquery; | ||
25 | char *pgqueryname; | ||
26 | |||
27 | double twarn; | ||
28 | double tcrit; | ||
29 | thresholds *qthresholds; | ||
30 | char *query_warning; | ||
31 | char *query_critical; | ||
32 | } check_pgsql_config; | ||
33 | |||
34 | /* begin, by setting the parameters for a backend connection if the | ||
35 | * parameters are null, then the system will try to use reasonable | ||
36 | * defaults by looking up environment variables or, failing that, | ||
37 | * using hardwired constants | ||
38 | * this targets .pgoptions and .pgtty | ||
39 | */ | ||
40 | |||
41 | check_pgsql_config check_pgsql_config_init() { | ||
42 | check_pgsql_config tmp = { | ||
43 | .pghost = NULL, | ||
44 | .pgport = NULL, | ||
45 | .pgoptions = NULL, | ||
46 | .pgtty = NULL, | ||
47 | .dbName = DEFAULT_DB, | ||
48 | .pguser = NULL, | ||
49 | .pgpasswd = NULL, | ||
50 | .pgparams = NULL, | ||
51 | .pgquery = NULL, | ||
52 | .pgqueryname = NULL, | ||
53 | |||
54 | .twarn = (double)DEFAULT_WARN, | ||
55 | .tcrit = (double)DEFAULT_CRIT, | ||
56 | .qthresholds = NULL, | ||
57 | .query_warning = NULL, | ||
58 | .query_critical = NULL, | ||
59 | }; | ||
60 | return tmp; | ||
61 | } | ||