About this library
The library is an implementation of zabbix_sender
utility, which sends items data to zabbix server
using the zabbix trapper
protocol. Because the library is a pure Node.js/Javascript implementation, it doesn't
require invocation of zabbix_sender
utility. So there is no any child_process
involved!
Basic usage example
var ZabbixSender = ;var Sender = host: 'zabbix.example.com'; // Add items to requestSender;Sender; // Add item with default hostSender; // Send the items to zabbix trapperSender;
addItem
& send
combined
Another example, with var ZabbixSender = ;var Sender = host: 'zabbix.example.com'; // addItem supports chaining// Here is an example: add item and & send itSender;
Instance options
Whenever you create a new instance of zabbix sender, you can pass an options object (e.g new ZabbixSender(opts)
)
here are the options defaults:
host: 'localhost' port: 10051 timeout: 5000 with_ns: false with_timestamps: false items_host: hostname
host
andport
are self-explanatory, the zabbix server host & porttimeout
is a socket timeout in milliseconds, when connecting to the zabbix serverwith_timestamps
when youaddItem
, timestamp will be added as wellwith_ns
implieswith_timestamps
, nanoseconds portion of the timestamp seconds will be added to the itemitems_host
a target monitored host in zabbix. used when you don't specify the host when youaddItem
, see example above
Instance methods
addItem([host], key, value)
Adds an item to the request payload. The item data won't be sent until the send
method invoked.
The return
value is self instance, so chaining can be used.
clearItems()
Clears the previously added items (if any). Mostly used internally, but you can use this method,
if you want to make sure no orphan items are present. The return
value is self instance, so chaining can be used.
countItems()
Just returns the number of unsent items.
send(callback)
Sends all items that were added to the request payload.
The callback function passes 3 arguments error
(if any), the response
from zabbix server (trapper),
and the items
array of item objects. The send
method clears items that were previously added.
In case of error
, the previously added items will be kept, for the next send
invocation.
Protocol References
- https://www.zabbix.org/wiki/Docs/protocols/zabbix_sender/3.4
- https://www.zabbix.org/wiki/Docs/protocols/zabbix_agent/3.4
License
Licensed under the MIT License. See the LICENSE file for details.