line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zabbix::API::Item; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3596
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
23
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
94
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Params::Validate qw/validate validate_with :types/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
257
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
904
|
use parent qw/Exporter Zabbix::API::CRUDE/; |
|
1
|
|
|
|
|
333
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use constant { |
13
|
1
|
|
|
|
|
986
|
ITEM_TYPE_ZABBIX => 0, |
14
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV1 => 1, |
15
|
|
|
|
|
|
|
ITEM_TYPE_TRAPPER => 2, |
16
|
|
|
|
|
|
|
ITEM_TYPE_SIMPLE => 3, |
17
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV2C => 4, |
18
|
|
|
|
|
|
|
ITEM_TYPE_INTERNAL => 5, |
19
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV3 => 6, |
20
|
|
|
|
|
|
|
ITEM_TYPE_ZABBIX_ACTIVE => 7, |
21
|
|
|
|
|
|
|
ITEM_TYPE_AGGREGATE => 8, |
22
|
|
|
|
|
|
|
ITEM_TYPE_HTTPTEST => 9, |
23
|
|
|
|
|
|
|
ITEM_TYPE_EXTERNAL => 10, |
24
|
|
|
|
|
|
|
ITEM_TYPE_DB_MONITOR => 11, |
25
|
|
|
|
|
|
|
ITEM_TYPE_IPMI => 12, |
26
|
|
|
|
|
|
|
ITEM_TYPE_SSH => 13, |
27
|
|
|
|
|
|
|
ITEM_TYPE_TELNET => 14, |
28
|
|
|
|
|
|
|
ITEM_TYPE_CALCULATED => 15, |
29
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_FLOAT => 0, |
30
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_STR => 1, |
31
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_LOG => 2, |
32
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_UINT64 => 3, |
33
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_TEXT => 4, |
34
|
|
|
|
|
|
|
ITEM_DATA_TYPE_DECIMAL => 0, |
35
|
|
|
|
|
|
|
ITEM_DATA_TYPE_OCTAL => 1, |
36
|
|
|
|
|
|
|
ITEM_DATA_TYPE_HEXADECIMAL => 2, |
37
|
|
|
|
|
|
|
ITEM_STATUS_ACTIVE => 0, |
38
|
|
|
|
|
|
|
ITEM_STATUS_DISABLED => 1, |
39
|
|
|
|
|
|
|
ITEM_STATUS_NOTSUPPORTED => 3 |
40
|
1
|
|
|
1
|
|
97
|
}; |
|
1
|
|
|
|
|
1
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ |
43
|
|
|
|
|
|
|
ITEM_TYPE_ZABBIX |
44
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV1 |
45
|
|
|
|
|
|
|
ITEM_TYPE_TRAPPER |
46
|
|
|
|
|
|
|
ITEM_TYPE_SIMPLE |
47
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV2C |
48
|
|
|
|
|
|
|
ITEM_TYPE_INTERNAL |
49
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV3 |
50
|
|
|
|
|
|
|
ITEM_TYPE_ZABBIX_ACTIVE |
51
|
|
|
|
|
|
|
ITEM_TYPE_AGGREGATE |
52
|
|
|
|
|
|
|
ITEM_TYPE_HTTPTEST |
53
|
|
|
|
|
|
|
ITEM_TYPE_EXTERNAL |
54
|
|
|
|
|
|
|
ITEM_TYPE_DB_MONITOR |
55
|
|
|
|
|
|
|
ITEM_TYPE_IPMI |
56
|
|
|
|
|
|
|
ITEM_TYPE_SSH |
57
|
|
|
|
|
|
|
ITEM_TYPE_TELNET |
58
|
|
|
|
|
|
|
ITEM_TYPE_CALCULATED |
59
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_FLOAT |
60
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_STR |
61
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_LOG |
62
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_UINT64 |
63
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_TEXT |
64
|
|
|
|
|
|
|
ITEM_DATA_TYPE_DECIMAL |
65
|
|
|
|
|
|
|
ITEM_DATA_TYPE_OCTAL |
66
|
|
|
|
|
|
|
ITEM_DATA_TYPE_HEXADECIMAL |
67
|
|
|
|
|
|
|
ITEM_STATUS_ACTIVE |
68
|
|
|
|
|
|
|
ITEM_STATUS_DISABLED |
69
|
|
|
|
|
|
|
ITEM_STATUS_NOTSUPPORTED/; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
72
|
|
|
|
|
|
|
item_types => [ |
73
|
|
|
|
|
|
|
qw/ITEM_TYPE_ZABBIX |
74
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV1 |
75
|
|
|
|
|
|
|
ITEM_TYPE_TRAPPER |
76
|
|
|
|
|
|
|
ITEM_TYPE_SIMPLE |
77
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV2C |
78
|
|
|
|
|
|
|
ITEM_TYPE_INTERNAL |
79
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV3 |
80
|
|
|
|
|
|
|
ITEM_TYPE_ZABBIX_ACTIVE |
81
|
|
|
|
|
|
|
ITEM_TYPE_AGGREGATE |
82
|
|
|
|
|
|
|
ITEM_TYPE_HTTPTEST |
83
|
|
|
|
|
|
|
ITEM_TYPE_EXTERNAL |
84
|
|
|
|
|
|
|
ITEM_TYPE_DB_MONITOR |
85
|
|
|
|
|
|
|
ITEM_TYPE_IPMI |
86
|
|
|
|
|
|
|
ITEM_TYPE_SSH |
87
|
|
|
|
|
|
|
ITEM_TYPE_TELNET |
88
|
|
|
|
|
|
|
ITEM_TYPE_CALCULATED/ |
89
|
|
|
|
|
|
|
], |
90
|
|
|
|
|
|
|
value_types => [ |
91
|
|
|
|
|
|
|
qw/ITEM_VALUE_TYPE_FLOAT |
92
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_STR |
93
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_LOG |
94
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_UINT64 |
95
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_TEXT/ |
96
|
|
|
|
|
|
|
], |
97
|
|
|
|
|
|
|
data_types => [ |
98
|
|
|
|
|
|
|
qw/ITEM_DATA_TYPE_DECIMAL |
99
|
|
|
|
|
|
|
ITEM_DATA_TYPE_OCTAL |
100
|
|
|
|
|
|
|
ITEM_DATA_TYPE_HEXADECIMAL/ |
101
|
|
|
|
|
|
|
], |
102
|
|
|
|
|
|
|
status_types => [ |
103
|
|
|
|
|
|
|
qw/ITEM_STATUS_ACTIVE |
104
|
|
|
|
|
|
|
ITEM_STATUS_DISABLED |
105
|
|
|
|
|
|
|
ITEM_STATUS_NOTSUPPORTED/ |
106
|
|
|
|
|
|
|
] |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub id { |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
## mutator for id |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
114
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
if (defined $value) { |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$self->data->{itemid} = $value; |
118
|
0
|
|
|
|
|
|
return $self->data->{itemid}; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} else { |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return $self->data->{itemid}; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub prefix { |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
0
|
1
|
|
my (undef, $suffix) = @_; |
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
if ($suffix) { |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
return 'item'.$suffix; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} else { |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
return 'item'; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub extension { |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
0
|
1
|
|
return ( output => 'extend' ); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub collides { |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
return @{$self->{root}->query(method => $self->prefix('.get'), |
|
0
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
params => { filter => { key_ => $self->data->{key_} }, |
156
|
|
|
|
|
|
|
hostids => [ $self->host->id ]})}; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub name { |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
return sprintf('%s/%s', |
165
|
0
|
|
0
|
|
|
|
eval { $self->host->name } || '???', |
|
|
|
0
|
|
|
|
|
166
|
|
|
|
|
|
|
$self->data->{key_} || '???'); |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub graphs { |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
## accessor for this item's graphs |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
175
|
|
|
|
|
|
|
|
176
|
0
|
0
|
|
|
|
|
if (defined $value) { |
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
croak 'Accessor graphs called as mutator'; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
} else { |
181
|
|
|
|
|
|
|
|
182
|
0
|
0
|
|
|
|
|
unless (exists ($self->{graphs})) { |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
my $graphs = $self->{root}->fetch('Graph', params => { itemids => [ $self->id ] }); |
185
|
0
|
|
|
|
|
|
$self->{graphs} = $graphs; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
return $self->{graphs}; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub host { |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
## accessor for host |
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
200
|
|
|
|
|
|
|
|
201
|
0
|
0
|
|
|
|
|
if (defined $value) { |
202
|
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
|
croak 'Accessor host called as mutator'; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
} else { |
206
|
|
|
|
|
|
|
|
207
|
0
|
0
|
|
|
|
|
unless (exists $self->{host}) { |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
my $hosts = $self->{root}->fetch('Host', params => { hostids => [ $self->data->{hostid} ] }); |
210
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
|
croak 'Unexpectedly found more than one host for a given item' |
212
|
0
|
0
|
|
|
|
|
if @{$hosts} > 1; |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
$self->{host} = $hosts->[0]; |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
return $self->{host}; |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub history { |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
## accessor for history |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
## DOES NOT CACHE! |
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
231
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
|
my %extra_parameters = validate_with(params => \@_, |
233
|
|
|
|
|
|
|
spec => { time_from => { type => SCALAR, optional => 1 }, |
234
|
|
|
|
|
|
|
time_till => { type => SCALAR, optional => 1 } }, |
235
|
|
|
|
|
|
|
allow_extra => 1); |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
my $history = $self->{root}->query(method => 'history.get', |
238
|
|
|
|
|
|
|
params => { %extra_parameters, |
239
|
|
|
|
|
|
|
itemids => [ $self->id ], |
240
|
|
|
|
|
|
|
output => 'extend' }); |
241
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
return $history; |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub delay { |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
## mutator for the item's polling period |
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
251
|
|
|
|
|
|
|
|
252
|
0
|
0
|
|
|
|
|
if ($value) { |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
$self->data->{delay} = $value; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
return $self->data->{delay}; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
1; |
263
|
|
|
|
|
|
|
__END__ |