Execute Python Script on Remote Linux Host with Zabbix Agent

Video Lecture

Execute Python Script on Remote Linux Host with Zabbix Agent Execute Python Script on Remote Linux Host with Zabbix Agent Execute Python Script on Remote Linux Host with Zabbix Agent

Description

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.

Note

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

1
2
import random
print(random.randit(0,36))

Zabbix Agent Items

Restricting Agent Checks