summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.d
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-03-11 02:02:27 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-03-11 02:02:27 +0100
commitf25a4000b6ffbe0fff1d749ff334b36c77ddc6a2 (patch)
treeadf1152a6c69583e44d3d4e41088eb57217c774f /plugins/check_curl.d
parentaa137f7d4adb8ebbbdd3a4c71cd28824d6fcfaca (diff)
downloadmonitoring-plugins-f25a4000b6ffbe0fff1d749ff334b36c77ddc6a2.tar.gz
Refactor check_curl
Diffstat (limited to 'plugins/check_curl.d')
-rw-r--r--plugins/check_curl.d/config.h141
1 files changed, 141 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..9085fbbb
--- /dev/null
+++ b/plugins/check_curl.d/config.h
@@ -0,0 +1,141 @@
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 "curl/curl.h"
10
11enum {
12 MAX_RE_SIZE = 1024,
13 HTTP_PORT = 80,
14 HTTPS_PORT = 443,
15 MAX_PORT = 65535,
16 DEFAULT_MAX_REDIRS = 15
17};
18
19enum {
20 FOLLOW_HTTP_CURL = 0,
21 FOLLOW_LIBCURL = 1
22};
23
24enum {
25 STICKY_NONE = 0,
26 STICKY_HOST = 1,
27 STICKY_PORT = 2
28};
29
30#define HTTP_EXPECT "HTTP/"
31#define DEFAULT_BUFFER_SIZE 2048
32#define DEFAULT_SERVER_URL "/"
33
34typedef struct {
35 char *server_address;
36 unsigned short server_port;
37 unsigned short virtual_port;
38 char *host_name;
39 char *server_url;
40
41 bool automatic_decompression;
42 bool haproxy_protocol;
43 char *client_cert;
44 char *client_privkey;
45 char *ca_cert;
46 bool use_ssl;
47 int ssl_version;
48 char *http_method;
49 char user_agent[DEFAULT_BUFFER_SIZE];
50 char **http_opt_headers;
51 int http_opt_headers_count;
52 char *http_post_data;
53 int max_depth;
54 char *http_content_type;
55 long socket_timeout;
56 char user_auth[MAX_INPUT_BUFFER];
57 char proxy_auth[MAX_INPUT_BUFFER];
58 int followmethod;
59 int followsticky;
60 bool no_body;
61 int curl_http_version;
62 char *cookie_jar_file;
63
64 int maximum_age;
65 char regexp[MAX_RE_SIZE];
66 int state_regex;
67 bool invert_regex;
68 bool verify_peer_and_host;
69 bool check_cert;
70 bool continue_after_check_cert;
71 int days_till_exp_warn;
72 int days_till_exp_crit;
73 thresholds *thlds;
74 int min_page_len;
75 int max_page_len;
76 char server_expect[MAX_INPUT_BUFFER];
77 bool server_expect_yn;
78 char string_expect[MAX_INPUT_BUFFER];
79 char header_expect[MAX_INPUT_BUFFER];
80 int onredirect;
81
82 bool show_extended_perfdata;
83 bool show_body;
84 bool display_html;
85} check_curl_config;
86
87check_curl_config check_curl_config_init() {
88 check_curl_config tmp = {
89 .server_address = NULL,
90 .server_port = HTTP_PORT,
91 .virtual_port = 0,
92 .host_name = NULL,
93 .server_url = strdup(DEFAULT_SERVER_URL),
94
95 .automatic_decompression = false,
96 .haproxy_protocol = false,
97 .client_cert = NULL,
98 .client_privkey = NULL,
99 .ca_cert = NULL,
100 .use_ssl = false,
101 .ssl_version = CURL_SSLVERSION_DEFAULT,
102 .http_method = NULL,
103 .user_agent = {},
104 .http_opt_headers = NULL,
105 .http_opt_headers_count = 0,
106 .http_post_data = NULL,
107 .max_depth = DEFAULT_MAX_REDIRS,
108 .http_content_type = NULL,
109 .socket_timeout = DEFAULT_SOCKET_TIMEOUT,
110 .user_auth = "",
111 .proxy_auth = "",
112 .followmethod = FOLLOW_HTTP_CURL,
113 .followsticky = STICKY_NONE,
114 .no_body = false,
115 .curl_http_version = CURL_HTTP_VERSION_NONE,
116 .cookie_jar_file = NULL,
117
118 .maximum_age = -1,
119 .regexp = {},
120 .state_regex = STATE_CRITICAL,
121 .invert_regex = false,
122 .verify_peer_and_host = false,
123 .check_cert = false,
124 .continue_after_check_cert = false,
125 .days_till_exp_warn = 0,
126 .days_till_exp_crit = 0,
127 .thlds = NULL,
128 .min_page_len = 0,
129 .max_page_len = 0,
130 .server_expect = HTTP_EXPECT,
131 .server_expect_yn = false,
132 .string_expect = "",
133 .header_expect = "",
134 .onredirect = STATE_OK,
135
136 .show_extended_perfdata = false,
137 .show_body = false,
138 .display_html = false,
139 };
140 return tmp;
141}