summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_by_ssh.c11
-rw-r--r--plugins/check_http.c4
-rw-r--r--plugins/check_radius.c2
-rw-r--r--plugins/check_snmp.c20
-rw-r--r--plugins/common.h6
-rw-r--r--plugins/t/check_by_ssh.t13
6 files changed, 42 insertions, 14 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index ff27b39..8752016 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -187,6 +187,7 @@ process_arguments (int argc, char **argv)
187 {"use-ipv6", no_argument, 0, '6'}, 187 {"use-ipv6", no_argument, 0, '6'},
188 {"ssh-option", required_argument, 0, 'o'}, 188 {"ssh-option", required_argument, 0, 'o'},
189 {"quiet", no_argument, 0, 'q'}, 189 {"quiet", no_argument, 0, 'q'},
190 {"configfile", optional_argument, 0, 'F'},
190 {0, 0, 0, 0} 191 {0, 0, 0, 0}
191 }; 192 };
192 193
@@ -198,7 +199,7 @@ process_arguments (int argc, char **argv)
198 strcpy (argv[c], "-t"); 199 strcpy (argv[c], "-t");
199 200
200 while (1) { 201 while (1) {
201 c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:", longopts, 202 c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts,
202 &option); 203 &option);
203 204
204 if (c == -1 || c == EOF) 205 if (c == -1 || c == EOF)
@@ -306,6 +307,10 @@ process_arguments (int argc, char **argv)
306 case 'q': /* Tell the ssh command to be quiet */ 307 case 'q': /* Tell the ssh command to be quiet */
307 comm_append("-q"); 308 comm_append("-q");
308 break; 309 break;
310 case 'F': /* ssh configfile */
311 comm_append("-F");
312 comm_append(optarg);
313 break;
309 default: /* help */ 314 default: /* help */
310 usage5(); 315 usage5();
311 } 316 }
@@ -418,6 +423,8 @@ print_help (void)
418 printf (" %s\n", _("short name of host in nagios configuration [optional]")); 423 printf (" %s\n", _("short name of host in nagios configuration [optional]"));
419 printf (" %s\n","-o, --ssh-option=OPTION"); 424 printf (" %s\n","-o, --ssh-option=OPTION");
420 printf (" %s\n", _("Call ssh with '-o OPTION' (may be used multiple times) [optional]")); 425 printf (" %s\n", _("Call ssh with '-o OPTION' (may be used multiple times) [optional]"));
426 printf (" %s\n","-F, --configfile");
427 printf (" %s\n", _("Tell ssh to use this configfile [optional]"));
421 printf (" %s\n","-q, --quiet"); 428 printf (" %s\n","-q, --quiet");
422 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]")); 429 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]"));
423 printf (UT_WARN_CRIT); 430 printf (UT_WARN_CRIT);
@@ -454,6 +461,6 @@ print_usage (void)
454 printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" 461 printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n"
455 " [-S [lines]] [-E [lines]] [-t timeout] [-i identity]\n" 462 " [-S [lines]] [-E [lines]] [-t timeout] [-i identity]\n"
456 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" 463 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n"
457 " [-p port] [-o ssh-option]\n", 464 " [-p port] [-o ssh-option] [-F configfile]\n",
458 progname); 465 progname);
459} 466}
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 433c28e..3175f6c 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1400,6 +1400,10 @@ print_help (void)
1400 printf (" %s\n", _("serve content (optionally within a specified time) or whether the X509 ")); 1400 printf (" %s\n", _("serve content (optionally within a specified time) or whether the X509 "));
1401 printf (" %s\n", _("certificate is still valid for the specified number of days.")); 1401 printf (" %s\n", _("certificate is still valid for the specified number of days."));
1402 printf ("\n"); 1402 printf ("\n");
1403 printf (" %s\n", _("Please note that this plugin does not check if the presented server"));
1404 printf (" %s\n", _("certificate matches the hostname of the server, or if the certificate"));
1405 printf (" %s\n", _("has a valid chain of trust to one of the locally installed CAs."));
1406 printf ("\n");
1403 printf ("%s\n", _("Examples:")); 1407 printf ("%s\n", _("Examples:"));
1404 printf (" %s\n\n", "CHECK CONTENT: check_http -w 5 -c 10 --ssl -H www.verisign.com"); 1408 printf (" %s\n\n", "CHECK CONTENT: check_http -w 5 -c 10 --ssl -H www.verisign.com");
1405 printf (" %s\n", _("When the 'www.verisign.com' server returns its content within 5 seconds,")); 1409 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 61d84fb..c2c93ee 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -211,7 +211,7 @@ main (int argc, char **argv)
211 if (result == OK_RC) 211 if (result == OK_RC)
212 die (STATE_OK, _("Auth OK")); 212 die (STATE_OK, _("Auth OK"));
213 (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result); 213 (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result);
214 die (STATE_UNKNOWN, msg); 214 die (STATE_UNKNOWN, "%s", msg);
215} 215}
216 216
217 217
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index d79da8c..4cd3805 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -740,7 +740,7 @@ process_arguments (int argc, char **argv)
740 labels[nlabels - 1] = optarg; 740 labels[nlabels - 1] = optarg;
741 ptr = thisarg (optarg); 741 ptr = thisarg (optarg);
742 labels[nlabels - 1] = ptr; 742 labels[nlabels - 1] = ptr;
743 if (strstr (ptr, "'") == ptr) 743 if (ptr[0] == '\'')
744 labels[nlabels - 1] = ptr + 1; 744 labels[nlabels - 1] = ptr + 1;
745 while (ptr && (ptr = nextarg (ptr))) { 745 while (ptr && (ptr = nextarg (ptr))) {
746 if (nlabels >= labels_size) { 746 if (nlabels >= labels_size) {
@@ -749,9 +749,9 @@ process_arguments (int argc, char **argv)
749 if (labels == NULL) 749 if (labels == NULL)
750 die (STATE_UNKNOWN, _("Could not reallocate labels\n")); 750 die (STATE_UNKNOWN, _("Could not reallocate labels\n"));
751 } 751 }
752 labels++; 752 nlabels++;
753 ptr = thisarg (ptr); 753 ptr = thisarg (ptr);
754 if (strstr (ptr, "'") == ptr) 754 if (ptr[0] == '\'')
755 labels[nlabels - 1] = ptr + 1; 755 labels[nlabels - 1] = ptr + 1;
756 else 756 else
757 labels[nlabels - 1] = ptr; 757 labels[nlabels - 1] = ptr;
@@ -769,7 +769,7 @@ process_arguments (int argc, char **argv)
769 unitv[nunits - 1] = optarg; 769 unitv[nunits - 1] = optarg;
770 ptr = thisarg (optarg); 770 ptr = thisarg (optarg);
771 unitv[nunits - 1] = ptr; 771 unitv[nunits - 1] = ptr;
772 if (strstr (ptr, "'") == ptr) 772 if (ptr[0] == '\'')
773 unitv[nunits - 1] = ptr + 1; 773 unitv[nunits - 1] = ptr + 1;
774 while (ptr && (ptr = nextarg (ptr))) { 774 while (ptr && (ptr = nextarg (ptr))) {
775 if (nunits >= unitv_size) { 775 if (nunits >= unitv_size) {
@@ -780,7 +780,7 @@ process_arguments (int argc, char **argv)
780 } 780 }
781 nunits++; 781 nunits++;
782 ptr = thisarg (ptr); 782 ptr = thisarg (ptr);
783 if (strstr (ptr, "'") == ptr) 783 if (ptr[0] == '\'')
784 unitv[nunits - 1] = ptr + 1; 784 unitv[nunits - 1] = ptr + 1;
785 else 785 else
786 unitv[nunits - 1] = ptr; 786 unitv[nunits - 1] = ptr;
@@ -935,7 +935,7 @@ char *
935thisarg (char *str) 935thisarg (char *str)
936{ 936{
937 str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ 937 str += strspn (str, " \t\r\n"); /* trim any leading whitespace */
938 if (strstr (str, "'") == str) { /* handle SIMPLE quoted strings */ 938 if (str[0] == '\'') { /* handle SIMPLE quoted strings */
939 if (strlen (str) == 1 || !strstr (str + 1, "'")) 939 if (strlen (str) == 1 || !strstr (str + 1, "'"))
940 die (STATE_UNKNOWN, _("Unbalanced quotes\n")); 940 die (STATE_UNKNOWN, _("Unbalanced quotes\n"));
941 } 941 }
@@ -951,7 +951,7 @@ thisarg (char *str)
951char * 951char *
952nextarg (char *str) 952nextarg (char *str)
953{ 953{
954 if (strstr (str, "'") == str) { 954 if (str[0] == '\'') {
955 str[0] = 0; 955 str[0] = 0;
956 if (strlen (str) > 1) { 956 if (strlen (str) > 1) {
957 str = strstr (str + 1, "'"); 957 str = strstr (str + 1, "'");
@@ -961,7 +961,7 @@ nextarg (char *str)
961 return NULL; 961 return NULL;
962 } 962 }
963 } 963 }
964 if (strstr (str, ",") == str) { 964 if (str[0] == ',') {
965 str[0] = 0; 965 str[0] = 0;
966 if (strlen (str) > 1) { 966 if (strlen (str) > 1) {
967 return (++str); 967 return (++str);
@@ -1072,8 +1072,8 @@ print_help (void)
1072 1072
1073 printf ("\n"); 1073 printf ("\n");
1074 printf ("%s\n", _("Notes:")); 1074 printf ("%s\n", _("Notes:"));
1075 printf (" %s\n", _("- Multiple OIDs may be indicated by a comma or space-delimited list (lists with")); 1075 printf (" %s\n", _("- Multiple OIDs (and labels) may be indicated by a comma or space-delimited "));
1076 printf (" %s %i %s\n", _("internal spaces must be quoted). Maximum:"), MAX_OIDS, _("OIDs.")); 1076 printf (" %s %i %s\n", _("list (lists with internal spaces must be quoted). Maximum:"), MAX_OIDS, _("OIDs."));
1077 1077
1078 printf(" -%s", UT_THRESHOLDS_NOTES); 1078 printf(" -%s", UT_THRESHOLDS_NOTES);
1079 1079
diff --git a/plugins/common.h b/plugins/common.h
index dfc0941..09af7e7 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -59,6 +59,12 @@
59#include <math.h> 59#include <math.h>
60#endif 60#endif
61 61
62#ifdef _AIX
63#ifdef HAVE_MP_H
64#include <mp.h>
65#endif
66#endif
67
62#ifdef HAVE_STRINGS_H 68#ifdef HAVE_STRINGS_H
63#include <strings.h> 69#include <strings.h>
64#endif 70#endif
diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t
index 5f2c534..cca72c9 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",
17 "A key allowing access to NP_SSH_HOST", 17 "A key allowing access to NP_SSH_HOST",
18 "~/.ssh/id_dsa"); 18 "~/.ssh/id_dsa");
19 19
20my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE",
21 "A config file with ssh settings",
22 "~/.ssh/config");
23
24
20plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key); 25plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key);
21 26
22plan tests => 40; 27plan tests => 42;
23 28
24# Some random check strings/response 29# Some random check strings/response
25my @responce = ('OK: Everything is fine!', 30my @responce = ('OK: Everything is fine!',
@@ -85,6 +90,12 @@ $result = NPTest->testCmd(
85cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); 90cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)");
86is($result->output, $responce[4], "Return proper status text even with unknown status codes"); 91is($result->output, $responce[4], "Return proper status text even with unknown status codes");
87 92
93$result = NPTest->testCmd(
94 "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'"
95 );
96cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
97is($result->output, 'OK - check_by_ssh: Remote command \'exit 0\' returned status 0', "Status text if command returned none (OK)");
98
88# Multiple active checks 99# Multiple active checks
89$result = NPTest->testCmd( 100$result = NPTest->testCmd(
90 "./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'" 101 "./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'"