Open reesealexander opened 3 months ago
I did some testing. i was wrong with "zabbix_api.py". it is only used if you use "Monitoring type: Zabbix" in Server Setup. with this it seems to work.
but we use "Monitoring type: ZabbixProblemBased", with this type of server setup the issue accure. if understand the code correct this Monitoring Type did not use the definitions in zabbix_api.py. it use a own written light defintion to connect to the api. and in this implementation i cannot find the fix for zabbix api need "username" from version 6.4 on, and not "user" parameter to logon.
in ZabbixProblemBased.py line 99 login methode is defined with
def login(self, username, password): self.logger.debug("Login in as " + username) self.zbx_auth = self.do_request('user.login', {'user': username, 'password':
password}) `
it should cover zabbix version there, i guess.
ok, more informations. with "Monitoring type: ZabbixProblemBased" using class ZabbixLightApi that didn´t cover zabbix version >=6.4 user usernamen and not user for logon parameter. i have tested it with this code change in "ZabbixProblemBased.py" :
` def api_version(self, **options):
obj = self.do_request('apiinfo.version', options, no_auth=True)
return obj #['result']
def login(self, username, password):
self.logger.debug("Login in as " + username)
# 21.03.2024 a.reese: add to cover zabbix api version login like zabbix_api.py
# check version to use the correct keyword for username which changed since 6.4
if self.api_version() < '6.4':
self.zbx_auth = self.do_request('user.login', {'user': username, 'password': password})
else:
self.zbx_auth = self.do_request('user.login', {'username': username, 'password': password})
`
and with zabbix 6.4.12 it is working for me. i have no zabbix lower than this, to test if it also work with the older version. maybe someone can test and implement this change to the main and create a release with a fix.
I can support that request. I do now have the same issue with Nagstamon 3.14.0.
Side information: Nagstmon 3.10.0 still worked very well with zabbix 6.4.2 for me for many months. Nagstamon 3.12.0 had the same issues with this zabbix 6.4.2, so I kept using 3.10.0. Nagstamon 3.14.0 has the same issue as 3.12.0. With the update of zabbix to 6.4.12 Nagstamon 3.10.0 does no longer work as well.
@reesealexander thanks for your research. I applied your patch and it is available now in latest testing release. Can you please try if it works as expected?
Hi @HenriWahl, if tried to test but the program crash after i have setup a server wit monitoring typ "zabbix server problem based". i have checked your new code and i think you have miss the function definition for "api_version"
Sorry but github or i´m not able to give this code a god looking format in this comment window.
def api_version(self, **options): obj = self.do_request('apiinfo.version', options, no_auth=True) return obj #['result']
thx Alex
@reesealexander I added in into the latest testing release.
Hi @HenriWahl , sorry it is still not working. program just crash after setup a server with monitoring type "zabbix server problem based".
i have taken a look into the function "api_version()" you have implemented into the Nagstamon/Servers/ZabbixProblemBased.py and it is a copy of the some funtions from Nagstamon/thirdparty/zabbix_api.py
during my code changes i have discovered that this is not working due to a problem with the returned object in obj, that not include an array it is juts a string. works for some kind of reason different in the ZabbixProblemBased.py than in zabbix_api.py.
that is why i have changed the funtion to just return the "obj" variable. as you see in my comments from 2 days ago. the ['result'] part is now a comment starting with #.
;-)
Ah OK, I thought this comment was a mistake. 🤪
@reesealexander I rebuilt with your change - can you test the latest testing release? It has the same version number for the sake of faster deployment.
Hi @HenriWahl , now it is working like expected. but i can only test with zabbix version 6.4.12. Maybe some other user can test with older versions of zabbix.
we have update zabbix from 6.4.2 to 6.4.12, after restart of nagstamon it´is not abble to connect to zabbix anymore
actual zabbix version 6.4.12 actual nagstamon version 3.14.0
Error Message: Nagstamon.Servers.ZabbixProblemBased.ZabbixLightApiException: ZBX: <Invalid parameter "/": unexpected parameter "user".
i have tested zabbix api call with method: apiinfo.version and we get "result": "6.4.12"
i don´t understand the complete code but for me it looks like in "zabbix_api.py" function "login" with code:
didn´t work like expected. cause it send "user" parameter to zabbix API and not "username", even zabbix version is higher than 6.4.