summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_curl.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 57b6e12..12e0d0a 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -93,6 +93,7 @@ char *server_url = DEFAULT_SERVER_URL;
93unsigned short server_port = HTTP_PORT; 93unsigned short server_port = HTTP_PORT;
94int virtual_port = 0; 94int virtual_port = 0;
95int host_name_length; 95int host_name_length;
96char output_header_search[30] = "";
96char output_string_search[30] = ""; 97char output_string_search[30] = "";
97char *warning_thresholds = NULL; 98char *warning_thresholds = NULL;
98char *critical_thresholds = NULL; 99char *critical_thresholds = NULL;
@@ -122,6 +123,7 @@ CURLcode res;
122char url[DEFAULT_BUFFER_SIZE]; 123char url[DEFAULT_BUFFER_SIZE];
123char msg[DEFAULT_BUFFER_SIZE]; 124char msg[DEFAULT_BUFFER_SIZE];
124char perfstring[DEFAULT_BUFFER_SIZE]; 125char perfstring[DEFAULT_BUFFER_SIZE];
126char header_expect[MAX_INPUT_BUFFER] = "";
125char string_expect[MAX_INPUT_BUFFER] = ""; 127char string_expect[MAX_INPUT_BUFFER] = "";
126char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; 128char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
127int server_expect_yn = 0; 129int server_expect_yn = 0;
@@ -489,6 +491,18 @@ check_http (void)
489 } 491 }
490 492
491 /* Page and Header content checks go here */ 493 /* Page and Header content checks go here */
494
495 if (strlen (header_expect)) {
496 if (!strstr (header_buf.buf, header_expect)) {
497 strncpy(&output_header_search[0],header_expect,sizeof(output_header_search));
498 if(output_header_search[sizeof(output_header_search)-1]!='\0') {
499 bcopy("...",&output_header_search[sizeof(output_header_search)-4],4);
500 }
501 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
502 result = STATE_CRITICAL;
503 }
504 }
505
492 if (strlen (string_expect)) { 506 if (strlen (string_expect)) {
493 if (!strstr (body_buf.buf, string_expect)) { 507 if (!strstr (body_buf.buf, string_expect)) {
494 strncpy(&output_string_search[0],string_expect,sizeof(output_string_search)); 508 strncpy(&output_string_search[0],string_expect,sizeof(output_string_search));
@@ -592,6 +606,7 @@ process_arguments (int argc, char **argv)
592 {"url", required_argument, 0, 'u'}, 606 {"url", required_argument, 0, 'u'},
593 {"port", required_argument, 0, 'p'}, 607 {"port", required_argument, 0, 'p'},
594 {"authorization", required_argument, 0, 'a'}, 608 {"authorization", required_argument, 0, 'a'},
609 {"header-string", required_argument, 0, 'd'},
595 {"string", required_argument, 0, 's'}, 610 {"string", required_argument, 0, 's'},
596 {"expect", required_argument, 0, 'e'}, 611 {"expect", required_argument, 0, 'e'},
597 {"regex", required_argument, 0, 'r'}, 612 {"regex", required_argument, 0, 'r'},
@@ -631,7 +646,7 @@ process_arguments (int argc, char **argv)
631 } 646 }
632 647
633 while (1) { 648 while (1) {
634 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:j:I:a:p:e:s:R:r:u:f:C:J:K:S::m:NE", longopts, &option); 649 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:j:I:a:p:d:e:s:R:r:u:f:C:J:K:S::m:NE", longopts, &option);
635 if (c == -1 || c == EOF || c == 1) 650 if (c == -1 || c == EOF || c == 1)
636 break; 651 break;
637 652
@@ -797,6 +812,10 @@ process_arguments (int argc, char **argv)
797 if (verbose >= 2) 812 if (verbose >= 2)
798 printf(_("* Following redirects set to %s\n"), state_text(onredirect)); 813 printf(_("* Following redirects set to %s\n"), state_text(onredirect));
799 break; 814 break;
815 case 'd': /* string or substring */
816 strncpy (header_expect, optarg, MAX_INPUT_BUFFER - 1);
817 header_expect[MAX_INPUT_BUFFER - 1] = 0;
818 break;
800 case 's': /* string or substring */ 819 case 's': /* string or substring */
801 strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1); 820 strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1);
802 string_expect[MAX_INPUT_BUFFER - 1] = 0; 821 string_expect[MAX_INPUT_BUFFER - 1] = 0;
@@ -970,6 +989,8 @@ print_help (void)
970 printf (" %s", _("the first (status) line of the server response (default: ")); 989 printf (" %s", _("the first (status) line of the server response (default: "));
971 printf ("%s)\n", HTTP_EXPECT); 990 printf ("%s)\n", HTTP_EXPECT);
972 printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)")); 991 printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)"));
992 printf (" %s\n", "-d, --header-string=STRING");
993 printf (" %s\n", _("String to expect in the response headers"));
973 printf (" %s\n", "-s, --string=STRING"); 994 printf (" %s\n", "-s, --string=STRING");
974 printf (" %s\n", _("String to expect in the content")); 995 printf (" %s\n", _("String to expect in the content"));
975 printf (" %s\n", "-u, --url=PATH"); 996 printf (" %s\n", "-u, --url=PATH");
@@ -1065,7 +1086,7 @@ print_usage (void)
1065 printf (" [-J <client certificate file>] [-K <private key>] [--ca-cert <CA certificate file>]\n"); 1086 printf (" [-J <client certificate file>] [-K <private key>] [--ca-cert <CA certificate file>]\n");
1066 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-E] [-a auth]\n"); 1087 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-E] [-a auth]\n");
1067 printf (" [-f <ok|warning|critcal|follow>]\n"); 1088 printf (" [-f <ok|warning|critcal|follow>]\n");
1068 printf (" [-e <expect>] [-s string] [-r <regex> | -R <case-insensitive regex>]\n"); 1089 printf (" [-e <expect>] [-d string] [-s string] [-r <regex> | -R <case-insensitive regex>]\n");
1069 printf (" [-m <min_pg_size>:<max_pg_size>] [-N]\n"); 1090 printf (" [-m <min_pg_size>:<max_pg_size>] [-N]\n");
1070 printf (" [-4|-6] [-N]\n"); 1091 printf (" [-4|-6] [-N]\n");
1071 printf (" [-A string] [-k string] [-S <version>] [-C]\n"); 1092 printf (" [-A string] [-k string] [-S <version>] [-C]\n");