1
package # Hide from pause
2
Monitoring::Livestatus::Class::Abstract::Stats;
6
extends 'Monitoring::Livestatus::Class::Base::Abstract';
8
use Monitoring::Livestatus::Class;
9
my $TRACE = Monitoring::Livestatus::Class->TRACE() || 0;
11
sub build_mode { return 'Stats'; };
13
sub build_compining_prefix { return 'Stats'; }
17
my $operators = $self->SUPER::build_operators();
19
push @{ $operators }, {
20
regexp => qr/(groupby)/ix,
21
handler => '_cond_op_groupby',
24
push @{ $operators }, {
25
regexp => qr/(sum|min|max|avg|std)/ix,
26
handler => '_cond_op_simple'
29
push @{ $operators }, {
30
regexp => qr/(isa)/ix,
31
handler => '_cond_op_isa'
37
sub _cond_op_groupby {
41
my $combining_count = shift || 0;
43
print STDERR "#IN _cond_op_groupby $operator $value $combining_count\n" if $TRACE > 9;
45
my ( @child_statment ) = $self->_dispatch_refkind($value, {
47
return ( sprintf("%s%s: %s",$self->compining_prefix, 'GroupBy', $value) );
50
print STDERR "#OUT _cond_op_groupby $operator $value $combining_count\n" if $TRACE > 9;
51
return ( $combining_count, @child_statment );
58
my $combining_count = shift || 0;
59
my @child_statment = ();
61
print STDERR "#IN _cond_op_simple $operator $value $combining_count\n" if $TRACE > 9;
63
( $combining_count,@child_statment ) = $self->_dispatch_refkind($value, {
65
return (++$combining_count, sprintf("%s: %s %s",$self->compining_prefix,$operator,$value) );
69
print STDERR "#OUT _cond_op_simple $operator $value $combining_count\n" if $TRACE > 9;
70
return ( $combining_count, @child_statment );
77
my $combining_count = shift || 0;
79
print STDERR "#IN _cond_op_isa $operator $value $combining_count\n" if $TRACE > 9;
81
my ( $child_combining_count, @statment ) = $self->_dispatch_refkind($value, {
83
my @keys = keys %$value;
84
if ( scalar @keys != 1 ){
85
die "Isa operator doesn't support more then one key.";
87
$as_name = shift @keys;
88
my @values = values(%$value);
89
return $self->_recurse_cond(shift( @values ), 0 );
92
$combining_count += $child_combining_count;
94
$statment[ $#statment ] = $statment[$#statment] . " as " . $as_name;
96
print STDERR "#OUT _cond_op_isa $operator $value $combining_count isa key: " . $self->{_isa_key} . "\n" if $TRACE > 9;
97
return ( $combining_count, @statment );
104
Monitoring::Livestatus::Class::Abstract::Stats - Class to generate livestatus
115
please view in L<Monitoring::Livestatus::Class::Base::Abstract>
117
=head1 INTERNAL METHODS
123
=item build_compining_prefix
125
=item build_operators
131
See L<Monitoring::Livestatus::Class/AUTHOR> and L<Monitoring::Livestatus::Class/CONTRIBUTORS>.
133
=head1 COPYRIGHT & LICENSE
135
Copyright 2009 Robert Bohne.
137
This program is free software; you can redistribute it and/or modify it
138
under the terms of either: the GNU General Public License as published
139
by the Free Software Foundation; or the Artistic License.
141
See http://dev.perl.org/licenses/ for more information.