From 3cbd84ce754b1f7ce1ac8f9bc46059da62392ffe Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 25 Feb 2025 16:35:51 +0100 Subject: Switch timeout handler to new output infrastructure --- plugins/netutils.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/netutils.c b/plugins/netutils.c index f5df7f3d..e2916c65 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c @@ -28,6 +28,8 @@ *****************************************************************************/ #include "common.h" +#include "output.h" +#include "states.h" #include "netutils.h" unsigned int socket_timeout = DEFAULT_SOCKET_TIMEOUT; @@ -43,13 +45,19 @@ int address_family = AF_INET; /* handles socket timeouts */ void socket_timeout_alarm_handler(int sig) { + mp_subcheck timeout_sc = mp_subcheck_init(); + timeout_sc = mp_set_subcheck_state(timeout_sc, socket_timeout_state); + if (sig == SIGALRM) { - printf(_("%s - Socket timeout after %d seconds\n"), state_text(socket_timeout_state), socket_timeout); + xasprintf(&timeout_sc.output, _("Socket timeout after %d seconds\n"), socket_timeout); } else { - printf(_("%s - Abnormal timeout after %d seconds\n"), state_text(socket_timeout_state), socket_timeout); + xasprintf(&timeout_sc.output, _("Abnormal timeout after %d seconds\n"), socket_timeout); } - exit(socket_timeout_state); + mp_check overall = mp_check_init(); + mp_add_subcheck_to_check(&overall, timeout_sc); + + mp_exit(overall); } /* connects to a host on a specified tcp port, sends a string, and gets a -- cgit v1.2.3-74-g34f1