alerta / zabbix-alerta

Forward Zabbix alerts to the alerta monitoring system
http://alerta.io
MIT License
98 stars 42 forks source link

Python error with the zabbix-alerta #44

Closed Daych closed 3 years ago

Daych commented 3 years ago

I got the error message from the zabbix as below, im using python 2.7.5 and tried to import the configparser, but It cant (but ConfigParser are works) , Im not familiar on python, can you let me know how to fix this error ? Thanks alot

========================================================== Traceback (most recent call last): File "/usr/lib/zabbix/alertscripts/zabbix-alerta", line 9, in load_entry_point('zabbix-alerta==4.0.0', 'console_scripts', 'zabbix-alerta')() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point return ep.load() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load entry = import(self.module_name, globals(),globals(), ['name']) File "build/bdist.linux-x86_64/egg/zabbix_alerta.py", line 6, in ImportError: No module named configparser

Luugui commented 3 years ago

In this case you need to change the module name for ConfigParser inside the script zabbix_alerta.py

before: import configparser after: import ConfigParser

and line 161:

before: parser = configparser.RawConfigParser(defaults=options) after: parser = ConfigParser.RawConfigParser(defaults=options)

Daych commented 3 years ago

Hi Luugui

I just update the string you mentioned (the file on my instance is /usr/local/src/zabbix-alerta/zabbix_alerta.py, but Zabbix also got the same error, but I need to do a zabbix restart or alerta needed ? Thanks again

Luugui commented 3 years ago

Hi Luugui

I just update the string you mentioned (the file on my instance is /usr/local/src/zabbix-alerta/zabbix_alerta.py, but Zabbix also got the same error, but I need to do a zabbix restart or alerta needed ? Thanks again

In error description say the file is build/bdist.linux-x86_64/egg/zabbix_alerta.py

Attempts to make changes to this file

Daych commented 3 years ago

Hi Luugui

Thanks for the information, but I cant find where the zabbix_alerta.py at, by the way I just install the required package needed for the python, but I got the error message from Zabbix is the version of the zabbix-alerta need to be use for Python 2, the message at below. do it means this python script need to be run on Python3 ?

Traceback (most recent call last): File "/usr/lib/zabbix/alertscripts/zabbix-alerta", line 9, in load_entry_point('zabbix-alerta==4.0.0', 'console_scripts', 'zabbix-alerta')() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point return ep.load() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load entry = import(self.module_name, globals(),globals(), ['name']) File "build/bdist.linux-x86_64/egg/zabbixalerta.py", line 10, in File "/usr/lib/python2.7/site-packages/alerta-8.4.0-py2.7.egg/alertaclient/init.py", line 26, in """) ImportError: You are running Alerta 6.0 on Python 2

Alerta 6.0 and above are no longer compatible with Python 2.

Make sure you have pip >= 9.0 to avoid this kind of issue, as well as setuptools >= 24.2:

$ pip install pip setuptools --upgrade

Your choices:

$ pip install 'alerta<6.0'

See the following URL for more up-to-date information:

https://github.com/alerta/alerta/wiki/Python-3

Daych commented 3 years ago

Hi Luugui

I just update to use python3 and it should be OK right now, Thanks again..