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 |
|
|
64 |
$user_agent->timeout($timeout); |
$user_agent->timeout($timeout); |
65 |
|
|
66 |
my @failed; |
my @failed; |
67 |
|
my @available; |
68 |
my %failure; |
my %failure; |
69 |
host: |
host: |
70 |
foreach my $host (@_) { |
foreach my $host (@_) { |
113 |
&{$ht_lose}("Regex not found"); |
&{$ht_lose}("Regex not found"); |
114 |
} |
} |
115 |
} |
} |
116 |
|
push(@available, $host); |
117 |
} |
} |
118 |
if(@failed) { |
if(@failed) { |
119 |
print "$u_proto Failures: " . join(" ", @failed) . "\n"; |
print "$u_proto Failures: " . join(" ", @failed) . "\n"; |
120 |
foreach my $fail (@failed) { |
foreach my $fail (@failed) { |
121 |
print "$fail: $failure{$fail}\n"; |
print "$fail: $failure{$fail}\n"; |
122 |
} |
} |
123 |
exit(1); |
if ($opt_o && ($#available+1) > 0) { |
124 |
|
print "$u_proto Available: ".join(" ", @available)."\n"; |
125 |
|
} else { |
126 |
|
exit(1); |
127 |
|
} |
128 |
} |
} |
129 |
exit; |
exit; |
130 |
} |
} |
150 |
-v Invert the regular expression. Content must NOT match. |
-v Invert the regular expression. Content must NOT match. |
151 |
-z Supress zero-length check. |
-z Supress zero-length check. |
152 |
-c Enable Cookies. |
-c Enable Cookies. |
153 |
|
-o Return success if at least One server is available. |
154 |
EOF |
EOF |
155 |
} |
} |
156 |
exit 1; |
exit 1; |
158 |
|
|
159 |
### |
### |
160 |
|
|
161 |
getopts("hszvcp:t:d:r:P:") || do_usage(); |
getopts("hszvcp:t:d:r:P:o") || do_usage(); |
162 |
do_usage($opt_h) if($opt_h); |
do_usage($opt_h) if($opt_h); |
163 |
|
|
164 |
&main(@ARGV); |
&main(@ARGV); |