All development in this repositoryy is frozen. Future development will continue here https://github.com/vulogov/zlm-cython
The pyzabbix-agent
loadable module is a way to extend zabbix_agentd
daemon
with Python. The main goal is to avoid costly and slow exec calls and
loading of the interpreter.
At this moment, I do not recommend to use this module in a production environment. There are bugs. There are undetected issues.
-
Check the include path and compilation parameters in
Makefile
and runmake
. -
Copy
python.so
to the directory defined byLoadModulePath
inzabbix_agentd.conf
-
Create subdirectory
pymodules
in the directory where your configuration file is installed -
Install the Python Zabbix modules in this directory.
-
Add
LoadModule=python.so
in yourzabbix_agentd.conf
. -
Set the
PYTHONPATH
as:
export PYTHONPATH=`python -c "import sys; print ':'.join(sys.path)"`
This is not mandatory anymore, if PYTHONPATH is not defined, module will discover it from Python interpreter.
- Restart
zabbix_agentd
This is a regular python module, where you shall define function main(*args). All arguments passed from Zabbix to an agent, will be passed to a main() functions as srings. The return value will be returned to Zabbix. Only Int, Long, Float and String information types are supported as return values.
These modules perform some special actions.
-
ZBX_startup.py
- module, which main() function will be executed duringzabbix_agentd
startup -
ZBX_finish.py
- module, which main() function will be executed duringzabbix_agentd
finish
The following item keys are supported:
python.ping
- no parameters. Return 1 if embedded Python is initializedpython.version
- returns version of the embedded Python interpreterpython
- calling the Python Zabbix module. The first parameter is the name of the module, the next parameters will be passed to the main() function of the module.python.prof
- same aspython
, but instead returning the value, returns execution time of the module in miliseconds.py[]
- same aspython[]
, but wrapping module interface through ZBX_call.py. In addition to a callingmain()
function of the module, can call any function and also read data from pre-spawned agents and a Redis queues.