46 WARNING => 1, |
46 WARNING => 1, |
47 CRITICAL => 2, |
47 CRITICAL => 2, |
48 UNKNOWN => 3 |
48 UNKNOWN => 3 |
49 }; |
49 }; |
50 |
50 |
|
51 sub version($$); |
|
52 |
51 Getopt::Long::Configure('no_ignore_case_always'); |
53 Getopt::Long::Configure('no_ignore_case_always'); |
|
54 |
52 GetOptions( |
55 GetOptions( |
53 "w|warning=i" => \$opt->{warning}, |
56 "w|warning=i" => \$opt->{warning}, |
54 "c|critical=i" => \$opt->{critical}, |
57 "c|critical=i" => \$opt->{critical}, |
55 "H|index-host=s" => \$opt->{'index-host'}, |
58 "H|index-host=s" => \$opt->{'index-host'}, |
56 "Z|index-zone=s" => \$opt->{'index-zone'}, |
59 "Z|index-zone=s" => \$opt->{'index-zone'}, |
57 "h|help" => sub { pod2usage( -verbose => 1, -exitval => $rv->{OK} ) }, |
60 "h|help" => sub { pod2usage( -verbose => 1, -exitval => $rv->{OK} ) }, |
58 "m|man" => sub { pod2usage( -verbose => 2, -exitval => $rv->{OK} ) }, |
61 "m|man" => sub { pod2usage( |
|
62 -exitval => $rv->{OK}, |
|
63 # "system('perldoc -V &>/dev/null')" appears shorter, but may not |
|
64 # do what you expect ( it still returns 0 on debian squeeze with |
|
65 # dash as system shell even if cannot find the command in $PATH) |
|
66 -noperldoc => system('perldoc -V >/dev/null 2>&1'), |
|
67 -verbose => 2 ) }, |
59 "V|version" => sub { version( $ME, $VERSION ); exit $rv->{OK}; } |
68 "V|version" => sub { version( $ME, $VERSION ); exit $rv->{OK}; } |
60 ) or pod2usage( -verbose => 1, -exitval => $rv->{CRITICAL} ); |
69 ) or pod2usage( -verbose => 1, -exitval => $rv->{CRITICAL} ); |
61 |
70 |
62 my $rc = 'OK'; |
71 my $rc = 'OK'; |
63 my $res = Net::DNS::Resolver->new; |
72 my $res = Net::DNS::Resolver->new; |