7 # ABSTRACT: allows checking of website according to configured specifications
13 use Params
::Util
qw(_ARRAY);
15 use WWW
::Mechanize
::Script
::Util
qw(:ALL);
16 use WWW
::Mechanize
::Script
;
18 my $VERSION = '0.001_003';
20 my @options = ( "file=s", "help|h", "usage|?" );
22 GetOptions
( \
%opts, @options ) or pod2usage
(2);
24 defined( $opts{help
} )
32 defined( $opts{usage
} ) and $opts{usage
} and pod2usage
(1);
33 opt_required_all
( \
%opts, qw(file) );
35 my %cfg = load_config
( \
%opts );
38 my %cfgvar = ( OPTS_FILE
=> $opts{file
} );
39 my $cfgkeys = join( "|", keys %cfgvar );
40 $cfg{summary
}->{target
} =~ s/@($cfgkeys)[@]/$cfgvar{$1}/ge;
41 $cfg{report
}->{target
} =~ s/@($cfgkeys)[@]/$cfgvar{$1}/ge;
44 my $wms = WWW
::Mechanize
::Script
->new( \
%cfg );
46 _ARRAY
( $cfg{wtscript_extensions
} )
47 and Config
::Any
::WTScript
->extensions( @
{ $cfg{wtscript_extensions
} } );
48 my @script_files = find_scripts
( \
%cfg, $opts{file
} );
50 my ( $code, @msgs ) = (0);
53 my $scripts = Config
::Any
->load_files(
55 files
=> [@script_files],
60 foreach my $filename (@script_files)
62 defined( $scripts->{$filename} )
63 or next; # file not found or not parsable ...
64 # merge into default and previous loaded config ...
65 push( @script, @
{ $scripts->{$filename} } );
67 ( $code, @msgs ) = $wms->run_script(@script);
69 $@
and say("UNKNOWN - $@");
70 exit( $@ ?
255 : $code );
76 check_web2 is intended to be used to check web-sites according a configuration.
77 The configuration covers the request configuration (including agent part) and
78 check configuration to specify check parameters.
80 See C<WWW::Mechanize::Script> for details about the configuration options.
84 This script is created as successor of an check_web script of a nagios setup
85 based on HTTP::WebCheck. This module isn't longer maintained, so decision
86 was made to create a new environment simulating the old one basing on
91 $ check_web2 --file domain1/site1.json
92 $ check_web2 --file domain2/site1.yml
94 $ check_web2 --file domain1/site2.wts
98 Jens Rehsack, C<< <rehsack at cpan.org> >>
102 Please report any bugs or feature requests to C<bug-www-mechanize-script at rt.cpan.org>, or through
103 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Mechanize-Script>. I will be notified, and then you'll
104 automatically be notified of progress on your bug as I make changes.
108 You can find documentation for this module with the perldoc command.
110 perldoc WWW:Mechanize::Script
112 You can also look for information at:
116 =item * RT: CPAN's request tracker (report bugs here)
118 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Mechanize-Script>
120 =item * AnnoCPAN: Annotated CPAN documentation
122 L<http://annocpan.org/dist/WWW-Mechanize-Script>
126 L<http://cpanratings.perl.org/d/WWW-Mechanize-Script>
130 L<http://search.cpan.org/dist/WWW-Mechanize-Script/>
134 =head1 ACKNOWLEDGEMENTS
136 =head1 LICENSE AND COPYRIGHT
138 Copyright 2012 Jens Rehsack.
140 This program is free software; you can redistribute it and/or modify it
141 under the terms of either: the GNU General Public License as published
142 by the Free Software Foundation; or the Artistic License.
144 See http://dev.perl.org/licenses/ for more information.