** Documentation and latest version can be found at: http://trac.red-tux.net/wiki/lua **
This patch is for Zabbix 1.8.3, I will work on a 1.8.4 version soon.
This patch requires no DB changes.
This patch will require a recompile and a reinstall of your php frontend. (same as an upgrade)
You will need to have the lua development libraries installed for this to work.
To install patch
1) Untar zabbix 1.8.3 into a fresh directory
1a) Download patch (see link above)
2) In the new 1.8.3 directory run the following command: patch -p0 < lua-zabbix-1.8.3.patch (if that does not work try patch -p1 < lua-zabbix-1.8.3.patch)
3) Run "configure" with the following option --with-lua
4) compile and install
5) copy frontend directory as you would a normal install/upgrade
So what does this patch do? It allows you to create your own Lua scripts and run them as a normal item. Right now there are only two functions available in the lua script engine, getitem(itemid) (returns val,clock in that order) and zabbix_log(level,message).
Configuring is pretty straight forward as a new item item is added called "Lua Script" (type 16 for those interested). The key just needs to be in the format of lua[unique identifier]. Also it is important that your lua script return a value using the "return" statement.
In addition you can also set up your own lua library. Just point the zabbix_server.conf variable to where you want to load your library for example:
LuaScriptLibrary=/etc/zabbix/lua/zabbix.lua
There is also a configuration option to start more Lua Pollers using
StartLUAPollers, the default value is 1.
In the following example I have created a lua library with the following:
The main goal of this patch is to allow for people to do simple scripting within Zabbix. Imagine if you needed to create a standard deviation function for various items, how would you implement that now? Via an external script which would either query the API or the database directly. Also looking long term I would also like to tie this into triggers, thus allowing for the writing of more complex triggers using Lua. Imagine conditional triggers where the value of one item determines the sensitivity or values a trigger will activate on for other items.
If you have suggestions for the next patch release let me know.
This patch is for Zabbix 1.8.3, I will work on a 1.8.4 version soon.
This patch requires no DB changes.
This patch will require a recompile and a reinstall of your php frontend. (same as an upgrade)
You will need to have the lua development libraries installed for this to work.
To install patch
1) Untar zabbix 1.8.3 into a fresh directory
1a) Download patch (see link above)
2) In the new 1.8.3 directory run the following command: patch -p0 < lua-zabbix-1.8.3.patch (if that does not work try patch -p1 < lua-zabbix-1.8.3.patch)
3) Run "configure" with the following option --with-lua
4) compile and install
5) copy frontend directory as you would a normal install/upgrade
So what does this patch do? It allows you to create your own Lua scripts and run them as a normal item. Right now there are only two functions available in the lua script engine, getitem(itemid) (returns val,clock in that order) and zabbix_log(level,message).
Configuring is pretty straight forward as a new item item is added called "Lua Script" (type 16 for those interested). The key just needs to be in the format of lua[unique identifier]. Also it is important that your lua script return a value using the "return" statement.
In addition you can also set up your own lua library. Just point the zabbix_server.conf variable to where you want to load your library for example:
LuaScriptLibrary=/etc/zabbix/lua/zabbix.lua
There is also a configuration option to start more Lua Pollers using
StartLUAPollers, the default value is 1.
In the following example I have created a lua library with the following:
Code:
function sum(...)
total=0
for i=1,#arg do
total = total + get_item(arg[i])
end
return total
end
If you have suggestions for the next patch release let me know.
Comment