[monitoring-plugins] check_by_ssh: print command output in verbose mode
Sven Nierlein
git at monitoring-plugins.org
Mon Nov 7 22:00:15 CET 2016
Module: monitoring-plugins
Branch: master
Commit: 3a12034805caf6c4ad21a8f86c8e4a43ff62576c
Author: Sven Nierlein <sven at nierlein.de>
Date: Thu Mar 10 21:33:49 2016 +0100
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=3a12034
check_by_ssh: print command output in verbose mode
right now it is not possible to print the command output of ssh. check_by_ssh
only prints the command itself. This patchs adds printing the output too. This
makes it possible to use ssh with verbose logging which helps debuging any
connection, key or other ssh problems.
Note: you must use -E,--skip-stderr=<high number>, otherwise check_by_ssh would
always exit with unknown state.
Example:
./check_by_ssh -H localhost -o LogLevel=DEBUG3 -C "sleep 1" -E 999 -v
Signed-off-by: Sven Nierlein <sven at nierlein.de>
---
plugins/check_by_ssh.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 04bce38..13d8bc3 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -100,6 +100,13 @@ main (int argc, char **argv)
result = cmd_run_array (commargv, &chld_out, &chld_err, 0);
+ if (verbose) {
+ for(i = 0; i < chld_out.lines; i++)
+ printf("stdout: %s\n", chld_out.line[i]);
+ for(i = 0; i < chld_err.lines; i++)
+ printf("stderr: %s\n", chld_err.line[i]);
+ }
+
if (skip_stdout == -1) /* --skip-stdout specified without argument */
skip_stdout = chld_out.lines;
if (skip_stderr == -1) /* --skip-stderr specified without argument */
More information about the Commits
mailing list