'Can't execute external script from zabbix

I'm trying to execute script from zabbix ui. I put my script to '/usr/lib/zabbix/externalscripts' folder. The script's name is "check_ssl.py". When I connect to server and go to that folder and execute the script manually - it works, but when I try to execute it from zabbix's ui - it throws an error :

"Traceback (most recent call last):
  File "/usr/lib/zabbix/externalscripts/check_ssl.py", line 14, in <module>
    ACCESS_KEY = conf('ACCESS_KEY')
  File "/usr/local/lib/python3.8/dist-packages/decouple.py", line 243, in __call__
    return self.config(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/decouple.py", line 105, in __call__
    return self.get(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/decouple.py", line 90, in get
    raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: ACCESS_KEY not found. Declare it as envvar or define a default value." 

ACCESS_KEY variable is declared and set as env. variable. Does anyone know why it throws this error?



Solution 1:[1]

The service environment is different from other users' env, see https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service

Edit the service with systemctl edit zabbix-server and add Environment="ACCESS_KEY=your_access_key" in the [Service] section.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Iron Bishop