Skip to content

Latest commit

 

History

History
185 lines (108 loc) · 4.82 KB

README.md

File metadata and controls

185 lines (108 loc) · 4.82 KB

NAME

Zabbix::Sender - A pure-perl implementation of zabbix-sender.

SYNOPSIS

This code snippet shows how to send the value "OK" for the item "my.zabbix.item" to the zabbix server/proxy at "my.zabbix.server.example" on port "10055".

use Zabbix::Sender;

my $sender = Zabbix::Sender->new({
   'server' => 'my.zabbix.server.example',
   'port' => 10055,
});
$sender->send('my.zabbix.item','OK');

SUBROUTINES/METHODS

hostname

Name of the host for which to submit items to Zabbix. Initialized by _init_hostname. You can set it either using

$sender->hostname('another.hostname');

or during creation time of Zabbix::Sender

my $sender = Zabbix::Sender->new({
    'server' => 'my.zabbix.server.example',
    'hostname' => 'another.hostname',
});

You can also query the current setting using

my $current_hostname = $sender->hostname();

strict

Use the strict setting to make Zabbix::Sender check the return values from Zabbix:

$sender->strict(1);

You can also query the current setting using

my $is_strict = $sender->strict();

_init_json

Zabbix 1.8 uses a JSON encoded payload after a custom Zabbix header. So this initializes the JSON object.

_init_hostname

The hostname of the sending instance may be given in the constructor.

If not it is detected here.

zabbix_template_1_8

ZABBIX 1.8 TEMPLATE

a4 - ZBXD b - 0x01 V - Length of Request in Bytes (64-bit integer), aligned left, padded with 0x00, low 32 bits V - High 32 bits of length (always 0 in Zabbix::Sender) a* - JSON encoded request

This may be changed to a HashRef if future version of zabbix change the header template.

_encode_request

This method encodes values as a json string and creates the required header according to the template defined above.

_check_info

Checks the return value from the Zabbix server (or Zabbix proxy), which states the number of processed, failed and total values. Returns undef if everything is alright, a message otherwise.

This method is called when the strict setting of Zabbix::Sender is active:

my $sender = Zabbix::Sender->new({
    'server' => 'my.zabbix.server.example',
    'strict' => 1,
});

_decode_answer

This method tries to decode the answer received from the server.

Returns true if response indicates success, false if response indicates failure, undefined value if response was empty or cannot be decoded.

Method "response" may be used to return decoded response.

send

Send the given item with the given value to the server.

Takes two or three scalar arguments: item key, value and clock (clock is optional).

bulk_buf_add

Adds values to the stack of values to bulk_send.

It accepts arguments in forms:

$sender->bulk_buf_add($key, $value, $clock, ...); $sender->bulk_buf_add([$key, $value, $clock], ...); $sender->bulk_buf_add($hostname, [ [$key, $value, $clock], ...], ...);

Last form allows to add values for several hosts at once.

$clock is optional and may be undef, empty or omitted.

Returns true if successful or undef if invalid arguments are specified.

bulk_buf_clear

Clear bulk_send buffer.

bulk_send

Send accumulated values to the server.

It accepts the same arguments as bulk_buf_add. If arguments are specified, they are added to the buffer before sending.

DEMOLISH

Disconnects any open sockets on destruction.

AUTHOR

"Dominik Schulz", <"lkml at ds.gauner.org">

BUGS

Please report any bugs or feature requests to bug-zabbix-sender at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Zabbix-Sender. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Zabbix::Sender

You can also look for information at:

ACKNOWLEDGEMENTS

This code is based on the documentation and sample code found at:

LICENSE AND COPYRIGHT

Copyright 2011 Dominik Schulz.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.