summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_by_ssh.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 8036ffa4..ebe54b80 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -94,8 +94,9 @@ int main(int argc, char **argv) {
94 mp_check overall = mp_check_init(); 94 mp_check overall = mp_check_init();
95 95
96 /* SSH returns 255 if connection attempt fails; include the first line of error output */ 96 /* SSH returns 255 if connection attempt fails; include the first line of error output */
97 mp_subcheck sc_ssh_execution = mp_subcheck_init(); 97 // we can sadly not detect other SSH errors
98 if (child_result.cmd_error_code == 255 && config.unknown_timeout) { 98 if (child_result.cmd_error_code == 255 && config.unknown_timeout) {
99 mp_subcheck sc_ssh_execution = mp_subcheck_init();
99 xasprintf(&sc_ssh_execution.output, "SSH connection failed: %s", 100 xasprintf(&sc_ssh_execution.output, "SSH connection failed: %s",
100 child_result.stderr.lines > 0 ? child_result.stderr.line[0] 101 child_result.stderr.lines > 0 ? child_result.stderr.line[0]
101 : "(no error output)"); 102 : "(no error output)");
@@ -103,28 +104,8 @@ int main(int argc, char **argv) {
103 sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN); 104 sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN);
104 mp_add_subcheck_to_check(&overall, sc_ssh_execution); 105 mp_add_subcheck_to_check(&overall, sc_ssh_execution);
105 mp_exit(overall); 106 mp_exit(overall);
106 } else if (child_result.cmd_error_code != 0) {
107 xasprintf(&sc_ssh_execution.output, "SSH connection failed: ");
108
109 if (child_result.stderr.lines > 0) {
110 for (size_t i = 0; i < child_result.stderr.lines; i++) {
111 xasprintf(&sc_ssh_execution.output, "%s\n%s", sc_ssh_execution.output,
112 child_result.stderr.line[i]);
113 }
114 } else {
115 xasprintf(&sc_ssh_execution.output, "%s %s", sc_ssh_execution.output,
116 "no output on stderr");
117 }
118
119 sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN);
120 mp_add_subcheck_to_check(&overall, sc_ssh_execution);
121 mp_exit(overall);
122 } 107 }
123 108
124 xasprintf(&sc_ssh_execution.output, "SSH connection succeeded");
125 sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_OK);
126 mp_add_subcheck_to_check(&overall, sc_ssh_execution);
127
128 if (verbose) { 109 if (verbose) {
129 for (size_t i = 0; i < child_result.stdout.lines; i++) { 110 for (size_t i = 0; i < child_result.stdout.lines; i++) {
130 printf("stdout: %s\n", child_result.stdout.line[i]); 111 printf("stdout: %s\n", child_result.stdout.line[i]);