| 1 | #!/usr/bin/env perl | ||||||||||
| 2 | # | ||||||||||
| 3 | # Plugin for checking any command-line program by executing it with | ||||||||||
| 4 | # given arguments and reporting warning if there was any STDERR and | ||||||||||
| 5 | # checking STDOUT for expected values (defined in the given, or | ||||||||||
| 6 | # default, configuration file). | ||||||||||
| 7 | # | ||||||||||
| 8 | # Usage: check-prg.pl [-cfg <config-file>] -service <id> [<logging-options>] | ||||||||||
| 9 | # | ||||||||||
| 10 | # The return code and STDOUT are compatible with the Nagios plugins | ||||||||||
| 11 | # (see: http://nagios.sourceforge.net/docs/3_0/quickstart.html) | ||||||||||
| 12 | # | ||||||||||
| 13 | # September 2011 | ||||||||||
| 14 | # Author: Martin Senger <martin.senger@gmail.com> | ||||||||||
| 15 | #----------------------------------------------------------------- | ||||||||||
| 16 | |||||||||||
| 17 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 2 | ▶ | use Monitor::Simple; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 2 | ▶ | use Log::Log4perl qw(:easy); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | # read command-line arguments and configuration | ||||||||||
| 24 | 2 | my ($config_file, $service_id) = Monitor::Simple::Utils->parse_plugin_args ('', @ARGV); | |||||||||
| 25 | 2 | ▶ | LOGDIE ("Unknown service (missing parameter '-service <id>')\n") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | unless $service_id; | ||||||||||
| 27 | 2 | my $config = Monitor::Simple::Config->get_config ($config_file); | |||||||||
| 28 | |||||||||||
| 29 | # make my tests | ||||||||||
| 30 | 2 | Monitor::Simple::Utils->exec_or_exit ($service_id, $config); | |||||||||
| 31 | |||||||||||
| 32 | # everything is okay | ||||||||||
| 33 | 1 | Monitor::Simple::Utils->report_and_exit ($service_id, $config, Monitor::Simple::RETURN_OK, "OK"); | |||||||||
| 34 | |||||||||||
| 35 | __END__ | ||||||||||