|
1 month ago | |
---|---|---|
debian | 11 months ago | |
rockspecs | 11 months ago | |
src | 1 month ago | |
.drone.yml | 11 months ago | |
CHANGELOG.md | 1 month ago | |
LICENSE | 11 months ago | |
README.md | 1 month ago |
A zabbix sender protocol implementation in Lua, for pushing monitoring data to Zabbix trapper items directly from your Lua code.
I am not a programmer, so here’s a warning: This code was written in an exploratory way. If you encounter problems, see something wrong or something was implemented in a weird way, I would be happy if you tell me about it or create a pull request. Thank you. :)
local zbx_sender = require('zabbix-sender')
local sender = zbx_sender.new({
server = 'localhost',
port = 10051,
monitored_host = 'node01'
})
local resp = send:add_item('trap1', 'test1')
:add_item('trap2', 'test2')
:add_item('trap1', 'test1', 'node02')
:send()
print(inspect(resp))
{
failed = 0,
processed = 3,
total = 3
}
new([opts])
Creates a new zabbix sender.
Parameter:
localhost
)10051
)nil
)opts.nanoseconds
is set to true
opts.timestamps
is set to true
too (default=false
)false
)0.5
)Returns:
(table) zabbix sender
add_item(key, value[, mhost])
Adds an item to the request payload. The item(s) are stored until send()
is invoked. Multiple calls to add_item()
can be chained and completed by a final call to send()
. See example above.
Parameter:
Returns:
(table) self
Raises:
key
or value
is missinghost
is missing and monitored_host
was not setadd_items(items)
Adds multiple items from a given table. The items
table is an array of tables in the format of:
{
{ 'key1', 'val1', 'host1' },
{ 'key2', 'val2', 'host2' },
...
}
Parameter:
Returns:
(table) self
Raises:
items
is not given or not a table
clear()
Removes all unsent items.
Returns:
(nil)
has_unsent_items()
Returns if there are unsent items and the number of unset items.
Returns:
send()
Sends all added items.
Returns:
false
in case of error