| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Monitoring::Livestatus::Class; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 3 |  |  | 3 |  | 33733 | use Moose; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | use Module::Find; | 
| 5 |  |  |  |  |  |  | use Class::Load; | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '0.06'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | sub TRACE { return $ENV{'MONITORING_LIVESTATUS_CLASS_TRACE'} || 0 }; | 
| 10 |  |  |  |  |  |  | our $TRACE = TRACE(); | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | has 'peer' => ( | 
| 13 |  |  |  |  |  |  | is       => 'rw', | 
| 14 |  |  |  |  |  |  | required => 1, | 
| 15 |  |  |  |  |  |  | ); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | has 'verbose' => ( | 
| 18 |  |  |  |  |  |  | is       => 'rw', | 
| 19 |  |  |  |  |  |  | isa      => 'Bool', | 
| 20 |  |  |  |  |  |  | required => 0, | 
| 21 |  |  |  |  |  |  | ); | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | has 'keepalive' => ( | 
| 24 |  |  |  |  |  |  | is       => 'rw', | 
| 25 |  |  |  |  |  |  | isa      => 'Bool', | 
| 26 |  |  |  |  |  |  | required => 0, | 
| 27 |  |  |  |  |  |  | ); | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | has 'name' => ( | 
| 30 |  |  |  |  |  |  | is       => 'rw', | 
| 31 |  |  |  |  |  |  | isa      => 'Str', | 
| 32 |  |  |  |  |  |  | required => 0, | 
| 33 |  |  |  |  |  |  | ); | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | has 'backend_obj' => ( | 
| 37 |  |  |  |  |  |  | is       => 'ro', | 
| 38 |  |  |  |  |  |  | ); | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | has 'table_sources' => ( | 
| 41 |  |  |  |  |  |  | is      => 'ro', | 
| 42 |  |  |  |  |  |  | # isa     => 'ArrayRef', | 
| 43 |  |  |  |  |  |  | builder  => '_build_table_sources', | 
| 44 |  |  |  |  |  |  | ); | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | sub _build_table_sources { | 
| 47 |  |  |  |  |  |  | my $self = shift; | 
| 48 |  |  |  |  |  |  | my @found = useall Monitoring::Livestatus::Class::Table; | 
| 49 |  |  |  |  |  |  | return \@found; | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | sub BUILD { | 
| 53 |  |  |  |  |  |  | my $self = shift; | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | my $backend = sprintf 'Monitoring::Livestatus'; | 
| 56 |  |  |  |  |  |  | Class::Load::load_class($backend); | 
| 57 |  |  |  |  |  |  | $self->{backend_obj} = $backend->new( | 
| 58 |  |  |  |  |  |  | name      => $self->{name}, | 
| 59 |  |  |  |  |  |  | peer      => $self->{peer}, | 
| 60 |  |  |  |  |  |  | keepalive => $self->{keepalive}, | 
| 61 |  |  |  |  |  |  | verbose   => $self->{verbose}, | 
| 62 |  |  |  |  |  |  | ); | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | sub table { | 
| 68 |  |  |  |  |  |  | my $self = shift; | 
| 69 |  |  |  |  |  |  | my $table = ucfirst(lc(shift)); | 
| 70 |  |  |  |  |  |  | my $class = sprintf("Monitoring::Livestatus::Class::Table::%s",$table); | 
| 71 |  |  |  |  |  |  | return $class->new( ctx => $self ); | 
| 72 |  |  |  |  |  |  | } | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | 1; | 
| 75 |  |  |  |  |  |  | __END__ | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =head1 NAME | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | Monitoring::Livestatus::Class - Object-Oriented interface for | 
| 80 |  |  |  |  |  |  | Monitoring::Livestatus | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | This module is an object-oriented interface for Monitoring::Livestatus | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | B<The module is still in an early stage of development, there can be some | 
| 87 |  |  |  |  |  |  | api changes between releases.> | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head1 REPOSITORY | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | Git: http://github.com/rbo/Monitoring-Livestatus-Class | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | use Monitoring::Livestatus::Class; | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | my $class = Monitoring::Livestatus::Class->new( | 
| 98 |  |  |  |  |  |  | peer => '/var/lib/nagios3/rw/livestatus.sock' | 
| 99 |  |  |  |  |  |  | ); | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | my $hosts = $class->table('hosts'); | 
| 102 |  |  |  |  |  |  | my @data = $hosts->columns('display_name')->filter( | 
| 103 |  |  |  |  |  |  | { display_name => { '-or' => [qw/test_host_47 test_router_3/] } } | 
| 104 |  |  |  |  |  |  | )->hashref_array(); | 
| 105 |  |  |  |  |  |  | print Dumper \@data; | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | =head2 peer | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | Connection point to the status check_mk livestatus addon. This can be a unix | 
| 112 |  |  |  |  |  |  | domain or tcp socket. | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =head3 Socket | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | my $class = Monitoring::Livestatus::Class->new( | 
| 117 |  |  |  |  |  |  | peer => '/var/lib/nagios3/rw/livestatus.sock' | 
| 118 |  |  |  |  |  |  | ); | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | =head3 TCP Connection | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | my $class = Monitoring::Livestatus::Class->new( | 
| 123 |  |  |  |  |  |  | peer => '192.168.1.1:2134' | 
| 124 |  |  |  |  |  |  | ); | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =head1 METHODS | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =head2 table_sources | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | Arguments: none | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | Returns: @list | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | Get a list of all table class names. | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | =head2 table | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | Arguments: $table_name | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | Returns: $table_object | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | Returns a table object based on L<Monitoring::Livestatus::Class::Base::Table> | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | =head1 INTERNAL METHODS | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  | =over 4 | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | =item BUILD | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | Initializes the internal L<Monitoring::Livestatus> object. | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | =item TRACE | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | Get the trace level | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | =back | 
| 157 |  |  |  |  |  |  |  | 
| 158 |  |  |  |  |  |  | =head1 ENVIRONMENT VARIABLES | 
| 159 |  |  |  |  |  |  |  | 
| 160 |  |  |  |  |  |  | =head2 MONITORING_LIVESTATUS_CLASS_TRACE | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | Print tracer output from this object. | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  | =head2 MONITORING_LIVESTATUS_CLASS_TEST_PEER | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | Set peer for live tests. | 
| 167 |  |  |  |  |  |  |  | 
| 168 |  |  |  |  |  |  | =head1 AUTHOR | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  | Robert Bohne, C<< <rbo at cpan.org> >> | 
| 171 |  |  |  |  |  |  |  | 
| 172 |  |  |  |  |  |  | =head1 CONTRIBUTORS | 
| 173 |  |  |  |  |  |  |  | 
| 174 |  |  |  |  |  |  | nierlein: Sven Nierlein <nierlein@cpan.org> | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  | =head1 TODO: | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  | =over 4 | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | =item * Bettering the documentation | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | =back | 
| 183 |  |  |  |  |  |  |  | 
| 184 |  |  |  |  |  |  | =head1 BUGS | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  | Please report any bugs or feature requests to | 
| 187 |  |  |  |  |  |  | C<bug-Monitoring-Livestatus-Class at rt.cpan.org>, | 
| 188 |  |  |  |  |  |  | or through the web interface at | 
| 189 |  |  |  |  |  |  | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Monitoring-Livestatus-Class>. | 
| 190 |  |  |  |  |  |  |  | 
| 191 |  |  |  |  |  |  | =head1 SUPPORT | 
| 192 |  |  |  |  |  |  |  | 
| 193 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 194 |  |  |  |  |  |  |  | 
| 195 |  |  |  |  |  |  | perldoc Monitoring::Livestatus::Class | 
| 196 |  |  |  |  |  |  |  | 
| 197 |  |  |  |  |  |  |  | 
| 198 |  |  |  |  |  |  | You can also look for information at: | 
| 199 |  |  |  |  |  |  |  | 
| 200 |  |  |  |  |  |  | =over 4 | 
| 201 |  |  |  |  |  |  |  | 
| 202 |  |  |  |  |  |  | =item * RT: CPAN's request tracker | 
| 203 |  |  |  |  |  |  |  | 
| 204 |  |  |  |  |  |  | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Monitoring-Livestatus-Class> | 
| 205 |  |  |  |  |  |  |  | 
| 206 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 207 |  |  |  |  |  |  |  | 
| 208 |  |  |  |  |  |  | L<http://annocpan.org/dist/Monitoring-Livestatus-Class> | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 211 |  |  |  |  |  |  |  | 
| 212 |  |  |  |  |  |  | L<http://cpanratings.perl.org/d/Monitoring-Livestatus-Class> | 
| 213 |  |  |  |  |  |  |  | 
| 214 |  |  |  |  |  |  | =item * Search CPAN | 
| 215 |  |  |  |  |  |  |  | 
| 216 |  |  |  |  |  |  | L<http://search.cpan.org/dist/Monitoring-Livestatus-Class/> | 
| 217 |  |  |  |  |  |  |  | 
| 218 |  |  |  |  |  |  | =back | 
| 219 |  |  |  |  |  |  |  | 
| 220 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 221 |  |  |  |  |  |  |  | 
| 222 |  |  |  |  |  |  | Copyright 2009 Robert Bohne. | 
| 223 |  |  |  |  |  |  |  | 
| 224 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 225 |  |  |  |  |  |  | under the terms of either: the GNU General Public License as published | 
| 226 |  |  |  |  |  |  | by the Free Software Foundation; or the Artistic License. | 
| 227 |  |  |  |  |  |  |  | 
| 228 |  |  |  |  |  |  | See http://dev.perl.org/licenses/ for more information. | 
| 229 |  |  |  |  |  |  |  | 
| 230 |  |  |  |  |  |  | =cut |