summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.d/config.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_curl.d/config.h')
-rw-r--r--plugins/check_curl.d/config.h160
1 files changed, 160 insertions, 0 deletions
diff --git a/plugins/check_curl.d/config.h b/plugins/check_curl.d/config.h
new file mode 100644
index 00000000..9de68713
--- /dev/null
+++ b/plugins/check_curl.d/config.h
@@ -0,0 +1,160 @@
1#pragma once
2
3#include "../../config.h"
4#include "../common.h"
5#include "../../lib/states.h"
6#include "../../lib/thresholds.h"
7#include <stddef.h>
8#include <string.h>
9#include <sys/socket.h>
10#include "curl/curl.h"
11
12enum {
13 MAX_RE_SIZE = 1024,
14 HTTP_PORT = 80,
15 HTTPS_PORT = 443,
16 MAX_PORT = 65535,
17 DEFAULT_MAX_REDIRS = 15
18};
19
20enum {
21 FOLLOW_HTTP_CURL = 0,
22 FOLLOW_LIBCURL = 1
23};
24
25enum {
26 STICKY_NONE = 0,
27 STICKY_HOST = 1,
28 STICKY_PORT = 2
29};
30
31#define HTTP_EXPECT "HTTP/"
32#define DEFAULT_BUFFER_SIZE 2048
33#define DEFAULT_SERVER_URL "/"
34
35typedef struct {
36 char *server_address;
37 char *server_url;
38 char *host_name;
39
40 char *http_method;
41
42 char *http_post_data;
43
44 unsigned short virtualPort;
45 unsigned short serverPort;
46
47 bool use_ssl;
48 bool no_body;
49} check_curl_working_state;
50
51check_curl_working_state check_curl_working_state_init() {
52 check_curl_working_state result = {
53 .server_address = NULL,
54 .server_url = DEFAULT_SERVER_URL,
55 .host_name = NULL,
56 .http_method = NULL,
57 .http_post_data = NULL,
58 .virtualPort = 0,
59 .serverPort = 0,
60 .use_ssl = false,
61 .no_body = false,
62 };
63 return result;
64}
65
66typedef struct {
67 check_curl_working_state initial_config;
68 sa_family_t sin_family;
69
70 bool automatic_decompression;
71 bool haproxy_protocol;
72 char *client_cert;
73 char *client_privkey;
74 char *ca_cert;
75 int ssl_version;
76 char user_agent[DEFAULT_BUFFER_SIZE];
77 char **http_opt_headers;
78 size_t http_opt_headers_count;
79 int max_depth;
80 char *http_content_type;
81 long socket_timeout;
82 char user_auth[MAX_INPUT_BUFFER];
83 char proxy_auth[MAX_INPUT_BUFFER];
84 int followmethod;
85 int followsticky;
86 int curl_http_version;
87 char *cookie_jar_file;
88
89 int maximum_age;
90 char regexp[MAX_RE_SIZE];
91 mp_state_enum state_regex;
92 bool invert_regex;
93 bool verify_peer_and_host;
94 bool check_cert;
95 bool continue_after_check_cert;
96 int days_till_exp_warn;
97 int days_till_exp_crit;
98 thresholds *thlds;
99 size_t min_page_len;
100 size_t max_page_len;
101 char server_expect[MAX_INPUT_BUFFER];
102 bool server_expect_yn;
103 char string_expect[MAX_INPUT_BUFFER];
104 char header_expect[MAX_INPUT_BUFFER];
105 mp_state_enum onredirect;
106
107 bool show_extended_perfdata;
108 bool show_body;
109 bool display_html;
110} check_curl_config;
111
112check_curl_config check_curl_config_init() {
113 check_curl_config tmp = {
114 .initial_config = check_curl_working_state_init(),
115
116 .sin_family = AF_UNSPEC,
117
118 .automatic_decompression = false,
119 .haproxy_protocol = false,
120 .client_cert = NULL,
121 .client_privkey = NULL,
122 .ca_cert = NULL,
123 .ssl_version = CURL_SSLVERSION_DEFAULT,
124 .user_agent = {'\0'},
125 .http_opt_headers = NULL,
126 .http_opt_headers_count = 0,
127 .max_depth = DEFAULT_MAX_REDIRS,
128 .http_content_type = NULL,
129 .socket_timeout = DEFAULT_SOCKET_TIMEOUT,
130 .user_auth = "",
131 .proxy_auth = "",
132 .followmethod = FOLLOW_HTTP_CURL,
133 .followsticky = STICKY_NONE,
134 .curl_http_version = CURL_HTTP_VERSION_NONE,
135 .cookie_jar_file = NULL,
136
137 .maximum_age = -1,
138 .regexp = {},
139 .state_regex = STATE_CRITICAL,
140 .invert_regex = false,
141 .verify_peer_and_host = false,
142 .check_cert = false,
143 .continue_after_check_cert = false,
144 .days_till_exp_warn = 0,
145 .days_till_exp_crit = 0,
146 .thlds = NULL,
147 .min_page_len = 0,
148 .max_page_len = 0,
149 .server_expect = HTTP_EXPECT,
150 .server_expect_yn = false,
151 .string_expect = "",
152 .header_expect = "",
153 .onredirect = STATE_OK,
154
155 .show_extended_perfdata = false,
156 .show_body = false,
157 .display_html = false,
158 };
159 return tmp;
160}