6 |
# Lots of options. |
# Lots of options. |
7 |
# |
# |
8 |
# $Id$ |
# $Id$ |
9 |
|
# |
10 |
|
# 2002-09-02 Dobrica Pavlinusic <dpavlin@rot13.org> |
11 |
|
# added option -o which will return success if ANY of server responded with |
12 |
|
# success (so that you can ignore alerts if backup servers are working) |
13 |
|
|
14 |
use strict; |
use strict; |
15 |
|
|
23 |
### |
### |
24 |
|
|
25 |
use vars qw($opt_h $opt_p $opt_t $opt_z $opt_d $opt_r $opt_s $opt_P |
use vars qw($opt_h $opt_p $opt_t $opt_z $opt_d $opt_r $opt_s $opt_P |
26 |
$opt_v $opt_c); |
$opt_v $opt_c $opt_o); |
27 |
|
|
28 |
## |
## |
29 |
|
|
62 |
$user_agent->agent($agent); |
$user_agent->agent($agent); |
63 |
$user_agent->from($maintainer); |
$user_agent->from($maintainer); |
64 |
$user_agent->timeout($timeout); |
$user_agent->timeout($timeout); |
65 |
|
$user_agent->env_proxy(); |
66 |
|
|
67 |
my @failed; |
my @failed; |
68 |
|
my @available; |
69 |
my %failure; |
my %failure; |
70 |
host: |
host: |
71 |
foreach my $host (@_) { |
foreach my $host (@_) { |
114 |
&{$ht_lose}("Regex not found"); |
&{$ht_lose}("Regex not found"); |
115 |
} |
} |
116 |
} |
} |
117 |
|
push(@available, $host); |
118 |
} |
} |
119 |
if(@failed) { |
if(@failed) { |
120 |
print "$u_proto Failures: " . join(" ", @failed) . "\n"; |
print "$u_proto Failures: " . join(" ", @failed) . "\n"; |
121 |
foreach my $fail (@failed) { |
foreach my $fail (@failed) { |
122 |
print "$fail: $failure{$fail}\n"; |
print "$fail: $failure{$fail}\n"; |
123 |
} |
} |
124 |
exit(1); |
if ($opt_o && ($#available+1) > 0) { |
125 |
|
print "$u_proto Available: ".join(" ", @available)."\n"; |
126 |
|
} else { |
127 |
|
exit(1); |
128 |
|
} |
129 |
} |
} |
130 |
exit; |
exit; |
131 |
} |
} |
151 |
-v Invert the regular expression. Content must NOT match. |
-v Invert the regular expression. Content must NOT match. |
152 |
-z Supress zero-length check. |
-z Supress zero-length check. |
153 |
-c Enable Cookies. |
-c Enable Cookies. |
154 |
|
-o Return success if at least One server is available. |
155 |
EOF |
EOF |
156 |
} |
} |
157 |
exit 1; |
exit 1; |
159 |
|
|
160 |
### |
### |
161 |
|
|
162 |
getopts("hszvcp:t:d:r:P:") || do_usage(); |
getopts("hszvcp:t:d:r:P:o") || do_usage(); |
163 |
do_usage($opt_h) if($opt_h); |
do_usage($opt_h) if($opt_h); |
164 |
|
|
165 |
&main(@ARGV); |
&main(@ARGV); |