summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.d
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_curl.d')
-rw-r--r--plugins/check_curl.d/config.h144
1 files changed, 144 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..43be0306
--- /dev/null
+++ b/plugins/check_curl.d/config.h
@@ -0,0 +1,144 @@
1#pragma once
2
3#include "../../config.h"
4#include "common.h"
5#include "states.h"
6#include "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 unsigned short server_port;
38 unsigned short virtual_port;
39 char *host_name;
40 char *server_url;
41 sa_family_t sin_family;
42
43 bool automatic_decompression;
44 bool haproxy_protocol;
45 char *client_cert;
46 char *client_privkey;
47 char *ca_cert;
48 bool use_ssl;
49 int ssl_version;
50 char *http_method;
51 char user_agent[DEFAULT_BUFFER_SIZE];
52 char **http_opt_headers;
53 size_t http_opt_headers_count;
54 char *http_post_data;
55 int max_depth;
56 char *http_content_type;
57 long socket_timeout;
58 char user_auth[MAX_INPUT_BUFFER];
59 char proxy_auth[MAX_INPUT_BUFFER];
60 int followmethod;
61 int followsticky;
62 bool no_body;
63 int curl_http_version;
64 char *cookie_jar_file;
65
66 int maximum_age;
67 char regexp[MAX_RE_SIZE];
68 mp_state_enum state_regex;
69 bool invert_regex;
70 bool verify_peer_and_host;
71 bool check_cert;
72 bool continue_after_check_cert;
73 int days_till_exp_warn;
74 int days_till_exp_crit;
75 thresholds *thlds;
76 size_t min_page_len;
77 size_t max_page_len;
78 char server_expect[MAX_INPUT_BUFFER];
79 bool server_expect_yn;
80 char string_expect[MAX_INPUT_BUFFER];
81 char header_expect[MAX_INPUT_BUFFER];
82 mp_state_enum onredirect;
83
84 bool show_extended_perfdata;
85 bool show_body;
86 bool display_html;
87} check_curl_config;
88
89check_curl_config check_curl_config_init() {
90 check_curl_config tmp = {
91 .server_address = NULL,
92 .server_port = HTTP_PORT,
93 .virtual_port = 0,
94 .host_name = NULL,
95 .server_url = strdup(DEFAULT_SERVER_URL),
96 .sin_family = AF_UNSPEC,
97
98 .automatic_decompression = false,
99 .haproxy_protocol = false,
100 .client_cert = NULL,
101 .client_privkey = NULL,
102 .ca_cert = NULL,
103 .use_ssl = false,
104 .ssl_version = CURL_SSLVERSION_DEFAULT,
105 .http_method = NULL,
106 .user_agent = {'\0'},
107 .http_opt_headers = NULL,
108 .http_opt_headers_count = 0,
109 .http_post_data = NULL,
110 .max_depth = DEFAULT_MAX_REDIRS,
111 .http_content_type = NULL,
112 .socket_timeout = DEFAULT_SOCKET_TIMEOUT,
113 .user_auth = "",
114 .proxy_auth = "",
115 .followmethod = FOLLOW_HTTP_CURL,
116 .followsticky = STICKY_NONE,
117 .no_body = false,
118 .curl_http_version = CURL_HTTP_VERSION_NONE,
119 .cookie_jar_file = NULL,
120
121 .maximum_age = -1,
122 .regexp = {},
123 .state_regex = STATE_CRITICAL,
124 .invert_regex = false,
125 .verify_peer_and_host = false,
126 .check_cert = false,
127 .continue_after_check_cert = false,
128 .days_till_exp_warn = 0,
129 .days_till_exp_crit = 0,
130 .thlds = NULL,
131 .min_page_len = 0,
132 .max_page_len = 0,
133 .server_expect = HTTP_EXPECT,
134 .server_expect_yn = false,
135 .string_expect = "",
136 .header_expect = "",
137 .onredirect = STATE_OK,
138
139 .show_extended_perfdata = false,
140 .show_body = false,
141 .display_html = false,
142 };
143 return tmp;
144}