diff options
author | Matthias Eble <psychotrahe@users.sourceforge.net> | 2012-04-10 22:49:24 +0200 |
---|---|---|
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | 2012-04-10 22:49:24 +0200 |
commit | 4c30935850997f513b3eee21d169f6d523d43c5d (patch) | |
tree | 09a14dfecd959e1b566b9df7b7fdb99f6bb4c5d8 /plugins | |
parent | 9978b3ca744b076d8ea24441819826938211dd17 (diff) | |
parent | 8c7e2b636c601dd05a6881c84cc95136ecf9323e (diff) | |
download | monitoring-plugins-4c30935850997f513b3eee21d169f6d523d43c5d.tar.gz |
Merge branch 'master' of ssh://nagiosplug.git.sourceforge.net/gitroot/nagiosplug/nagiosplug
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_by_ssh.c | 11 | ||||
-rw-r--r-- | plugins/check_http.c | 4 | ||||
-rw-r--r-- | plugins/check_radius.c | 2 | ||||
-rw-r--r-- | plugins/check_snmp.c | 20 | ||||
-rw-r--r-- | plugins/common.h | 6 | ||||
-rw-r--r-- | plugins/t/check_by_ssh.t | 13 |
6 files changed, 42 insertions, 14 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index ff27b396..87520166 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c @@ -187,6 +187,7 @@ process_arguments (int argc, char **argv) {"use-ipv6", no_argument, 0, '6'}, {"ssh-option", required_argument, 0, 'o'}, {"quiet", no_argument, 0, 'q'}, + {"configfile", optional_argument, 0, 'F'}, {0, 0, 0, 0} }; @@ -198,7 +199,7 @@ process_arguments (int argc, char **argv) strcpy (argv[c], "-t"); while (1) { - c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:", longopts, + c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts, &option); if (c == -1 || c == EOF) @@ -306,6 +307,10 @@ process_arguments (int argc, char **argv) case 'q': /* Tell the ssh command to be quiet */ comm_append("-q"); break; + case 'F': /* ssh configfile */ + comm_append("-F"); + comm_append(optarg); + break; default: /* help */ usage5(); } @@ -418,6 +423,8 @@ print_help (void) printf (" %s\n", _("short name of host in nagios configuration [optional]")); printf (" %s\n","-o, --ssh-option=OPTION"); printf (" %s\n", _("Call ssh with '-o OPTION' (may be used multiple times) [optional]")); + printf (" %s\n","-F, --configfile"); + printf (" %s\n", _("Tell ssh to use this configfile [optional]")); printf (" %s\n","-q, --quiet"); printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]")); printf (UT_WARN_CRIT); @@ -454,6 +461,6 @@ print_usage (void) printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" " [-S [lines]] [-E [lines]] [-t timeout] [-i identity]\n" " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" - " [-p port] [-o ssh-option]\n", + " [-p port] [-o ssh-option] [-F configfile]\n", progname); } diff --git a/plugins/check_http.c b/plugins/check_http.c index 433c28e3..3175f6cb 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -1400,6 +1400,10 @@ print_help (void) printf (" %s\n", _("serve content (optionally within a specified time) or whether the X509 ")); printf (" %s\n", _("certificate is still valid for the specified number of days.")); printf ("\n"); + printf (" %s\n", _("Please note that this plugin does not check if the presented server")); + printf (" %s\n", _("certificate matches the hostname of the server, or if the certificate")); + printf (" %s\n", _("has a valid chain of trust to one of the locally installed CAs.")); + printf ("\n"); printf ("%s\n", _("Examples:")); printf (" %s\n\n", "CHECK CONTENT: check_http -w 5 -c 10 --ssl -H www.verisign.com"); printf (" %s\n", _("When the 'www.verisign.com' server returns its content within 5 seconds,")); diff --git a/plugins/check_radius.c b/plugins/check_radius.c index 61d84fb8..c2c93eeb 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c @@ -211,7 +211,7 @@ main (int argc, char **argv) if (result == OK_RC) die (STATE_OK, _("Auth OK")); (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result); - die (STATE_UNKNOWN, msg); + die (STATE_UNKNOWN, "%s", msg); } diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index d79da8cf..4cd38051 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -740,7 +740,7 @@ process_arguments (int argc, char **argv) labels[nlabels - 1] = optarg; ptr = thisarg (optarg); labels[nlabels - 1] = ptr; - if (strstr (ptr, "'") == ptr) + if (ptr[0] == '\'') labels[nlabels - 1] = ptr + 1; while (ptr && (ptr = nextarg (ptr))) { if (nlabels >= labels_size) { @@ -749,9 +749,9 @@ process_arguments (int argc, char **argv) if (labels == NULL) die (STATE_UNKNOWN, _("Could not reallocate labels\n")); } - labels++; + nlabels++; ptr = thisarg (ptr); - if (strstr (ptr, "'") == ptr) + if (ptr[0] == '\'') labels[nlabels - 1] = ptr + 1; else labels[nlabels - 1] = ptr; @@ -769,7 +769,7 @@ process_arguments (int argc, char **argv) unitv[nunits - 1] = optarg; ptr = thisarg (optarg); unitv[nunits - 1] = ptr; - if (strstr (ptr, "'") == ptr) + if (ptr[0] == '\'') unitv[nunits - 1] = ptr + 1; while (ptr && (ptr = nextarg (ptr))) { if (nunits >= unitv_size) { @@ -780,7 +780,7 @@ process_arguments (int argc, char **argv) } nunits++; ptr = thisarg (ptr); - if (strstr (ptr, "'") == ptr) + if (ptr[0] == '\'') unitv[nunits - 1] = ptr + 1; else unitv[nunits - 1] = ptr; @@ -935,7 +935,7 @@ char * thisarg (char *str) { str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ - if (strstr (str, "'") == str) { /* handle SIMPLE quoted strings */ + if (str[0] == '\'') { /* handle SIMPLE quoted strings */ if (strlen (str) == 1 || !strstr (str + 1, "'")) die (STATE_UNKNOWN, _("Unbalanced quotes\n")); } @@ -951,7 +951,7 @@ thisarg (char *str) char * nextarg (char *str) { - if (strstr (str, "'") == str) { + if (str[0] == '\'') { str[0] = 0; if (strlen (str) > 1) { str = strstr (str + 1, "'"); @@ -961,7 +961,7 @@ nextarg (char *str) return NULL; } } - if (strstr (str, ",") == str) { + if (str[0] == ',') { str[0] = 0; if (strlen (str) > 1) { return (++str); @@ -1072,8 +1072,8 @@ print_help (void) printf ("\n"); printf ("%s\n", _("Notes:")); - printf (" %s\n", _("- Multiple OIDs may be indicated by a comma or space-delimited list (lists with")); - printf (" %s %i %s\n", _("internal spaces must be quoted). Maximum:"), MAX_OIDS, _("OIDs.")); + printf (" %s\n", _("- Multiple OIDs (and labels) may be indicated by a comma or space-delimited ")); + printf (" %s %i %s\n", _("list (lists with internal spaces must be quoted). Maximum:"), MAX_OIDS, _("OIDs.")); printf(" -%s", UT_THRESHOLDS_NOTES); diff --git a/plugins/common.h b/plugins/common.h index dfc09416..09af7e7e 100644 --- a/plugins/common.h +++ b/plugins/common.h @@ -59,6 +59,12 @@ #include <math.h> #endif +#ifdef _AIX +#ifdef HAVE_MP_H +#include <mp.h> +#endif +#endif + #ifdef HAVE_STRINGS_H #include <strings.h> #endif diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t index 5f2c534d..cca72c96 100644 --- a/plugins/t/check_by_ssh.t +++ b/plugins/t/check_by_ssh.t @@ -17,9 +17,14 @@ my $ssh_key = getTestParameter( "NP_SSH_IDENTITY", "A key allowing access to NP_SSH_HOST", "~/.ssh/id_dsa"); +my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE", + "A config file with ssh settings", + "~/.ssh/config"); + + plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key); -plan tests => 40; +plan tests => 42; # Some random check strings/response my @responce = ('OK: Everything is fine!', @@ -85,6 +90,12 @@ $result = NPTest->testCmd( cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); is($result->output, $responce[4], "Return proper status text even with unknown status codes"); +$result = NPTest->testCmd( + "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" + ); +cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); +is($result->output, 'OK - check_by_ssh: Remote command \'exit 0\' returned status 0', "Status text if command returned none (OK)"); + # Multiple active checks $result = NPTest->testCmd( "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[1]; sh -c exit\\ 1' -C '$check[0]; sh -c exit\\ 0' -C '$check[3]; sh -c exit\\ 3' -C '$check[2]; sh -c exit\\ 2'" |