From 9980e788509af3203725cdcd15f517ad1ed503fb Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Mon, 6 Apr 2026 12:17:43 +0200 Subject: Add option to override output for check in lib for check_by_ssh (#2230) The new output functionality was discussed in the context of check_by_ssh, where it mostly adds more stuff which was seen as not inherently usefull as a succesful check_by_ssh check might as well be transparent. --- plugins/check_by_ssh.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 7ffa0ded..4d0c8e7d 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c @@ -41,6 +41,8 @@ const char *email = "devel@monitoring-plugins.org"; # define NP_MAXARGS 1024 #endif +char *check_by_ssh_output_override(void *remote_output) { return ((char *)remote_output); } + typedef struct { int errorcode; check_by_ssh_config config; @@ -155,10 +157,21 @@ int main(int argc, char **argv) { xasprintf(&sc_active_check.output, "command stdout:"); if (child_result.out.lines > skip_stdout) { + + char *remote_command_output = NULL; for (size_t i = skip_stdout; i < child_result.out.lines; i++) { - xasprintf(&sc_active_check.output, "%s\n%s", sc_active_check.output, - child_result.out.line[i]); + if (i == skip_stdout) { + // first iteration + xasprintf(&remote_command_output, "%s", child_result.out.line[i]); + } else { + xasprintf(&remote_command_output, "%s\n%s", remote_command_output, + child_result.out.line[i]); + } } + + sc_active_check.output = remote_command_output; + overall.default_output_override_content = remote_command_output; + overall.default_output_override = check_by_ssh_output_override; } else { xasprintf(&sc_active_check.output, "remote command '%s' returned status %d", config.remotecmd, child_result.cmd_error_code); -- cgit v1.2.3-74-g34f1