| 1 | package Monitoring::TT::Object::Host; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use base 'Monitoring::TT::Object'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | ##################################################################### | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Monitoring::TT::Object::Host - Object representation of a host | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | contains generic methods which can be used in templates for each object | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | ##################################################################### | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head1 METHODS | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head2 BUILD | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | return new object | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||
| 30 | sub BUILD { | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my($class, $self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 33 | 0 | return $self; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | ##################################################################### | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head2 has_app | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | returns true if object has specific app, false otherwise. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||
| 43 | sub has_app { | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my( $self, $app, $val ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
has_app: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 0 | $self->{'montt'}->{'hostspossible_apps'}->{$app} = 1; | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | return &Monitoring::TT::Object::_has_something($self, 'extra_apps', $app, $val) || &Monitoring::TT::Object::_has_something($self, 'apps', $app, $val); | ||||||||||||||||||||||||||
|
Condition0%0/3
&Monitoring::TT::Object::_has_something($self, 'extra_apps', $app, $val) || &Monitoring::TT::Object::_has_something($self, 'apps', $app, $val)
MC/DC0%0/2
&Monitoring::TT::Object::_has_something($self, 'extra_apps', $app, $val) || &Monitoring::TT::Object::_has_something($self, 'apps', $app, $val)
&Monitoring::TT::Object::_has_something($self, 'extra_apps', $app, $val)
&Monitoring::TT::Object::_has_something($self, 'apps', $app, $val)
Truth table0%0/3
A || B
A= &Monitoring::TT::Object::_has_something($self, 'extra_apps', $app, $val)B= &Monitoring::TT::Object::_has_something($self, 'apps', $app, $val)
| |||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | ##################################################################### | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head2 app | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | returns value of this app or empty string if not set | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||
| 57 | sub app { | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | my( $self, $app, $val ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
app: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | croak('app() does not accept value, use has_app() instead') if $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | $app = lc $app; | |||||||||||||||||||||||||||
| 61 | 0 | $self->{'montt'}->{'hostspossible_apps'}->{$app} = 1; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | if($self->{'extra_apps'}->{$app} and $self->{'apps'}->{$app}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"extra_apps"}{$app} and $self->{"apps"}{$app}
MC/DC0%0/2
$self->{"extra_apps"}{$app} and $self->{"apps"}{$app}
$self->{"extra_apps"}{$app}
$self->{"apps"}{$app}
Truth table0%0/3
A and B
A= $self->{"extra_apps"}{$app}B= $self->{"apps"}{$app}
| |||||||||||||||||||||||||||||
| 63 | 0 | my @list = @{$self->{'extra_apps'}->{$app}}; | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | push @list, ref $self->{'apps'}->{$app} eq 'ARRAY' ? @{$self->{'apps'}->{$app}} : $self->{'apps'}->{$app}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | return(Monitoring::TT::Utils::get_uniq_sorted(\@list)); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | return $self->{'extra_apps'}->{$app} if $self->{'extra_apps'}->{$app}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | return $self->{'apps'}->{$app} if $self->{'apps'}->{$app}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | return ""; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | ##################################################################### | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head2 apps | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | returns list of apps or empty list otherwise | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =cut | ||||||||||||||||||||||||||||
| 79 | sub apps { | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
apps: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | return $self->{'apps'} if exists $self->{'apps'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | return []; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | ##################################################################### | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =head2 extra_apps | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | returns list of extra apps or empty list otherwise | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||
| 92 | sub extra_apps { | ||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
extra_apps: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return $self->{'extra_apps'} if exists $self->{'extra_apps'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | return []; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | ##################################################################### | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head2 set_app | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | set additional app | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||||||||||
| 105 | sub set_app { | ||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my( $self, $app, $val ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
set_app: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 0 | return $self->_set_something('extra_apps', $app, $val); | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | ##################################################################### | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | Sven Nierlein, 2013, <sven.nierlein@consol.de> | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =cut | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 4 | 1; | |||||||||||||||||||||||||||