summaryrefslogtreecommitdiffstats
path: root/plugins/check_dbi.d/config.h
blob: 25d74a12f5be6b9cc6d0022ad3d66834139ca213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once

#include "../../config.h"
#include <stddef.h>
#include "../../lib/monitoringplug.h"
#include "thresholds.h"

typedef enum {
	METRIC_CONN_TIME,
	METRIC_SERVER_VERSION,
	METRIC_QUERY_RESULT,
	METRIC_QUERY_TIME,
} check_dbi_metric;

typedef enum {
	TYPE_NUMERIC,
	TYPE_STRING,
} check_dbi_type;

typedef struct {
	char *key;
	char *value;
} driver_option_t;

typedef struct {
	char *dbi_driver;
	char *host;

	driver_option_t *dbi_options;
	size_t dbi_options_num;

	char *database;
	char *query;

	char *expect;
	char *expect_re_str;
	int expect_re_cflags;
	check_dbi_metric metric;
	check_dbi_type type;
	mp_thresholds thresholds;

	bool output_format_is_set;
	mp_output_format output_format;
} check_dbi_config;

check_dbi_config check_dbi_config_init() {
	check_dbi_config tmp = {
		.dbi_driver = NULL,
		.host = NULL,
		.dbi_options = NULL,
		.dbi_options_num = 0,
		.database = NULL,
		.query = NULL,

		.expect = NULL,
		.expect_re_str = NULL,
		.expect_re_cflags = 0,
		.metric = METRIC_QUERY_RESULT,
		.type = TYPE_NUMERIC,

		.thresholds = mp_thresholds_init(),

		.output_format_is_set = false,
	};
	return tmp;
}