From 554bf3e5256f5489aed0cd56f0c600bcb281a7f5 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 4 Mar 2025 11:02:33 +0100 Subject: Refactor check_tcp and implement new output format --- plugins/check_tcp.d/config.h | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 plugins/check_tcp.d/config.h (limited to 'plugins/check_tcp.d/config.h') diff --git a/plugins/check_tcp.d/config.h b/plugins/check_tcp.d/config.h new file mode 100644 index 00000000..7ecf51a6 --- /dev/null +++ b/plugins/check_tcp.d/config.h @@ -0,0 +1,78 @@ +#pragma once + +#include "../common.h" +#include "../../lib/utils_tcp.h" +#include + +typedef struct check_tcp_config { + char *server_address; + bool host_specified; + int server_port; // TODO can this be a uint16? + + int protocol; /* most common is default */ + char *service; + char *send; + char *quit; + char **server_expect; + size_t server_expect_count; +#ifdef HAVE_SSL + bool use_tls; + char *sni; + bool sni_specified; + bool check_cert; + int days_till_exp_warn; + int days_till_exp_crit; +#endif // HAVE_SSL + int match_flags; + int expect_mismatch_state; + unsigned int delay; + + bool warning_time_set; + double warning_time; + bool critical_time_set; + double critical_time; + + int econn_refuse_state; + + ssize_t maxbytes; + + bool hide_output; +} check_tcp_config; + +check_tcp_config check_tcp_config_init() { + check_tcp_config result = { + .server_address = "127.0.0.1", + .host_specified = false, + .server_port = 0, + + .protocol = IPPROTO_TCP, + .service = "TCP", + .send = NULL, + .quit = NULL, + .server_expect = NULL, + .server_expect_count = 0, +#ifdef HAVE_SSL + .use_tls = false, + .sni = NULL, + .sni_specified = false, + .check_cert = false, + .days_till_exp_warn = 0, + .days_till_exp_crit = 0, +#endif // HAVE_SSL + .match_flags = NP_MATCH_EXACT, + .expect_mismatch_state = STATE_WARNING, + .delay = 0, + + .warning_time_set = false, + .warning_time = 0, + .critical_time_set = false, + .critical_time = 0, + + .econn_refuse_state = STATE_CRITICAL, + + .maxbytes = 0, + + .hide_output = false, + }; + return result; +} -- cgit v1.2.3-74-g34f1