Changes between Version 1 and Version 2 of WritingModulesHowTo

Show
Ignore:
Author:
jesus (IP: 8.8.38.2)
Timestamp:
08/22/10 18:45:35 (4 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WritingModulesHowTo

    v1 v2  
    1111 
    1212== Practice == 
     13 
     14=== lua === 
     15 
     16Lua 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: 
     17 
     18 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. 
     19 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. 
     20 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. 
     21 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.