summaryrefslogtreecommitdiffstats
path: root/plugins/check_by_ssh.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_by_ssh.c')
-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);