line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Monitoring::TT::Object::Host; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
117
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
90
|
|
5
|
4
|
|
|
4
|
|
20
|
use utf8; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
26
|
|
6
|
4
|
|
|
4
|
|
81
|
use Carp; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
222
|
|
7
|
4
|
|
|
4
|
|
18
|
use base 'Monitoring::TT::Object'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1894
|
|
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
|
|
|
|
|
|
$app = lc $app; |
46
|
0
|
|
|
|
|
|
$self->{'montt'}->{$self->{'object_type'}.'spossible_apps'}->{$app} = 1; |
47
|
0
|
|
0
|
|
|
|
return $self->_has_something('extra_apps', $app, $val) || $self->_has_something('apps', $app, $val); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
##################################################################### |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 app |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
returns value of this app or empty string if not set |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
sub app { |
59
|
0
|
|
|
0
|
1
|
|
my( $self, $app, $val ) = @_; |
60
|
0
|
0
|
|
|
|
|
croak('app() does not accept value, use has_app() instead') if $val; |
61
|
0
|
|
|
|
|
|
$app = lc $app; |
62
|
0
|
|
|
|
|
|
$self->{'montt'}->{$self->{'object_type'}.'spossible_apps'}->{$app} = 1; |
63
|
0
|
0
|
0
|
|
|
|
if($self->{'extra_apps'}->{$app} and $self->{'apps'}->{$app}) { |
64
|
0
|
|
|
|
|
|
my @list = @{$self->{'extra_apps'}->{$app}}; |
|
0
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
push @list, ref $self->{'apps'}->{$app} eq 'ARRAY' ? @{$self->{'apps'}->{$app}} : $self->{'apps'}->{$app}; |
|
0
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return(Monitoring::TT::Utils::get_uniq_sorted(\@list)); |
67
|
|
|
|
|
|
|
} |
68
|
0
|
0
|
|
|
|
|
return $self->{'extra_apps'}->{$app} if $self->{'extra_apps'}->{$app}; |
69
|
0
|
0
|
|
|
|
|
return $self->{'apps'}->{$app} if $self->{'apps'}->{$app}; |
70
|
0
|
|
|
|
|
|
return ""; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
##################################################################### |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 apps |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
returns list of apps or empty list otherwise |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
sub apps { |
81
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
82
|
0
|
0
|
|
|
|
|
return $self->{'apps'} if exists $self->{'apps'}; |
83
|
0
|
|
|
|
|
|
return []; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
##################################################################### |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 extra_apps |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
returns list of extra apps or empty list otherwise |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
sub extra_apps { |
94
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
95
|
0
|
0
|
|
|
|
|
return $self->{'extra_apps'} if exists $self->{'extra_apps'}; |
96
|
0
|
|
|
|
|
|
return []; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
##################################################################### |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 set_app |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
set additional app |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
sub set_app { |
107
|
0
|
|
|
0
|
1
|
|
my( $self, $app, $val ) = @_; |
108
|
0
|
|
|
|
|
|
return $self->_set_something('extra_apps', $app, $val); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
##################################################################### |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Sven Nierlein, 2013, |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |