diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-11-16 14:52:07 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-11-16 14:52:07 +0100 |
| commit | 463223790cb67421d420ba982c1f5ee6cc6f2b4a (patch) | |
| tree | 41d658ef8957c6e04847e49655b202c79e5874ea /plugins/check_by_ssh.c | |
| parent | e77ce530c44178521b7e0c4012feed1e8006e41e (diff) | |
| download | monitoring-plugins-463223790cb67421d420ba982c1f5ee6cc6f2b4a.tar.gz | |
check_by_ssh: handle errrors of ssh (1) directly
Diffstat (limited to 'plugins/check_by_ssh.c')
| -rw-r--r-- | plugins/check_by_ssh.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index ad385fbd..8036ffa4 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
| @@ -103,7 +103,24 @@ int main(int argc, char **argv) { | |||
| 103 | sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN); | 103 | sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN); |
| 104 | mp_add_subcheck_to_check(&overall, sc_ssh_execution); | 104 | mp_add_subcheck_to_check(&overall, sc_ssh_execution); |
| 105 | mp_exit(overall); | 105 | 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); | ||
| 106 | } | 122 | } |
| 123 | |||
| 107 | xasprintf(&sc_ssh_execution.output, "SSH connection succeeded"); | 124 | xasprintf(&sc_ssh_execution.output, "SSH connection succeeded"); |
| 108 | sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_OK); | 125 | sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_OK); |
| 109 | mp_add_subcheck_to_check(&overall, sc_ssh_execution); | 126 | mp_add_subcheck_to_check(&overall, sc_ssh_execution); |
