summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2026-04-06 12:17:43 +0200
committerGitHub <noreply@github.com>2026-04-06 12:17:43 +0200
commit9980e788509af3203725cdcd15f517ad1ed503fb (patch)
tree51c65dfd829e56bab4ce8c942e958d04d332833f /plugins
parentc57381d789fb246602966fccfcb80131a7fb0461 (diff)
downloadmonitoring-plugins-9980e788509af3203725cdcd15f517ad1ed503fb.tar.gz
Add option to override output for check in lib for check_by_ssh (#2230)HEADmaster
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.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_by_ssh.c17
1 files changed, 15 insertions, 2 deletions
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";
41# define NP_MAXARGS 1024 41# define NP_MAXARGS 1024
42#endif 42#endif
43 43
44char *check_by_ssh_output_override(void *remote_output) { return ((char *)remote_output); }
45
44typedef struct { 46typedef struct {
45 int errorcode; 47 int errorcode;
46 check_by_ssh_config config; 48 check_by_ssh_config config;
@@ -155,10 +157,21 @@ int main(int argc, char **argv) {
155 xasprintf(&sc_active_check.output, "command stdout:"); 157 xasprintf(&sc_active_check.output, "command stdout:");
156 158
157 if (child_result.out.lines > skip_stdout) { 159 if (child_result.out.lines > skip_stdout) {
160
161 char *remote_command_output = NULL;
158 for (size_t i = skip_stdout; i < child_result.out.lines; i++) { 162 for (size_t i = skip_stdout; i < child_result.out.lines; i++) {
159 xasprintf(&sc_active_check.output, "%s\n%s", sc_active_check.output, 163 if (i == skip_stdout) {
160 child_result.out.line[i]); 164 // first iteration
165 xasprintf(&remote_command_output, "%s", child_result.out.line[i]);
166 } else {
167 xasprintf(&remote_command_output, "%s\n%s", remote_command_output,
168 child_result.out.line[i]);
169 }
161 } 170 }
171
172 sc_active_check.output = remote_command_output;
173 overall.default_output_override_content = remote_command_output;
174 overall.default_output_override = check_by_ssh_output_override;
162 } else { 175 } else {
163 xasprintf(&sc_active_check.output, "remote command '%s' returned status %d", 176 xasprintf(&sc_active_check.output, "remote command '%s' returned status %d",
164 config.remotecmd, child_result.cmd_error_code); 177 config.remotecmd, child_result.cmd_error_code);