mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-05-28 04:35:40 -04:00
check_by_ssh: handle errrors of ssh (1) directly
This commit is contained in:
parent
e77ce530c4
commit
463223790c
1 changed files with 17 additions and 0 deletions
|
|
@ -100,10 +100,27 @@ int main(int argc, char **argv) {
|
|||
child_result.stderr.lines > 0 ? child_result.stderr.line[0]
|
||||
: "(no error output)");
|
||||
|
||||
sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN);
|
||||
mp_add_subcheck_to_check(&overall, sc_ssh_execution);
|
||||
mp_exit(overall);
|
||||
} else if (child_result.cmd_error_code != 0) {
|
||||
xasprintf(&sc_ssh_execution.output, "SSH connection failed: ");
|
||||
|
||||
if (child_result.stderr.lines > 0) {
|
||||
for (size_t i = 0; i < child_result.stderr.lines; i++) {
|
||||
xasprintf(&sc_ssh_execution.output, "%s\n%s", sc_ssh_execution.output,
|
||||
child_result.stderr.line[i]);
|
||||
}
|
||||
} else {
|
||||
xasprintf(&sc_ssh_execution.output, "%s %s", sc_ssh_execution.output,
|
||||
"no output on stderr");
|
||||
}
|
||||
|
||||
sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN);
|
||||
mp_add_subcheck_to_check(&overall, sc_ssh_execution);
|
||||
mp_exit(overall);
|
||||
}
|
||||
|
||||
xasprintf(&sc_ssh_execution.output, "SSH connection succeeded");
|
||||
sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_OK);
|
||||
mp_add_subcheck_to_check(&overall, sc_ssh_execution);
|
||||
|
|
|
|||
Loading…
Reference in a new issue