diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | THANKS.in | 1 | ||||
-rw-r--r-- | plugins/check_http.c | 56 | ||||
-rw-r--r-- | plugins/t/check_http.t | 23 |
4 files changed, 45 insertions, 36 deletions
@@ -13,6 +13,7 @@ This file documents the major additions and syntax changes between releases. | |||
13 | Allow for building the plugins in parallel | 13 | Allow for building the plugins in parallel |
14 | Add --without-{dbi,ldap,radius} options to ./configure | 14 | Add --without-{dbi,ldap,radius} options to ./configure |
15 | Made Verbose output of check_sensors compliant (Gabriele Tozzi) | 15 | Made Verbose output of check_sensors compliant (Gabriele Tozzi) |
16 | New switch -E/--extended-perfdata for check_http to print additional performance data (Sebastian Nohn) | ||
16 | 17 | ||
17 | FIXES | 18 | FIXES |
18 | Change the MAIL FROM command generated by check_smtp to be RFC compliant | 19 | Change the MAIL FROM command generated by check_smtp to be RFC compliant |
@@ -284,3 +284,4 @@ Vaclav Ovsik | |||
284 | Roman Fiedler | 284 | Roman Fiedler |
285 | Fabio Rueda | 285 | Fabio Rueda |
286 | Gabriele Tozzi | 286 | Gabriele Tozzi |
287 | Sebastian Nohn | ||
diff --git a/plugins/check_http.c b/plugins/check_http.c index ce26ff42..6db38e8c 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -1,34 +1,34 @@ | |||
1 | /***************************************************************************** | 1 | /***************************************************************************** |
2 | * | 2 | * |
3 | * Nagios check_http plugin | 3 | * Nagios check_http plugin |
4 | * | 4 | * |
5 | * License: GPL | 5 | * License: GPL |
6 | * Copyright (c) 1999-2013 Nagios Plugins Development Team | 6 | * Copyright (c) 1999-2013 Nagios Plugins Development Team |
7 | * | 7 | * |
8 | * Description: | 8 | * Description: |
9 | * | 9 | * |
10 | * This file contains the check_http plugin | 10 | * This file contains the check_http plugin |
11 | * | 11 | * |
12 | * This plugin tests the HTTP service on the specified host. It can test | 12 | * This plugin tests the HTTP service on the specified host. It can test |
13 | * normal (http) and secure (https) servers, follow redirects, search for | 13 | * normal (http) and secure (https) servers, follow redirects, search for |
14 | * strings and regular expressions, check connection times, and report on | 14 | * strings and regular expressions, check connection times, and report on |
15 | * certificate expiration times. | 15 | * certificate expiration times. |
16 | * | 16 | * |
17 | * | 17 | * |
18 | * This program is free software: you can redistribute it and/or modify | 18 | * This program is free software: you can redistribute it and/or modify |
19 | * it under the terms of the GNU General Public License as published by | 19 | * it under the terms of the GNU General Public License as published by |
20 | * the Free Software Foundation, either version 3 of the License, or | 20 | * the Free Software Foundation, either version 3 of the License, or |
21 | * (at your option) any later version. | 21 | * (at your option) any later version. |
22 | * | 22 | * |
23 | * This program is distributed in the hope that it will be useful, | 23 | * This program is distributed in the hope that it will be useful, |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26 | * GNU General Public License for more details. | 26 | * GNU General Public License for more details. |
27 | * | 27 | * |
28 | * You should have received a copy of the GNU General Public License | 28 | * You should have received a copy of the GNU General Public License |
29 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 29 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
30 | * | 30 | * |
31 | * | 31 | * |
32 | *****************************************************************************/ | 32 | *****************************************************************************/ |
33 | 33 | ||
34 | /* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */ | 34 | /* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */ |
@@ -1145,24 +1145,24 @@ check_http (void) | |||
1145 | /* check elapsed time */ | 1145 | /* check elapsed time */ |
1146 | if (show_extended_perfdata) | 1146 | if (show_extended_perfdata) |
1147 | xasprintf (&msg, | 1147 | xasprintf (&msg, |
1148 | _("%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s"), | 1148 | _("%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s"), |
1149 | msg, page_len, elapsed_time, | 1149 | msg, page_len, elapsed_time, |
1150 | (display_html ? "</A>" : ""), | 1150 | (display_html ? "</A>" : ""), |
1151 | perfd_time (elapsed_time), | 1151 | perfd_time (elapsed_time), |
1152 | perfd_size (page_len), | 1152 | perfd_size (page_len), |
1153 | perfd_time_connect (elapsed_time_connect), | 1153 | perfd_time_connect (elapsed_time_connect), |
1154 | perfd_time_ssl (elapsed_time_ssl), | 1154 | use_ssl == TRUE ? perfd_time_ssl (elapsed_time_ssl) : "", |
1155 | perfd_time_headers (elapsed_time_headers), | 1155 | perfd_time_headers (elapsed_time_headers), |
1156 | perfd_time_firstbyte (elapsed_time_firstbyte), | 1156 | perfd_time_firstbyte (elapsed_time_firstbyte), |
1157 | perfd_time_transfer (elapsed_time_transfer)); | 1157 | perfd_time_transfer (elapsed_time_transfer)); |
1158 | else | 1158 | else |
1159 | xasprintf (&msg, | 1159 | xasprintf (&msg, |
1160 | _("%s - %d bytes in %.3f second response time %s|%s %s"), | 1160 | _("%s - %d bytes in %.3f second response time %s|%s %s"), |
1161 | msg, page_len, elapsed_time, | 1161 | msg, page_len, elapsed_time, |
1162 | (display_html ? "</A>" : ""), | 1162 | (display_html ? "</A>" : ""), |
1163 | perfd_time (elapsed_time), | 1163 | perfd_time (elapsed_time), |
1164 | perfd_size (page_len)); | 1164 | perfd_size (page_len)); |
1165 | 1165 | ||
1166 | result = max_state_alt(get_status(elapsed_time, thlds), result); | 1166 | result = max_state_alt(get_status(elapsed_time, thlds), result); |
1167 | 1167 | ||
1168 | die (result, "HTTP %s: %s\n", state_text(result), msg); | 1168 | die (result, "HTTP %s: %s\n", state_text(result), msg); |
@@ -1364,7 +1364,7 @@ char *perfd_time_headers (double elapsed_time_headers) | |||
1364 | { | 1364 | { |
1365 | return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); | 1365 | return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); |
1366 | } | 1366 | } |
1367 | 1367 | ||
1368 | char *perfd_time_firstbyte (double elapsed_time_firstbyte) | 1368 | char *perfd_time_firstbyte (double elapsed_time_firstbyte) |
1369 | { | 1369 | { |
1370 | return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); | 1370 | return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); |
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 6299791f..9948c539 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -8,22 +8,22 @@ use strict; | |||
8 | use Test::More; | 8 | use Test::More; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | plan tests => 27; | 11 | plan tests => 30; |
12 | 12 | ||
13 | my $successOutput = '/OK.*HTTP.*second/'; | 13 | my $successOutput = '/OK.*HTTP.*second/'; |
14 | 14 | ||
15 | my $res; | 15 | my $res; |
16 | 16 | ||
17 | my $host_tcp_http = getTestParameter( "NP_HOST_TCP_HTTP", | 17 | my $host_tcp_http = getTestParameter( "NP_HOST_TCP_HTTP", |
18 | "A host providing the HTTP Service (a web server)", | 18 | "A host providing the HTTP Service (a web server)", |
19 | "localhost" ); | 19 | "localhost" ); |
20 | 20 | ||
21 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", | 21 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", |
22 | "The hostname of system not responsive to network requests", | 22 | "The hostname of system not responsive to network requests", |
23 | "10.0.0.1" ); | 23 | "10.0.0.1" ); |
24 | 24 | ||
25 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | 25 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", |
26 | "An invalid (not known to DNS) hostname", | 26 | "An invalid (not known to DNS) hostname", |
27 | "nosuchhost"); | 27 | "nosuchhost"); |
28 | 28 | ||
29 | my $internet_access = getTestParameter( "NP_INTERNET_ACCESS", | 29 | my $internet_access = getTestParameter( "NP_INTERNET_ACCESS", |
@@ -32,8 +32,8 @@ my $internet_access = getTestParameter( "NP_INTERNET_ACCESS", | |||
32 | 32 | ||
33 | my $host_tcp_http2; | 33 | my $host_tcp_http2; |
34 | if ($internet_access eq "no") { | 34 | if ($internet_access eq "no") { |
35 | $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", | 35 | $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", |
36 | "A host providing an index page containing the string 'nagios'", | 36 | "A host providing an index page containing the string 'nagios'", |
37 | "www.nagios.com" ); | 37 | "www.nagios.com" ); |
38 | } | 38 | } |
39 | 39 | ||
@@ -118,6 +118,10 @@ SKIP: { | |||
118 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); | 118 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); |
119 | cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); | 119 | cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); |
120 | 120 | ||
121 | $res = NPTest->testCmd( "./check_http --ssl www.verisign.com -E" ); | ||
122 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | ||
123 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); | ||
124 | |||
121 | $res = NPTest->testCmd( | 125 | $res = NPTest->testCmd( |
122 | "./check_http --ssl www.e-paycobalt.com" | 126 | "./check_http --ssl www.e-paycobalt.com" |
123 | ); | 127 | ); |
@@ -126,4 +130,7 @@ SKIP: { | |||
126 | 130 | ||
127 | $res = NPTest->testCmd( "./check_http -H www.mozilla.com -u /firefox -f follow" ); | 131 | $res = NPTest->testCmd( "./check_http -H www.mozilla.com -u /firefox -f follow" ); |
128 | is( $res->return_code, 0, "Redirection based on location is okay"); | 132 | is( $res->return_code, 0, "Redirection based on location is okay"); |
133 | |||
134 | $res = NPTest->testCmd( "./check_http -H www.mozilla.com --extended-perfdata" ); | ||
135 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | ||
129 | } | 136 | } |