diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-09-09 15:12:03 +0200 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-09-09 15:12:03 +0200 |
commit | 40b062f1bd77d60279555a2f40f853d829b15db6 (patch) | |
tree | 9035e823af2622bb8f19340cd2169c7c679de744 /plugins/check_curl.d | |
parent | 94ae1eccbc35b6fdb5274dbb6b15f0479e68aeed (diff) | |
download | monitoring-plugins-40b062f1bd77d60279555a2f40f853d829b15db6.tar.gz |
check_curl: more refactoring
Diffstat (limited to 'plugins/check_curl.d')
-rw-r--r-- | plugins/check_curl.d/config.h | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/plugins/check_curl.d/config.h b/plugins/check_curl.d/config.h index 97fbcaab..9de68713 100644 --- a/plugins/check_curl.d/config.h +++ b/plugins/check_curl.d/config.h | |||
@@ -34,10 +34,37 @@ enum { | |||
34 | 34 | ||
35 | typedef struct { | 35 | typedef struct { |
36 | char *server_address; | 36 | char *server_address; |
37 | unsigned short server_port; | ||
38 | unsigned short virtual_port; | ||
39 | char *host_name; | ||
40 | char *server_url; | 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 | |||
51 | check_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 | |||
66 | typedef struct { | ||
67 | check_curl_working_state initial_config; | ||
41 | sa_family_t sin_family; | 68 | sa_family_t sin_family; |
42 | 69 | ||
43 | bool automatic_decompression; | 70 | bool automatic_decompression; |
@@ -45,13 +72,10 @@ typedef struct { | |||
45 | char *client_cert; | 72 | char *client_cert; |
46 | char *client_privkey; | 73 | char *client_privkey; |
47 | char *ca_cert; | 74 | char *ca_cert; |
48 | bool use_ssl; | ||
49 | int ssl_version; | 75 | int ssl_version; |
50 | char *http_method; | ||
51 | char user_agent[DEFAULT_BUFFER_SIZE]; | 76 | char user_agent[DEFAULT_BUFFER_SIZE]; |
52 | char **http_opt_headers; | 77 | char **http_opt_headers; |
53 | size_t http_opt_headers_count; | 78 | size_t http_opt_headers_count; |
54 | char *http_post_data; | ||
55 | int max_depth; | 79 | int max_depth; |
56 | char *http_content_type; | 80 | char *http_content_type; |
57 | long socket_timeout; | 81 | long socket_timeout; |
@@ -59,7 +83,6 @@ typedef struct { | |||
59 | char proxy_auth[MAX_INPUT_BUFFER]; | 83 | char proxy_auth[MAX_INPUT_BUFFER]; |
60 | int followmethod; | 84 | int followmethod; |
61 | int followsticky; | 85 | int followsticky; |
62 | bool no_body; | ||
63 | int curl_http_version; | 86 | int curl_http_version; |
64 | char *cookie_jar_file; | 87 | char *cookie_jar_file; |
65 | 88 | ||
@@ -88,11 +111,8 @@ typedef struct { | |||
88 | 111 | ||
89 | check_curl_config check_curl_config_init() { | 112 | check_curl_config check_curl_config_init() { |
90 | check_curl_config tmp = { | 113 | check_curl_config tmp = { |
91 | .server_address = NULL, | 114 | .initial_config = check_curl_working_state_init(), |
92 | .server_port = HTTP_PORT, | 115 | |
93 | .virtual_port = 0, | ||
94 | .host_name = NULL, | ||
95 | .server_url = strdup(DEFAULT_SERVER_URL), | ||
96 | .sin_family = AF_UNSPEC, | 116 | .sin_family = AF_UNSPEC, |
97 | 117 | ||
98 | .automatic_decompression = false, | 118 | .automatic_decompression = false, |
@@ -100,13 +120,10 @@ check_curl_config check_curl_config_init() { | |||
100 | .client_cert = NULL, | 120 | .client_cert = NULL, |
101 | .client_privkey = NULL, | 121 | .client_privkey = NULL, |
102 | .ca_cert = NULL, | 122 | .ca_cert = NULL, |
103 | .use_ssl = false, | ||
104 | .ssl_version = CURL_SSLVERSION_DEFAULT, | 123 | .ssl_version = CURL_SSLVERSION_DEFAULT, |
105 | .http_method = NULL, | ||
106 | .user_agent = {'\0'}, | 124 | .user_agent = {'\0'}, |
107 | .http_opt_headers = NULL, | 125 | .http_opt_headers = NULL, |
108 | .http_opt_headers_count = 0, | 126 | .http_opt_headers_count = 0, |
109 | .http_post_data = NULL, | ||
110 | .max_depth = DEFAULT_MAX_REDIRS, | 127 | .max_depth = DEFAULT_MAX_REDIRS, |
111 | .http_content_type = NULL, | 128 | .http_content_type = NULL, |
112 | .socket_timeout = DEFAULT_SOCKET_TIMEOUT, | 129 | .socket_timeout = DEFAULT_SOCKET_TIMEOUT, |
@@ -114,7 +131,6 @@ check_curl_config check_curl_config_init() { | |||
114 | .proxy_auth = "", | 131 | .proxy_auth = "", |
115 | .followmethod = FOLLOW_HTTP_CURL, | 132 | .followmethod = FOLLOW_HTTP_CURL, |
116 | .followsticky = STICKY_NONE, | 133 | .followsticky = STICKY_NONE, |
117 | .no_body = false, | ||
118 | .curl_http_version = CURL_HTTP_VERSION_NONE, | 134 | .curl_http_version = CURL_HTTP_VERSION_NONE, |
119 | .cookie_jar_file = NULL, | 135 | .cookie_jar_file = NULL, |
120 | 136 | ||