diff options
| author | inqrphl <32687873+inqrphl@users.noreply.github.com> | 2026-05-19 16:01:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-19 16:01:43 +0200 |
| commit | 178e9a02e367ab4527129ddbc623401e245d00b2 (patch) | |
| tree | e4655ece4741fea367bc82f25b66912a1b704016 /plugins/t/check_curl.t | |
| parent | 5ccce854954e807e51966b3db9388bf20284b949 (diff) | |
| download | monitoring-plugins-178e9a02e367ab4527129ddbc623401e245d00b2.tar.gz | |
check_curl + check_http:
hdd cli argument to return custom states on timeout
---------
Co-authored-by: Ahmet Oeztuerk <Ahmet.Oeztuerk@consol.de>
Diffstat (limited to 'plugins/t/check_curl.t')
| -rw-r--r-- | plugins/t/check_curl.t | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t index 0f4d0de7..7ec8ca06 100644 --- a/plugins/t/check_curl.t +++ b/plugins/t/check_curl.t | |||
| @@ -13,7 +13,7 @@ use vars qw($tests $has_ipv6); | |||
| 13 | BEGIN { | 13 | BEGIN { |
| 14 | use NPTest; | 14 | use NPTest; |
| 15 | $has_ipv6 = NPTest::has_ipv6(); | 15 | $has_ipv6 = NPTest::has_ipv6(); |
| 16 | $tests = $has_ipv6 ? 57 : 92; | 16 | $tests = $has_ipv6 ? 65 : 100; |
| 17 | plan tests => $tests; | 17 | plan tests => $tests; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| @@ -69,7 +69,32 @@ $res = NPTest->testCmd( | |||
| 69 | ); | 69 | ); |
| 70 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); | 70 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); |
| 71 | # was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!) | 71 | # was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!) |
| 72 | like( $res->output, "/cURL returned 28 - Connection timed out after/", "Output OK"); | 72 | like( $res->output, "/cURL returned 28 - (Connection|Operation) timed out after/", "Output OK"); |
| 73 | |||
| 74 | # timeout return results can be changed using --timeout-result option | ||
| 75 | $res = NPTest->testCmd( | ||
| 76 | "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3 --timeout-result ok" | ||
| 77 | ); | ||
| 78 | like( $res->output, "/cURL returned 28 - (Connection|Operation) timed out after/", "Output OK"); | ||
| 79 | cmp_ok( $res->return_code, "==", 0, "Return code is correct due argument: --timeout-result ok"); | ||
| 80 | |||
| 81 | $res = NPTest->testCmd( | ||
| 82 | "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3 --timeout-result warning" | ||
| 83 | ); | ||
| 84 | like( $res->output, "/cURL returned 28 - (Connection|Operation) timed out after/", "Output OK"); | ||
| 85 | cmp_ok( $res->return_code, "==", 1, "Return code is correct due argument: --timeout-result warning"); | ||
| 86 | |||
| 87 | $res = NPTest->testCmd( | ||
| 88 | "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3 --timeout-result 2" | ||
| 89 | ); | ||
| 90 | like( $res->output, "/cURL returned 28 - (Connection|Operation) timed out after/", "Output OK"); | ||
| 91 | cmp_ok( $res->return_code, "==", 2, "Return code is correct due argument: --timeout-result 2"); | ||
| 92 | |||
| 93 | $res = NPTest->testCmd( | ||
| 94 | "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3 --timeout-result 3" | ||
| 95 | ); | ||
| 96 | like( $res->output, "/cURL returned 28 - (Connection|Operation) timed out after/", "Output OK"); | ||
| 97 | cmp_ok( $res->return_code, "==", 3, "Return code is correct due argument: --timeout-result 3"); | ||
| 73 | 98 | ||
| 74 | $res = NPTest->testCmd( | 99 | $res = NPTest->testCmd( |
| 75 | "./$plugin $hostname_invalid -wt 1 -ct 2" | 100 | "./$plugin $hostname_invalid -wt 1 -ct 2" |
