summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 741a64d)
raw | patch | inline | side by side (parent: 741a64d)
author | Matthew Kent <mattkent@users.sourceforge.net> | |
Sat, 27 Nov 2004 21:00:23 +0000 (21:00 +0000) | ||
committer | Matthew Kent <mattkent@users.sourceforge.net> | |
Sat, 27 Nov 2004 21:00:23 +0000 (21:00 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@945 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_ssh.c | patch | blob | history |
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index 6e0b0f17aef9c0c9debabe11355ff9fc52cdcdba..86267b29c85290804c65f5c9800f6e55e7392252 100644 (file)
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
int port = -1;
char *server_name = NULL;
+char *remote_version = NULL;
int verbose = FALSE;
int process_arguments (int, char **);
void print_help (void);
void print_usage (void);
-int ssh_connect (char *haddr, int hport);
+int ssh_connect (char *haddr, int hport, char *remote_version);
int
main (int argc, char **argv)
alarm (socket_timeout);
/* ssh_connect exits if error is found */
- result = ssh_connect (server_name, port);
+ result = ssh_connect (server_name, port, remote_version);
alarm (0);
{"use-ipv6", no_argument, 0, '6'},
{"timeout", required_argument, 0, 't'},
{"verbose", no_argument, 0, 'v'},
+ {"remote-version", required_argument, 0, 'r'},
{0, 0, 0, 0}
};
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "+Vhv46t:H:p:", longopts, &option);
+ c = getopt_long (argc, argv, "+Vhv46t:r:H:p:", longopts, &option);
if (c == -1 || c == EOF)
break;
case 'h': /* help */
print_help ();
exit (STATE_OK);
- case 'v': /* verose */
+ case 'v': /* verbose */
verbose = TRUE;
break;
case 't': /* timeout period */
usage (_("IPv6 support not available\n"));
#endif
break;
+ case 'r': /* remote version */
+ remote_version = optarg;
+ break;
case 'H': /* host */
if (is_host (optarg) == FALSE)
usage2 (_("Invalid host name/address"), optarg);
*-----------------------------------------------------------------------*/
int
-ssh_connect (char *haddr, int hport)
+ssh_connect (char *haddr, int hport, char *remote_version)
{
int sd;
int result;
ssh_proto = output + 4;
ssh_server = ssh_proto + strspn (ssh_proto, "-0123456789. ");
ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0;
- printf
- (_("SSH OK - %s (protocol %s)\n"),
- ssh_server, ssh_proto);
+
asprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, rev_no);
send (sd, buffer, strlen (buffer), MSG_DONTWAIT);
if (verbose)
printf ("%s\n", buffer);
+
+ if (remote_version && strcmp(remote_version, ssh_server)) {
+ printf
+ (_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n"),
+ ssh_server, ssh_proto, remote_version);
+ exit (STATE_WARNING);
+ }
+
+ printf
+ (_("SSH OK - %s (protocol %s)\n"),
+ ssh_server, ssh_proto);
exit (STATE_OK);
}
}
printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ printf (_("\
+ -r, --remote-version=STRING\n\
+ Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)\n"));
+
printf (_(UT_VERBOSE));
printf (_(UT_SUPPORT));
print_usage (void)
{
printf (_("\
-Usage: %s [-46] [-t <timeout>] [-p <port>] <host>\n"), progname);
+Usage: %s [-46] [-t <timeout>] [-r <remote version>] [-p <port>] <host>\n"), progname);
printf (_(UT_HLP_VRS), progname, progname);
}