Navigation:  LVE-Stats 2 > Creating a Plugin for LVE Stats 2 >


Previous pageReturn to chapter overviewNext page

LVE Stats 2 complex has scalable architecture, which allows to connect custom plugins.


General Information


LVE Stats server searches for plugins in the directory which is specified with plugins parameter of server’s /etc/sysconfig/lvestats2 configuration file. Default directory is /usr/share/lve-stats/plugins.


Each plugin must be of a Python class, must be written in Python language and its file must have .py extension. Files with all other extensions will be ignored. For normal server work access permission 400 is enough; owner – root.


Plugins' classes can be of the same name, but better not, because classes' names can affect the set of parameters in set_config method. You can find detailed plugins' configuring information below, in appropriate chapter.


Plugin's class must contain execute() method, which is invoked by the server every 5 seconds (by default, can be changed by interval parameter of configuration file).

Also set_config method (configuration settings) can be available. You can find more info in Plugins Configuration chapter.


Additionally the following attributes can be set (plugin class instance variable):


order (integer) - defines plugin's position in the server's plugin list, (more info in Servers Plugin Arrangement).

timeout (integer or float) – the longest allowable duration of one launch of the plugin (execute method). Default value of timeout parameter is 5 seconds.

period (integer) – sets the interval between two launches of execute plugin method in seconds. If not defined, then plugin runs every 5 seconds (interval parameter in configuration file).


When execute() method of the plugin is invoked, the server creates an attribute now in it, where launch time is recorded. This value is equal to what a standard Python function time.time() returns. All the plugins launched one after another receive the same  value of now attribute from the server. now is overwritten before execute() method is invoked.


The previous value of now attribute is not saved by the server. If plugin needs it, it has to save it by itself.


Plugin's class can be inherited from LveStatsPlugin class, which is the part of the server itself. This is not obligatory, but inheritance can help to avoid different errors in servers work, particularly if a plugin doesn't contain required execute method.


LveStatsPlugin class is defined in the file: /opt/alt/python27/lib/python2.7/site-packages/lvestats/core/