Hello.
Trying to run a python script directly from 'Commands' field in 'Actions > Operations', seems the script never runs.
Have hard coded path:

I tested running a shell (.sh) script which works fine, if I try running the same python script from within the shell script it still does not run.
Maybe it suggests there is an issue with Python? I am just writing a simple string to file for testing.
If I 'su - zabbix' and run the Python script is executes OK, just doesn't run from Zabbix.
I have enabled 'Remote Commands' in agent conf file (Not that it is set to execute on the agent anyway).
There are no errors in the server or agent log.
I'm not to sure how to diagnose any further.
Thanks for your help!
Other possible useful info:
OS
/etc/passwd
/etc/sudoers
Python version
Top of Python script
OK. My bad, that was me not hard coding the path to home/zabbix. So I can get a Python script to run, but there is still an issue somewhere, below is log entry from the real script am trying to run. The script updates, a macro field in Zabbix, this is the same script that works fine when run manually under the zabbix account.
I'm a little bit of my depth here.
Trying to run a python script directly from 'Commands' field in 'Actions > Operations', seems the script never runs.
Have hard coded path:
HTML Code:
root@mon-a-tron:/home# ls -l | grep zabbix drwxr-xr-x 5 zabbix zabbix 4096 Feb 8 02:05 zabbix root@mon-a-tron:/home/zabbix# ls -l | grep p.py -rwxrwxr-x 1 zabbix zabbix 344 Feb 8 01:55 p.py
Maybe it suggests there is an issue with Python? I am just writing a simple string to file for testing.
If I 'su - zabbix' and run the Python script is executes OK, just doesn't run from Zabbix.
I have enabled 'Remote Commands' in agent conf file (Not that it is set to execute on the agent anyway).
There are no errors in the server or agent log.
I'm not to sure how to diagnose any further.
Thanks for your help!
Other possible useful info:
OS
HTML Code:
root@mon-a-tron:/home/zabbix# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
HTML Code:
root@mon-a-tron:/home# cat /etc/passwd | grep zabbix/ zabbix:x:113:115::/home/zabbix/:/bin/bash
HTML Code:
root@mon-a-tron:/etc# cat /etc/sudoers Defaults !requiretty zabbix ALL=(ALL:ALL) NOPASSWD: ALL
HTML Code:
root@mon-a-tron:/home/zabbix# python -V Python 2.7.17
HTML Code:
root@mon-a-tron:/home/zabbix# cat p.py #!/usr/bin/env python
HTML Code:
Slight progress, not sure why I have not seen this error before below. It is in Zabbix server log, so look like the issue is within Python or access to Python from the zabbix user account.
1521:20200208:034557.331 Failed to execute command "/home/zabbix/p.py": Traceback (most recent call last):
File "/home/zabbix/p.py", line 14, in <module>
f= open("test99.txt","w+")
IOError: [Errno 13] Permission denied: 'test99.txt'
I'm a little bit of my depth here.
HTML Code:
1521:20200208:040118.043 Failed to execute command "/home/zabbix/zhostupdater.py DEATH-STAR -M SSH.USERNAME.SET=1 /home/zabbix/zhostupdater.py DEATH-STAR -M SSH.USERNAME=abc123": Traceback (most recent call last): File "/home/zabbix/zhostupdater.py", line 30, in <module> defconf = os.getenv("HOME") + "/.zbx.conf" TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' Traceback (most recent call last): File "/home/zabbix/zhostupdater.py", line 30, in <module> defconf = os.getenv("HOME") + "/.zbx.conf" TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Comment