line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Monitoring::TT::Object::Host; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
90
|
|
4
|
4
|
|
|
4
|
|
14
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
82
|
|
5
|
4
|
|
|
4
|
|
13
|
use utf8; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
14
|
|
6
|
4
|
|
|
4
|
|
57
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
201
|
|
7
|
4
|
|
|
4
|
|
19
|
use base 'Monitoring::TT::Object'; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
1911
|
|
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
|
|
|
0
|
1
|
|
my($class, $self) = @_; |
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
|
|
|
0
|
1
|
|
my( $self, $app, $val ) = @_; |
45
|
0
|
|
|
|
|
|
$self->{'montt'}->{'hostspossible_apps'}->{$app} = 1; |
46
|
0
|
|
0
|
|
|
|
return &Monitoring::TT::Object::_has_something($self, 'extra_apps', $app, $val) || &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
|
|
|
0
|
1
|
|
my( $self, $app, $val ) = @_; |
59
|
0
|
0
|
|
|
|
|
croak('app() does not accept value, use has_app() instead') if $val; |
60
|
0
|
|
|
|
|
|
$app = lc $app; |
61
|
0
|
|
|
|
|
|
$self->{'montt'}->{'hostspossible_apps'}->{$app} = 1; |
62
|
0
|
0
|
0
|
|
|
|
if($self->{'extra_apps'}->{$app} and $self->{'apps'}->{$app}) { |
63
|
0
|
|
|
|
|
|
my @list = @{$self->{'extra_apps'}->{$app}}; |
|
0
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
push @list, ref $self->{'apps'}->{$app} eq 'ARRAY' ? @{$self->{'apps'}->{$app}} : $self->{'apps'}->{$app}; |
|
0
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return(Monitoring::TT::Utils::get_uniq_sorted(\@list)); |
66
|
|
|
|
|
|
|
} |
67
|
0
|
0
|
|
|
|
|
return $self->{'extra_apps'}->{$app} if $self->{'extra_apps'}->{$app}; |
68
|
0
|
0
|
|
|
|
|
return $self->{'apps'}->{$app} if $self->{'apps'}->{$app}; |
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
|
|
|
0
|
1
|
|
my( $self ) = @_; |
81
|
0
|
0
|
|
|
|
|
return $self->{'apps'} if exists $self->{'apps'}; |
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
|
|
|
0
|
1
|
|
my( $self ) = @_; |
94
|
0
|
0
|
|
|
|
|
return $self->{'extra_apps'} if exists $self->{'extra_apps'}; |
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
|
|
|
0
|
1
|
|
my( $self, $app, $val ) = @_; |
107
|
0
|
|
|
|
|
|
return $self->_set_something('extra_apps', $app, $val); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
##################################################################### |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Sven Nierlein, 2013, |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |