Imported Upstream version 2.0
This commit is contained in:
parent
c89ccc3c74
commit
0841b5c7c7
165 changed files with 25440 additions and 4442 deletions
|
@ -1,9 +1,9 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* Nagios check_ssh plugin
|
||||
* Monitoring check_ssh plugin
|
||||
*
|
||||
* License: GPL
|
||||
* Copyright (c) 2000-2007 Nagios Plugins Development Team
|
||||
* Copyright (c) 2000-2007 Monitoring Plugins Development Team
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
|
@ -30,7 +30,7 @@
|
|||
|
||||
const char *progname = "check_ssh";
|
||||
const char *copyright = "2000-2007";
|
||||
const char *email = "nagiosplug-devel@lists.sourceforge.net";
|
||||
const char *email = "devel@monitoring-plugins.org";
|
||||
|
||||
#include "common.h"
|
||||
#include "netutils.h"
|
||||
|
@ -46,6 +46,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
|
|||
int port = -1;
|
||||
char *server_name = NULL;
|
||||
char *remote_version = NULL;
|
||||
char *remote_protocol = NULL;
|
||||
int verbose = FALSE;
|
||||
|
||||
int process_arguments (int, char **);
|
||||
|
@ -53,7 +54,7 @@ int validate_arguments (void);
|
|||
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 *remote_protocol);
|
||||
|
||||
|
||||
|
||||
|
@ -78,7 +79,7 @@ main (int argc, char **argv)
|
|||
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, remote_protocol);
|
||||
|
||||
alarm (0);
|
||||
|
||||
|
@ -105,6 +106,7 @@ process_arguments (int argc, char **argv)
|
|||
{"timeout", required_argument, 0, 't'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"remote-version", required_argument, 0, 'r'},
|
||||
{"remote-protcol", required_argument, 0, 'P'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -116,7 +118,7 @@ process_arguments (int argc, char **argv)
|
|||
strcpy (argv[c], "-t");
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "+Vhv46t:r:H:p:", longopts, &option);
|
||||
c = getopt_long (argc, argv, "+Vhv46t:r:H:p:P:", longopts, &option);
|
||||
|
||||
if (c == -1 || c == EOF)
|
||||
break;
|
||||
|
@ -152,6 +154,9 @@ process_arguments (int argc, char **argv)
|
|||
case 'r': /* remote version */
|
||||
remote_version = optarg;
|
||||
break;
|
||||
case 'P': /* remote version */
|
||||
remote_protocol = optarg;
|
||||
break;
|
||||
case 'H': /* host */
|
||||
if (is_host (optarg) == FALSE)
|
||||
usage2 (_("Invalid hostname/address"), optarg);
|
||||
|
@ -206,7 +211,7 @@ validate_arguments (void)
|
|||
|
||||
|
||||
int
|
||||
ssh_connect (char *haddr, int hport, char *remote_version)
|
||||
ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol)
|
||||
{
|
||||
int sd;
|
||||
int result;
|
||||
|
@ -254,6 +259,14 @@ ssh_connect (char *haddr, int hport, char *remote_version)
|
|||
exit (STATE_WARNING);
|
||||
}
|
||||
|
||||
if (remote_protocol && strcmp(remote_protocol, ssh_proto)) {
|
||||
printf
|
||||
(_("SSH WARNING - %s (protocol %s) protocol version mismatch, expected '%s'\n"),
|
||||
ssh_server, ssh_proto, remote_protocol);
|
||||
close(sd);
|
||||
exit (STATE_WARNING);
|
||||
}
|
||||
|
||||
elapsed_time = (double)deltime(tv) / 1.0e6;
|
||||
|
||||
printf
|
||||
|
@ -291,11 +304,14 @@ print_help (void)
|
|||
|
||||
printf (UT_IPv46);
|
||||
|
||||
printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
|
||||
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
|
||||
|
||||
printf (" %s\n", "-r, --remote-version=STRING");
|
||||
printf (" %s\n", _("Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)"));
|
||||
|
||||
printf (" %s\n", "-P, --remote-protocol=STRING");
|
||||
printf (" %s\n", _("Warn if protocol doesn't match expected protocol version (ex: 2.0)"));
|
||||
|
||||
printf (UT_VERBOSE);
|
||||
|
||||
printf (UT_SUPPORT);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue