From f917244ab55917094bfe3bead0e905baad385821 Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Tue, 6 Sep 2011 23:20:21 -0400 Subject: Make GCC happy It won't trust us about msg containing no format string, and fail miserably when compiled with -Werror=format-security. Reported by spy6 on IRC. --- plugins/check_radius.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') 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); } -- cgit v1.2.3-74-g34f1 From 4011599466b8247ced0b6400b72e16620636d0fc Mon Sep 17 00:00:00 2001 From: Eric Stanley Date: Fri, 10 Feb 2012 10:27:24 -0600 Subject: Enable compiling on AIX 6.1 --- configure.in | 2 ++ plugins/common.h | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'plugins') diff --git a/configure.in b/configure.in index bdd44314..1d16bcd1 100644 --- a/configure.in +++ b/configure.in @@ -162,6 +162,8 @@ dnl dnl check for math-related functions needing -lm AC_CHECK_HEADERS(math.h) AC_CHECK_LIB(m,floor,MATHLIBS="-lm") +AC_CHECK_HEADERS(mp.h) +AC_CHECK_LIB(bsd,pow,MATHLIBS="$MATHLIBS -lbsd") AC_SUBST(MATHLIBS) dnl Check if we buils local libtap 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 #endif +#ifdef _AIX +#ifdef HAVE_MP_H +#include +#endif +#endif + #ifdef HAVE_STRINGS_H #include #endif -- cgit v1.2.3-74-g34f1 From 0e3fa54782f8cbb47af058c4bf13688e8b23865b Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Fri, 24 Feb 2012 12:29:00 +0100 Subject: Accept multiple labels specified with "-l" Fix the code which accepts a comma-separated list of labels specified via the "-l" option. (Spotted by Oskar Liljeblad in Debian bug report #647020, forwarded by Jan Wagner.) --- plugins/check_snmp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index d79da8cf..6c909093 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -749,7 +749,7 @@ 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) labels[nlabels - 1] = ptr + 1; @@ -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); -- cgit v1.2.3-74-g34f1 From b93c8eebc70153866d8c5a6872b6c7c4ccd94860 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Fri, 24 Feb 2012 12:31:20 +0100 Subject: Cosmetic change Replace all occurrences of "strstr(s, "c") == s" with "s[0] == 'c'". --- plugins/check_snmp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 6c909093..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) { @@ -751,7 +751,7 @@ process_arguments (int argc, char **argv) } 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); -- cgit v1.2.3-74-g34f1 From d796c16327e6e315dd528f17e8bd597c5f506730 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Fri, 24 Feb 2012 13:24:56 +0100 Subject: Clarify that check_http won't verify certificates Add a note to the --help output which clarifies that check_http doesn't perform certificate verification (beyond what the "-C" option does). (Suggested by Michael Renner in Debian bug report #644627, forwarded by Jan Wagner.) --- plugins/check_http.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins') 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,")); -- cgit v1.2.3-74-g34f1 From 83655083af68ddd87e5177f3dc4365b6d5721ed5 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Mon, 9 Apr 2012 22:12:21 +0200 Subject: check_by_ssh: added -F config file to specify alternative ssh config --- plugins/check_by_ssh.c | 11 +++++++++-- plugins/t/check_by_ssh.t | 13 ++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'plugins') 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 -C [-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/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'" -- cgit v1.2.3-74-g34f1