Next Change →
side by side
lines around each change
White space changes
08/22/10 18:45:35 (4 years ago)
== Practice ==
=== lua ===
Lua modules are simple text files written in the [http://www.lua.org/ lua programming language]. They are their own packages which must implement 4 functions:
1. '''onload(image)''' - accepts and image and it called once after the module is compiled. It must return 0 on success. The primary use for this function is to call the image.xml_description function with XML documentation for the module you are writing. This allows for automatic documentation generation and online console help.
1. '''config(module, options)''' - run immediately before init and a table of options (from the <config> that applied to this module in noit.conf. It must return 0 on success.
1. '''init(module)''' - run as the module is loaded and initial setup may be performed. Note that state may not be shared between different lua executions. It must return 0 on success.
1. '''initiate(check, config)''' - called each time the check is to be performed. The check contains the attributes of the check itself (target, name, etc.) and metrics, status and availability should be set within this function on the check object.