| 1 | package # Hide from pause | ||||||||||||
| 2 | Monitoring::Livestatus::Class::Abstract::Stats; | ||||||||||||
| 3 | |||||||||||||
| 4 | 4 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 4 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 4 | extends 'Monitoring::Livestatus::Class::Base::Abstract'; | |||||||||||
| 7 | |||||||||||||
| 8 | 4 | ▶ | use Monitoring::Livestatus::Class; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 4 | ▶ | my $TRACE = Monitoring::Livestatus::Class->TRACE() || 0; | ||||||||||
|
Condition50%1/2
'Monitoring::Livestatus::Class'->TRACE || 0
MC/DC0%0/1
'Monitoring::Livestatus::Class'->TRACE || 0
'Monitoring::Livestatus::Class'->TRACE
Truth table50%1/2
A
A= 'Monitoring::Livestatus::Class'->TRACE
| |||||||||||||
| 10 | |||||||||||||
| 11 | 21 | ▶ | sub build_mode { return 'Stats'; }; | ||||||||||
|
Subroutine
build_mode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 12 | |||||||||||||
| 13 | 21 | ▶ | sub build_compining_prefix { return 'Stats'; } | ||||||||||
|
Subroutine
build_compining_prefix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 14 | |||||||||||||
| 15 | 21 | ▶ | sub build_operators { | ||||||||||
|
Subroutine
build_operators: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 16 | 21 | my $self = shift; | |||||||||||
| 17 | 21 | my $operators = $self->SUPER::build_operators(); | |||||||||||
| 18 | |||||||||||||
| 19 | 21 | push @{ $operators }, { | |||||||||||
| 20 | regexp => qr/(groupby)/ix, | ||||||||||||
| 21 | handler => '_cond_op_groupby', | ||||||||||||
| 22 | }; | ||||||||||||
| 23 | |||||||||||||
| 24 | 21 | push @{ $operators }, { | |||||||||||
| 25 | regexp => qr/(sum|min|max|avg|std)/ix, | ||||||||||||
| 26 | handler => '_cond_op_simple' | ||||||||||||
| 27 | }; | ||||||||||||
| 28 | |||||||||||||
| 29 | 21 | push @{ $operators }, { | |||||||||||
| 30 | regexp => qr/(isa)/ix, | ||||||||||||
| 31 | handler => '_cond_op_isa' | ||||||||||||
| 32 | }; | ||||||||||||
| 33 | |||||||||||||
| 34 | 21 | return $operators; | |||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | 1 | ▶ | sub _cond_op_groupby { | ||||||||||
|
Subroutine
_cond_op_groupby: called CC=4 SCAR=14.2
| |||||||||||||
| 38 | 1 | my $self = shift; | |||||||||||
| 39 | 1 | my $operator = shift; | |||||||||||
| 40 | 1 | my $value = shift; | |||||||||||
| 41 | 1 | ▶ | my $combining_count = shift || 0; | ||||||||||
|
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 42 | |||||||||||||
| 43 | 1 | ▶ | print STDERR "#IN _cond_op_groupby $operator $value $combining_count\n" if $TRACE > 9; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 44 | |||||||||||||
| 45 | my ( @child_statment ) = $self->_dispatch_refkind($value, { | ||||||||||||
| 46 | 1 | ▶ | SCALAR => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 47 | 1 | return ( sprintf("%s%s: %s",$self->compining_prefix, 'GroupBy', $value) ); | |||||||||||
| 48 | }, | ||||||||||||
| 49 | 1 | }); | |||||||||||
| 50 | 1 | ▶ | print STDERR "#OUT _cond_op_groupby $operator $value $combining_count\n" if $TRACE > 9; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | 1 | return ( $combining_count, @child_statment ); | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | 1 | ▶ | sub _cond_op_simple { | ||||||||||
|
Subroutine
_cond_op_simple: called CC=4 SCAR=14.1
| |||||||||||||
| 55 | 1 | my $self = shift; | |||||||||||
| 56 | 1 | my $operator = shift; | |||||||||||
| 57 | 1 | my $value = shift; | |||||||||||
| 58 | 1 | ▶ | my $combining_count = shift || 0; | ||||||||||
|
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 59 | 1 | my @child_statment = (); | |||||||||||
| 60 | |||||||||||||
| 61 | 1 | ▶ | print STDERR "#IN _cond_op_simple $operator $value $combining_count\n" if $TRACE > 9; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 62 | |||||||||||||
| 63 | ( $combining_count,@child_statment ) = $self->_dispatch_refkind($value, { | ||||||||||||
| 64 | 1 | ▶ | SCALAR => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 65 | 1 | return (++$combining_count, sprintf("%s: %s %s",$self->compining_prefix,$operator,$value) ); | |||||||||||
| 66 | }, | ||||||||||||
| 67 | 1 | }); | |||||||||||
| 68 | |||||||||||||
| 69 | 1 | ▶ | print STDERR "#OUT _cond_op_simple $operator $value $combining_count\n" if $TRACE > 9; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 70 | 1 | return ( $combining_count, @child_statment ); | |||||||||||
| 71 | } | ||||||||||||
| 72 | |||||||||||||
| 73 | 8 | ▶ | sub _cond_op_isa { | ||||||||||
|
Subroutine
_cond_op_isa: called CC=4 SCAR=14.2
| |||||||||||||
| 74 | 8 | my $self = shift; | |||||||||||
| 75 | 8 | my $operator = shift; | |||||||||||
| 76 | 8 | my $value = shift; | |||||||||||
| 77 | 8 | ▶ | my $combining_count = shift || 0; | ||||||||||
|
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 78 | 8 | my $as_name; | |||||||||||
| 79 | 8 | ▶ | print STDERR "#IN _cond_op_isa $operator $value $combining_count\n" if $TRACE > 9; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 80 | |||||||||||||
| 81 | my ( $child_combining_count, @statment ) = $self->_dispatch_refkind($value, { | ||||||||||||
| 82 | 8 | ▶ | HASHREF => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||
| 83 | 8 | my @keys = keys %$value; | |||||||||||
| 84 | 8 | ▶ | if ( scalar @keys != 1 ){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 85 | 0 | die "Isa operator doesn't support more then one key."; | |||||||||||
| 86 | } | ||||||||||||
| 87 | 8 | $as_name = shift @keys; | |||||||||||
| 88 | 8 | my @values = values(%$value); | |||||||||||
| 89 | 8 | return $self->_recurse_cond(shift( @values ), 0 ); | |||||||||||
| 90 | }, | ||||||||||||
| 91 | 8 | }); | |||||||||||
| 92 | 8 | $combining_count += $child_combining_count; | |||||||||||
| 93 | |||||||||||||
| 94 | 8 | $statment[ $#statment ] = $statment[$#statment] . " as " . $as_name; | |||||||||||
| 95 | |||||||||||||
| 96 | 8 | ▶ | print STDERR "#OUT _cond_op_isa $operator $value $combining_count isa key: " . $self->{_isa_key} . "\n" if $TRACE > 9; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 97 | 8 | return ( $combining_count, @statment ); | |||||||||||
| 98 | } | ||||||||||||
| 99 | |||||||||||||
| 100 | 4 | 1; | |||||||||||
| 101 | __END__ | ||||||||||||