Simple/plugins/check-prg.pl

filter: Statementstmt 100% 17 / 17 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 95.6% 22 / 23 CC 1 SCAR 0.0
CC
1
Cov
95%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Simple/plugins/get-date.pl ↑ Summary Simple/plugins/copy-message.pl »
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
BranchTrueFalseTotal
unless $service_id 0 2 2
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__
« Simple/plugins/get-date.pl ↑ Summary Simple/plugins/copy-message.pl »