diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index cffe810..c68b208 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -15,6 +15,7 @@ | |||
15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | 16 | ||
17 | ******************************************************************************/ | 17 | ******************************************************************************/ |
18 | /* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */ | ||
18 | 19 | ||
19 | const char *progname = "check_http"; | 20 | const char *progname = "check_http"; |
20 | const char *revision = "$Revision$"; | 21 | const char *revision = "$Revision$"; |
@@ -115,9 +116,10 @@ char buffer[MAX_INPUT_BUFFER]; | |||
115 | int process_arguments (int, char **); | 116 | int process_arguments (int, char **); |
116 | static char *base64 (const char *bin, size_t len); | 117 | static char *base64 (const char *bin, size_t len); |
117 | int check_http (void); | 118 | int check_http (void); |
118 | int redir (char *pos, char *status_line); | 119 | void redir (char *pos, char *status_line); |
119 | int server_type_check(const char *type); | 120 | int server_type_check(const char *type); |
120 | int server_port_check(int ssl_flag); | 121 | int server_port_check(int ssl_flag); |
122 | char *perfd_time (long microsec); | ||
121 | int my_recv (void); | 123 | int my_recv (void); |
122 | int my_close (void); | 124 | int my_close (void); |
123 | void print_help (void); | 125 | void print_help (void); |
@@ -669,10 +671,11 @@ check_http (void) | |||
669 | printf (_("CRITICAL")); | 671 | printf (_("CRITICAL")); |
670 | microsec = deltime (tv); | 672 | microsec = deltime (tv); |
671 | elapsed_time = (double)microsec / 1.0e6; | 673 | elapsed_time = (double)microsec / 1.0e6; |
672 | asprintf (&msg, _(" - %s - %.3f second response time %s%s|time=%ldus size=%dB\n"), | 674 | die (onredirect, |
673 | status_line, elapsed_time, timestamp, | 675 | _(" - %s - %.3f second response time %s%s|%s size=%dB\n"), |
674 | (display_html ? "</A>" : ""), microsec, pagesize); | 676 | status_line, elapsed_time, timestamp, |
675 | die (onredirect, "%s", msg); | 677 | (display_html ? "</A>" : ""), |
678 | perfd_time (microsec), pagesize); | ||
676 | } /* end if (strstr (status_line, "30[0-4]") */ | 679 | } /* end if (strstr (status_line, "30[0-4]") */ |
677 | 680 | ||
678 | 681 | ||
@@ -682,9 +685,11 @@ check_http (void) | |||
682 | /* check elapsed time */ | 685 | /* check elapsed time */ |
683 | microsec = deltime (tv); | 686 | microsec = deltime (tv); |
684 | elapsed_time = (double)microsec / 1.0e6; | 687 | elapsed_time = (double)microsec / 1.0e6; |
685 | asprintf (&msg, _("HTTP problem: %s - %.3f second response time %s%s|time=%ldus size=%dB\n"), | 688 | asprintf (&msg, |
686 | status_line, elapsed_time, timestamp, | 689 | _("HTTP problem: %s - %.3f second response time %s%s|%s size=%dB\n"), |
687 | (display_html ? "</A>" : ""), microsec, pagesize); | 690 | status_line, elapsed_time, timestamp, |
691 | (display_html ? "</A>" : ""), | ||
692 | perfd_time (microsec), pagesize); | ||
688 | if (check_critical_time == TRUE && elapsed_time > critical_time) | 693 | if (check_critical_time == TRUE && elapsed_time > critical_time) |
689 | die (STATE_CRITICAL, "%s", msg); | 694 | die (STATE_CRITICAL, "%s", msg); |
690 | if (check_warning_time == TRUE && elapsed_time > warning_time) | 695 | if (check_warning_time == TRUE && elapsed_time > warning_time) |
@@ -695,14 +700,16 @@ check_http (void) | |||
695 | 700 | ||
696 | if (strlen (string_expect)) { | 701 | if (strlen (string_expect)) { |
697 | if (strstr (page, string_expect)) { | 702 | if (strstr (page, string_expect)) { |
698 | printf (_("HTTP OK %s - %.3f second response time %s%s|time=%ldus size=%dB\n"), | 703 | printf (_("HTTP OK %s - %.3f second response time %s%s|%s size=%dB\n"), |
699 | status_line, elapsed_time, | 704 | status_line, elapsed_time, |
700 | timestamp, (display_html ? "</A>" : ""), microsec, pagesize); | 705 | timestamp, (display_html ? "</A>" : ""), |
706 | perfd_time (microsec), pagesize); | ||
701 | exit (STATE_OK); | 707 | exit (STATE_OK); |
702 | } | 708 | } |
703 | else { | 709 | else { |
704 | printf (_("CRITICAL - string not found%s|time=%ldus\n size=%dB"), | 710 | printf (_("CRITICAL - string not found%s|%s size=%dB\n"), |
705 | (display_html ? "</A>" : ""), microsec, pagesize); | 711 | (display_html ? "</A>" : ""), |
712 | perfd_time (microsec), pagesize); | ||
706 | exit (STATE_CRITICAL); | 713 | exit (STATE_CRITICAL); |
707 | } | 714 | } |
708 | } | 715 | } |
@@ -710,15 +717,17 @@ check_http (void) | |||
710 | if (strlen (regexp)) { | 717 | if (strlen (regexp)) { |
711 | errcode = regexec (&preg, page, REGS, pmatch, 0); | 718 | errcode = regexec (&preg, page, REGS, pmatch, 0); |
712 | if (errcode == 0) { | 719 | if (errcode == 0) { |
713 | printf (_("HTTP OK %s - %.3f second response time %s%s|time=%ldus size=%dB\n"), | 720 | printf (_("HTTP OK %s - %.3f second response time %s%s|%s size=%dB\n"), |
714 | status_line, elapsed_time, | 721 | status_line, elapsed_time, |
715 | timestamp, (display_html ? "</A>" : ""), microsec, pagesize); | 722 | timestamp, (display_html ? "</A>" : ""), |
723 | perfd_time (microsec), pagesize); | ||
716 | exit (STATE_OK); | 724 | exit (STATE_OK); |
717 | } | 725 | } |
718 | else { | 726 | else { |
719 | if (errcode == REG_NOMATCH) { | 727 | if (errcode == REG_NOMATCH) { |
720 | printf (_("CRITICAL - pattern not found%s|time=%ldus size=%dB\n"), | 728 | printf (_("CRITICAL - pattern not found%s|%s size=%dB\n"), |
721 | (display_html ? "</A>" : ""), microsec, pagesize); | 729 | (display_html ? "</A>" : ""), |
730 | perfd_time (microsec), pagesize); | ||
722 | exit (STATE_CRITICAL); | 731 | exit (STATE_CRITICAL); |
723 | } | 732 | } |
724 | else { | 733 | else { |
@@ -738,9 +747,10 @@ check_http (void) | |||
738 | exit (STATE_WARNING); | 747 | exit (STATE_WARNING); |
739 | } | 748 | } |
740 | /* We only get here if all tests have been passed */ | 749 | /* We only get here if all tests have been passed */ |
741 | asprintf (&msg, _("HTTP OK %s - %.3f second response time %s%s|time=%ldus size=%dB\n"), | 750 | asprintf (&msg, _("HTTP OK %s - %.3f second response time %s%s|%s size=%dB\n"), |
742 | status_line, elapsed_time, | 751 | status_line, elapsed_time, |
743 | timestamp, (display_html ? "</A>" : ""), microsec, pagesize); | 752 | timestamp, (display_html ? "</A>" : ""), |
753 | perfd_time (microsec), pagesize); | ||
744 | die (STATE_OK, "%s", msg); | 754 | die (STATE_OK, "%s", msg); |
745 | return STATE_UNKNOWN; | 755 | return STATE_UNKNOWN; |
746 | } | 756 | } |
@@ -760,7 +770,7 @@ check_http (void) | |||
760 | #define HD4 URI_HTTP URI_HOST | 770 | #define HD4 URI_HTTP URI_HOST |
761 | #define HD5 URI_PATH | 771 | #define HD5 URI_PATH |
762 | 772 | ||
763 | int | 773 | void |
764 | redir (char *pos, char *status_line) | 774 | redir (char *pos, char *status_line) |
765 | { | 775 | { |
766 | int i = 0; | 776 | int i = 0; |
@@ -873,7 +883,7 @@ redir (char *pos, char *status_line) | |||
873 | free (server_url); | 883 | free (server_url); |
874 | server_url = strdup (url); | 884 | server_url = strdup (url); |
875 | 885 | ||
876 | return check_http (); | 886 | check_http (); |
877 | } | 887 | } |
878 | 888 | ||
879 | 889 | ||
@@ -1027,6 +1037,14 @@ check_certificate (X509 ** certificate) | |||
1027 | 1037 | ||
1028 | 1038 | ||
1029 | 1039 | ||
1040 | char *perfd_time (long microsec) | ||
1041 | { | ||
1042 | perfdata ("time", microsec, "us", | ||
1043 | check_warning_time, (int)(1e6*warning_time), | ||
1044 | check_critical_time, (int)(1e6*critical_time), | ||
1045 | TRUE, 0, FALSE, 0); | ||
1046 | } | ||
1047 | |||
1030 | int | 1048 | int |
1031 | my_recv (void) | 1049 | my_recv (void) |
1032 | { | 1050 | { |