Execute Python Script on Remote Linux Host with Zabbix Agent
I create a python script on my remote Linux host that prints a random number. I create a new item for the host and select the system.run option for the key and enter the python command needed to run the new py file on the remote host.
For pre Zabbix 5.02. In the zabbix_agentd.conf for the remote host, add EnableRemoteCommands=1 and then restart the agent process.
In Zabbix 5.0 and 5.01, you will also need to comment out the DenyKey parameter which blocks system.run by default, and then restart the agent process.
In Zabbix 5.02 and later, you can ignore EnableRemoteCommands=1 since it is now deprecated, and you should use a combination of DenyKey and AllowKey to fine tune the scripts you want to deny/allow.
See Restricting agent checks for more info.
Example Python Script
import random print(random.randit(0,36))