… | |
… | |
84 | |
84 | |
85 | Called on any protocol errors - these generally indicate that something |
85 | Called on any protocol errors - these generally indicate that something |
86 | other than a zabbix server is running on a port. The given key-value pairs |
86 | other than a zabbix server is running on a port. The given key-value pairs |
87 | are the lost items. |
87 | are the lost items. |
88 | |
88 | |
89 | =item on_loss => $cb->$zbx, (\@items) (default: log and continue) |
89 | =item on_loss => $cb->($zbx, \@items) (default: log and continue) |
90 | |
90 | |
91 | Will be called when some data items are thrown away (this happens if the |
91 | Will be called when some data items are thrown away (this happens if the |
92 | server isn't reachable for at least C<queue_time> seconds), |
92 | server isn't reachable for at least C<queue_time> seconds), |
93 | |
93 | |
94 | =item on_response => $cb->$zbx, (\@items, \%response) (default: not called) |
94 | =item on_response => $cb->($zbx, \@items, \%response) (default: not called) |
95 | |
95 | |
96 | Will be called with the (generally rather useless) response form the |
96 | Will be called with the (generally rather useless) response form the |
97 | zabbix server. |
97 | zabbix server. |
98 | |
98 | |
99 | =back |
99 | =back |
… | |
… | |
218 | $fh |
218 | $fh |
219 | or return $self->_retry; |
219 | or return $self->_retry; |
220 | |
220 | |
221 | delete $self->{retry}; |
221 | delete $self->{retry}; |
222 | |
222 | |
|
|
223 | delete $self->{send_immediate}; |
223 | my $data = delete $self->{queue}; |
224 | my $data = delete $self->{queue}; |
224 | my $items = [map @{ $_->[1] }, @$data]; |
225 | my $items = [map @{ $_->[1] }, @$data]; |
225 | |
226 | |
226 | my $fail = sub { |
227 | my $fail = sub { |
227 | $self->{on_error}($self, $items, $_[0]); |
228 | $self->{on_error}($self, $items, $_[0]); |
… | |
… | |
260 | }, |
261 | }, |
261 | ; |
262 | ; |
262 | |
263 | |
263 | my $json = $json->encode ({ |
264 | my $json = $json->encode ({ |
264 | request => "sender data", |
265 | request => "sender data", |
265 | clock => AE::now, |
266 | clock => int AE::now, |
266 | data => [ |
267 | data => [ |
267 | map { |
268 | map { |
268 | my $slot = $_; |
269 | my $slot = $_; |
269 | |
270 | |
270 | map { |
271 | map { |
271 | key => $_->[0], |
272 | key => $_->[0], |
272 | value => $_->[1], |
273 | value => $_->[1], |
273 | clock => $_->[2] // $slot->[0], |
274 | clock => int ($_->[2] // $slot->[0]), |
274 | host => $_->[3] // $self->{host}, |
275 | host => $_->[3] // $self->{host}, |
275 | }, @{ $slot->[1] } |
276 | }, @{ $slot->[1] } |
276 | } @$data |
277 | } @$data |
277 | ], |
278 | ], |
278 | }); |
279 | }); |