| 1 | #!/usr/bin/env perl | ||
| 2 | # | ||
| 3 | # Plugin for checking availability of a single web page, using first | ||
| 4 | # the HTTP HEAD method and then the HTTP POST method. | ||
| 5 | # | ||
| 6 | # Usage: check-post.pl [-cfg <config-file>] -service <id> [<logging-options>] | ||
| 7 | # | ||
| 8 | # The return code and STDOUT are compatible with the Nagios plugins | ||
| 9 | # (see: http://nagios.sourceforge.net/docs/3_0/quickstart.html) | ||
| 10 | # | ||
| 11 | # September 2011 | ||
| 12 | # Author: Martin Senger <martin.senger@gmail.com> | ||
| 13 | #----------------------------------------------------------------- | ||
| 14 | |||
| 15 | use warnings; | ||
| 16 | use strict; | ||
| 17 | |||
| 18 | use Monitor::Simple; | ||
| 19 | use Log::Log4perl qw(:easy); | ||
| 20 | |||
| 21 | # read command-line arguments and configuration | ||
| 22 | my ($config_file, $service_id) = Monitor::Simple::Utils->parse_plugin_args ('', @ARGV); | ||
| 23 | LOGDIE ("Unknown service (missing parameter '-service <id>')\n") | ||
| 24 | unless $service_id; | ||
| 25 | my $config = Monitor::Simple::Config->get_config ($config_file); | ||
| 26 | |||
| 27 | # make my test | ||
| 28 | Monitor::Simple::UserAgent->head_or_exit ($service_id, $config); | ||
| 29 | Monitor::Simple::UserAgent->post_or_exit ($service_id, $config); | ||
| 30 | |||
| 31 | # everything is okay | ||
| 32 | Monitor::Simple::Utils->report_and_exit ($service_id, $config, Monitor::Simple::RETURN_OK, "OK"); | ||
| 33 | |||
| 34 | __END__ |