1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
diff -ruN nagios-plugins-1.4.4.orig/plugins/check_ssh.c nagios-plugins-1.4.4/plugins/check_ssh.c
--- nagios-plugins-1.4.4.orig/plugins/check_ssh.c 2006-06-21 07:05:00.000000000 -0400
+++ nagios-plugins-1.4.4/plugins/check_ssh.c 2006-10-29 20:20:11.000000000 -0500
@@ -50,6 +50,7 @@
int port = -1;
char *server_name = NULL;
char *remote_version = NULL;
+char *parse_remote_version = NULL;
int verbose = FALSE;
int process_arguments (int, char **);
@@ -57,7 +58,7 @@
void print_help (void);
void print_usage (void);
-int ssh_connect (char *haddr, int hport, char *remote_version);
+int ssh_connect (char *haddr, int hport, char *remote_version, char *parse_remote_version);
@@ -79,7 +80,7 @@
alarm (socket_timeout);
/* ssh_connect exits if error is found */
- result = ssh_connect (server_name, port, remote_version);
+ result = ssh_connect (server_name, port, remote_version, parse_remote_version);
alarm (0);
@@ -105,6 +106,7 @@
{"timeout", required_argument, 0, 't'},
{"verbose", no_argument, 0, 'v'},
{"remote-version", required_argument, 0, 'r'},
+ {"parse-remote-version", required_argument, 0, 's'},
{0, 0, 0, 0}
};
@@ -116,7 +118,7 @@
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "+Vhv46t:r:H:p:", longopts, &option);
+ c = getopt_long (argc, argv, "+Vhv46t:r:s:H:p:", longopts, &option);
if (c == -1 || c == EOF)
break;
@@ -152,6 +154,9 @@
case 'r': /* remote version */
remote_version = optarg;
break;
+ case 's': /* remote version */
+ parse_remote_version = optarg;
+ break;
case 'H': /* host */
if (is_host (optarg) == FALSE)
usage2 (_("Invalid hostname/address"), optarg);
@@ -206,7 +211,7 @@
int
-ssh_connect (char *haddr, int hport, char *remote_version)
+ssh_connect (char *haddr, int hport, char *remote_version, char *parse_remote_version)
{
int sd;
int result;
@@ -248,6 +253,11 @@
(_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n"),
ssh_server, ssh_proto, remote_version);
exit (STATE_WARNING);
+ } else if (parse_remote_version && !strstr(parse_remote_version, ssh_server)) {
+ printf
+ (_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n"),
+ ssh_server, ssh_proto, parse_remote_version);
+ exit (STATE_WARNING);
}
printf
@@ -285,6 +295,9 @@
printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ printf (" %s\n", "-s, --parse-remote-version=STRING");
+ printf (" %s\n", _("Warn if STRING isnt in server version(ex: SSH)"));
+
printf (" %s\n", "-r, --remote-version=STRING");
printf (" %s\n", _("Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)"));
@@ -299,6 +312,6 @@
print_usage (void)
{
printf (_("Usage:"));
- printf ("%s [-46] [-t <timeout>] [-r <remote version>] [-p <port>] <host>\n", progname);
+ printf ("%s [-46] [-t <timeout>] [-r <remote version> | -s <remote string>] [-p <port>] <host>\n", progname);
}
|