summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a2ff62c)
raw | patch | inline | side by side (parent: a2ff62c)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Sat, 21 Feb 2004 05:37:34 +0000 (05:37 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Sat, 21 Feb 2004 05:37:34 +0000 (05:37 +0000) |
(to suppress a login banner)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@823 f882894a-f735-0410-b71e-b25c423dba1c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@823 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_by_ssh.c | patch | blob | history |
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 560ae0c61d73298f05bcda96980b11d0c22d5fb9..0bce902f5d2ab96d7f924154f2451dba94eb90e2 100644 (file)
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
int commands = 0;
int services = 0;
+int skip_lines = 0;
char *remotecmd = NULL;
char *comm = NULL;
char *hostname = NULL;
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process))
asprintf (&result_text, "%s%s", result_text, input_buffer);
-
/* WARNING if output found on stderr */
- if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
- printf ("%s\n", input_buffer);
- while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process))
- printf ("%s\n", input_buffer);
- return STATE_WARNING;
+ while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
+ if (skip_lines > 0) {
+ if (input_buffer[strlen(input_buffer)-1] == '\n') {
+ skip_lines--;
+ }
+ } else {
+ printf ("%s", input_buffer);
+ result = STATE_WARNING;
+ }
}
(void) fclose (child_stderr);
+ if (result == STATE_WARNING)
+ return result;
/* close the pipe */
{"user", required_argument, 0, 'u'},
{"logname", required_argument, 0, 'l'},
{"command", required_argument, 0, 'C'},
+ {"skip", required_argument, 0, 'S'},
{"proto1", no_argument, 0, '1'},
{"proto2", no_argument, 0, '2'},
{"use-ipv4", no_argument, 0, '4'},
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "Vvh1246ft:H:O:p:i:u:l:C:n:s:", longopts,
+ c = getopt_long (argc, argv, "Vvh1246ft:H:O:p:i:u:l:C:S:n:s:", longopts,
&option);
if (c == -1 || c == EOF)
if (commands > 1)
asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
asprintf (&remotecmd, "%s%s", remotecmd, optarg);
+ break;
+ case 'S': /* Skip n lines in the output to ignore system banner */
+ if (!is_integer (optarg))
+ usage2 (_("skip lines must be an integer"), optarg);
+ else
+ skip_lines = atoi (optarg);
+ break;
}
}
tell ssh to use Protocol 1\n\
-2, --proto2\n\
tell ssh to use Protocol 2\n\
+ -S, --skiplines=n\n\
+ Ignore first n lines on STDERR (to suppress a logon banner)\n\
-f\n\
tells ssh to fork rather than create a tty\n"));