lib/App/MadEye/Rule/Interval.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 42 CC 2 SCAR 11.5
CC
2
Cov
0%
dispatch
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.1
1 package App::MadEye::Rule::Interval;
2 use strict;
3 use warnings;
4 use base qw/App::MadEye::Rule/;
5 use Cache::FileCache;
6 use YAML;
7  
8 sub dispatch {
9 my ($self, $context, $args) = @_;
10  
11 my $interval_time = $self->config->{interval_time} or die "missing interval_time";
12 my $cache_root = $self->config->{cache_root} or die "missing cache_root";
13  
14 my $key = YAML::Dump($args->{target}).__PACKAGE__;
15 $context->log(info => "Interval: $args->{target}, $args->{plugin}");
16  
17 my $cache = Cache::FileCache->new( { cache_root => $cache_root, } );
18 if ($cache->get($key)) {
19 return 1; # not notify
20 } else {
21 $cache->set($key => "Boofy", $interval_time);
22 return 0;
23 }
24 }
25  
26 1;
27  
28 # 監視間隔が短いとわんわん通知がくるので、この時間内なら問題があっても
29 # 再通知しない。
30  
31 __END__