Zabbix Lua Patch version 1.8.5-p1
Installation
To install this patch:
- Download a fresh Zabbix-1.8.5 and untar
- Download patch http://trac.red-tux.net/export/311/trunk/lua/patches/1.8.5-p1-lua.patch
- cd to new Zabbix-1.8.5 directory and run the following command
patch -p1 < (path_to_patch)1.8.5-p1-lua.patch
- configure with the --with-lua option.
If you experience an error try running the bootstrap.sh script in the zabbix-1.8.5 directory. This script rebuilds the autoconf files use by the configure script.
Alternatively, you can check out a fully patched version of Zabbix:
http://svn.red-tux.net/trunk/lua/1.8.5/
or
svn co http://svn.red-tux.net/trunk/lua/1.8.5/
Changes from previous versions
- Return varlues for get_item have been reversed, get_last now returns (clock, value) not (value, clock) as before.
This allows for something like the followingreturn get_item(12345)
Which will now return the latest value of item 12345 - get_last has an optional second argument, nodeid.
- Lua item keys no longer have to start with lua and have one or more parameters.
The key for your Lua item can now be:this_is_my_lua_key
Ideas
Reference
Config file options
| Option | Deffault Value | Description |
| StartLUAPollers | 1 | The number of Lua pollers to fork |
| LuaScriptLibrary | (none) | The location where the lua script library cab be found |
| LuaCheckPermissions | 0 | 0=off, 1=on Turns on permissions checking for database related Lua commands |
| LuaDefaltUser | guest | The default user to use should the user information not be provided |
| LuaTimeout | 15 | Range 0-60, Default timeout for Lua Scripts |
Global Variables
| Name | Value |
| LOG_LEVEL_EMPTY | 0 |
| LOG_LEVEL_CRIT | 1 |
| LOG_LEVEL_ERR | 2 |
| LOG_LEVEL_WARNING | 3 |
| LOG_LEVEL_DEBUG | 4 |
| ARGC | number, the number of arguments passed in |
| ARGV | Array (table) of arguments passed in, base index is 1 |
| zbx_host | Host name associated with Lua Script |
| zbx_hostid | Hostid (int64) associated with Lua Script |
Functions
| Name | Description |
| zabbix_log (level,text) | The level is one of the LOG_LEVEL_* variables, at this point only one text value can be passed in |
| (time) now() | Returns the current number of seconds since the epoch (Unix Time). |
| (clock, value) get_last(itemid, nodeid=0) | Returns two items, the last value stored for itemid, and the clock value for that data point. Presently this function only supports values in the history_uint table. |
| (itemid) get_itemid (host,key) | returns an int64 value representing the item id associated with the host:key. |