line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zabbix::API::Item; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2338
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
22
|
use 5.010; |
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
65
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
430
|
use parent qw/Exporter Zabbix::API::CRUDE/; |
|
1
|
|
|
|
|
282
|
|
|
1
|
|
|
|
|
3
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use constant { |
11
|
1
|
|
|
|
|
614
|
ITEM_TYPE_ZABBIX => 0, |
12
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV1 => 1, |
13
|
|
|
|
|
|
|
ITEM_TYPE_TRAPPER => 2, |
14
|
|
|
|
|
|
|
ITEM_TYPE_SIMPLE => 3, |
15
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV2C => 4, |
16
|
|
|
|
|
|
|
ITEM_TYPE_INTERNAL => 5, |
17
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV3 => 6, |
18
|
|
|
|
|
|
|
ITEM_TYPE_ZABBIX_ACTIVE => 7, |
19
|
|
|
|
|
|
|
ITEM_TYPE_AGGREGATE => 8, |
20
|
|
|
|
|
|
|
ITEM_TYPE_HTTPTEST => 9, |
21
|
|
|
|
|
|
|
ITEM_TYPE_EXTERNAL => 10, |
22
|
|
|
|
|
|
|
ITEM_TYPE_DB_MONITOR => 11, |
23
|
|
|
|
|
|
|
ITEM_TYPE_IPMI => 12, |
24
|
|
|
|
|
|
|
ITEM_TYPE_SSH => 13, |
25
|
|
|
|
|
|
|
ITEM_TYPE_TELNET => 14, |
26
|
|
|
|
|
|
|
ITEM_TYPE_CALCULATED => 15, |
27
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_FLOAT => 0, |
28
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_STR => 1, |
29
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_LOG => 2, |
30
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_UINT64 => 3, |
31
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_TEXT => 4, |
32
|
|
|
|
|
|
|
ITEM_DATA_TYPE_DECIMAL => 0, |
33
|
|
|
|
|
|
|
ITEM_DATA_TYPE_OCTAL => 1, |
34
|
|
|
|
|
|
|
ITEM_DATA_TYPE_HEXADECIMAL => 2, |
35
|
|
|
|
|
|
|
ITEM_STATUS_ACTIVE => 0, |
36
|
|
|
|
|
|
|
ITEM_STATUS_DISABLED => 1, |
37
|
|
|
|
|
|
|
ITEM_STATUS_NOTSUPPORTED => 3 |
38
|
1
|
|
|
1
|
|
66
|
}; |
|
1
|
|
|
|
|
2
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ |
41
|
|
|
|
|
|
|
ITEM_TYPE_ZABBIX |
42
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV1 |
43
|
|
|
|
|
|
|
ITEM_TYPE_TRAPPER |
44
|
|
|
|
|
|
|
ITEM_TYPE_SIMPLE |
45
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV2C |
46
|
|
|
|
|
|
|
ITEM_TYPE_INTERNAL |
47
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV3 |
48
|
|
|
|
|
|
|
ITEM_TYPE_ZABBIX_ACTIVE |
49
|
|
|
|
|
|
|
ITEM_TYPE_AGGREGATE |
50
|
|
|
|
|
|
|
ITEM_TYPE_HTTPTEST |
51
|
|
|
|
|
|
|
ITEM_TYPE_EXTERNAL |
52
|
|
|
|
|
|
|
ITEM_TYPE_DB_MONITOR |
53
|
|
|
|
|
|
|
ITEM_TYPE_IPMI |
54
|
|
|
|
|
|
|
ITEM_TYPE_SSH |
55
|
|
|
|
|
|
|
ITEM_TYPE_TELNET |
56
|
|
|
|
|
|
|
ITEM_TYPE_CALCULATED |
57
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_FLOAT |
58
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_STR |
59
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_LOG |
60
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_UINT64 |
61
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_TEXT |
62
|
|
|
|
|
|
|
ITEM_DATA_TYPE_DECIMAL |
63
|
|
|
|
|
|
|
ITEM_DATA_TYPE_OCTAL |
64
|
|
|
|
|
|
|
ITEM_DATA_TYPE_HEXADECIMAL |
65
|
|
|
|
|
|
|
ITEM_STATUS_ACTIVE |
66
|
|
|
|
|
|
|
ITEM_STATUS_DISABLED |
67
|
|
|
|
|
|
|
ITEM_STATUS_NOTSUPPORTED/; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
70
|
|
|
|
|
|
|
item_types => [ |
71
|
|
|
|
|
|
|
qw/ITEM_TYPE_ZABBIX |
72
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV1 |
73
|
|
|
|
|
|
|
ITEM_TYPE_TRAPPER |
74
|
|
|
|
|
|
|
ITEM_TYPE_SIMPLE |
75
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV2C |
76
|
|
|
|
|
|
|
ITEM_TYPE_INTERNAL |
77
|
|
|
|
|
|
|
ITEM_TYPE_SNMPV3 |
78
|
|
|
|
|
|
|
ITEM_TYPE_ZABBIX_ACTIVE |
79
|
|
|
|
|
|
|
ITEM_TYPE_AGGREGATE |
80
|
|
|
|
|
|
|
ITEM_TYPE_HTTPTEST |
81
|
|
|
|
|
|
|
ITEM_TYPE_EXTERNAL |
82
|
|
|
|
|
|
|
ITEM_TYPE_DB_MONITOR |
83
|
|
|
|
|
|
|
ITEM_TYPE_IPMI |
84
|
|
|
|
|
|
|
ITEM_TYPE_SSH |
85
|
|
|
|
|
|
|
ITEM_TYPE_TELNET |
86
|
|
|
|
|
|
|
ITEM_TYPE_CALCULATED/ |
87
|
|
|
|
|
|
|
], |
88
|
|
|
|
|
|
|
value_types => [ |
89
|
|
|
|
|
|
|
qw/ITEM_VALUE_TYPE_FLOAT |
90
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_STR |
91
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_LOG |
92
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_UINT64 |
93
|
|
|
|
|
|
|
ITEM_VALUE_TYPE_TEXT/ |
94
|
|
|
|
|
|
|
], |
95
|
|
|
|
|
|
|
data_types => [ |
96
|
|
|
|
|
|
|
qw/ITEM_DATA_TYPE_DECIMAL |
97
|
|
|
|
|
|
|
ITEM_DATA_TYPE_OCTAL |
98
|
|
|
|
|
|
|
ITEM_DATA_TYPE_HEXADECIMAL/ |
99
|
|
|
|
|
|
|
], |
100
|
|
|
|
|
|
|
status_types => [ |
101
|
|
|
|
|
|
|
qw/ITEM_STATUS_ACTIVE |
102
|
|
|
|
|
|
|
ITEM_STATUS_DISABLED |
103
|
|
|
|
|
|
|
ITEM_STATUS_NOTSUPPORTED/ |
104
|
|
|
|
|
|
|
] |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub id { |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
## mutator for id |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
if (defined $value) { |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$self->data->{itemid} = $value; |
116
|
0
|
|
|
|
|
|
return $self->data->{itemid}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} else { |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
return $self->data->{itemid}; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub prefix { |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
0
|
1
|
|
my (undef, $suffix) = @_; |
129
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
if ($suffix) { |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
return 'item'.$suffix; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} else { |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
return 'item'; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub extension { |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
0
|
1
|
|
return ( output => 'extend' ); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub collides { |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
return @{$self->{root}->query(method => $self->prefix('.get'), |
153
|
|
|
|
|
|
|
params => { filter => { key_ => $self->data->{key_} }, |
154
|
0
|
|
|
|
|
|
hostids => [ $self->host->id ]})}; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub name { |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
return sprintf('%s/%s', |
163
|
|
|
|
|
|
|
eval { $self->host->name } || '???', |
164
|
0
|
|
0
|
|
|
|
$self->data->{key_} || '???'); |
|
|
|
0
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub host { |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
## accessor for host |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
173
|
|
|
|
|
|
|
|
174
|
0
|
0
|
|
|
|
|
if (defined $value) { |
175
|
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
croak 'Accessor host called as mutator'; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
} else { |
179
|
|
|
|
|
|
|
|
180
|
0
|
0
|
|
|
|
|
unless (exists $self->{host}) { |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
my $hosts = $self->{root}->fetch('Host', params => { hostids => [ $self->data->{hostid} ] }); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
croak 'Unexpectedly found more than one host for a given item' |
185
|
0
|
0
|
|
|
|
|
if @{$hosts} > 1; |
|
0
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
$self->{host} = $hosts->[0]; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
return $self->{host}; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
1; |
198
|
|
|
|
|
|
|
__END__ |