summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2022-11-13 23:06:51 +0100
committerSven Nierlein <sven@nierlein.org>2023-01-07 18:34:46 +0100
commit2c658383d5c7742d289e07116c948c6905555405 (patch)
tree406d489ea7c798dc20d85cc64d87334fcf77bda4 /plugins
parentd4502f246f367af5e1d6b3944116f1d86beb5811 (diff)
downloadmonitoring-plugins-2c658383d5c7742d289e07116c948c6905555405.tar.gz
Restructure code a bit to put things where they are actually needed
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_http.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 859e3e35..a2c7571b 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -103,8 +103,6 @@ int server_expect_yn = 0;
103char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; 103char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
104char header_expect[MAX_INPUT_BUFFER] = ""; 104char header_expect[MAX_INPUT_BUFFER] = "";
105char string_expect[MAX_INPUT_BUFFER] = ""; 105char string_expect[MAX_INPUT_BUFFER] = "";
106char output_header_search[30] = "";
107char output_string_search[30] = "";
108char *warning_thresholds = NULL; 106char *warning_thresholds = NULL;
109char *critical_thresholds = NULL; 107char *critical_thresholds = NULL;
110thresholds *thlds; 108thresholds *thlds;
@@ -1236,8 +1234,10 @@ int check_http(void) {
1236 } 1234 }
1237 1235
1238 /* Page and Header content checks go here */ 1236 /* Page and Header content checks go here */
1239 if (strlen(header_expect)) { 1237 if (strlen(header_expect) > 0) {
1240 if (!strstr(header, header_expect)) { 1238 if (strstr(header, header_expect) == NULL) {
1239 // We did not find the header, the rest is for building the output and setting the state
1240 char output_header_search[30] = "";
1241 strncpy(&output_header_search[0], header_expect, 1241 strncpy(&output_header_search[0], header_expect,
1242 sizeof(output_header_search)); 1242 sizeof(output_header_search));
1243 if (output_header_search[sizeof(output_header_search) - 1] != '\0') { 1243 if (output_header_search[sizeof(output_header_search) - 1] != '\0') {
@@ -1254,6 +1254,8 @@ int check_http(void) {
1254 1254
1255 if (strlen(string_expect)) { 1255 if (strlen(string_expect)) {
1256 if (!strstr(page, string_expect)) { 1256 if (!strstr(page, string_expect)) {
1257 // We found the string the body, the rest is for building the output
1258 char output_string_search[30] = "";
1257 strncpy(&output_string_search[0], string_expect, 1259 strncpy(&output_string_search[0], string_expect,
1258 sizeof(output_string_search)); 1260 sizeof(output_string_search));
1259 if (output_string_search[sizeof(output_string_search) - 1] != '\0') { 1261 if (output_string_search[sizeof(output_string_search) - 1] != '\0') {
@@ -1268,7 +1270,7 @@ int check_http(void) {
1268 } 1270 }
1269 } 1271 }
1270 1272
1271 if (strlen(regexp)) { 1273 if (strlen(regexp) > 0) {
1272 errcode = regexec(&preg, page, REGS, pmatch, 0); 1274 errcode = regexec(&preg, page, REGS, pmatch, 0);
1273 if ((errcode == 0 && invert_regex == 0) || 1275 if ((errcode == 0 && invert_regex == 0) ||
1274 (errcode == REG_NOMATCH && invert_regex == 1)) { 1276 (errcode == REG_NOMATCH && invert_regex == 1)) {