blib/lib/TheEye/Plugin/Store/Riemann.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod n/a totaltotal 0.0% 0 / 28 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package TheEye::Plugin::Store::Riemann;
2  
3 use Mouse::Role;
4 use Riemann::Client;
5  
6 # ABSTRACT: Riemann plugin for TheEye
7 #
8 our $VERSION = '0.1'; # VERSION
9  
10 has 'riemann' => (
11 is => 'rw',
12 isa => 'Riemann::Client',
13 required => 1,
14 lazy => 1,
15 default => sub { Riemann::Client->new( host => 'localhost', port => 5555)},
16 );
17  
18  
19 around 'save' => sub {
20 my $orig = shift;
21 my ( $self, $tests ) = @_;
22  
23 my @events;
24 foreach my $result (@{$tests}) {
25  
26 my @path = split(/\//, $result->{file});
27 my @file = split(/\./, pop(@path));
28  
29 my $event = {
30 state => 'ok',
31 host => $self->hostname,
32 service => $file[0],
33 time => $result->{time},
34 metric => $result->{delta},
35 description => $result->{passed} .' passed and '. $result->{failed} .' failed',
36 };
37 if($result->{failed}){
38 $event->{state} = 'critical';
39 }
40 push(@events, $event);
41 }
42 $self->riemann->send(@events);
43 return;
44 };
45  
46  
47 1;
48  
49 __END__