Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nagstamon 3.14.0 and 3.10.1 not working with Zabbix 6.4.12 #1018

Open
reesealexander opened this issue Mar 20, 2024 · 10 comments
Open

Nagstamon 3.14.0 and 3.10.1 not working with Zabbix 6.4.12 #1018

reesealexander opened this issue Mar 20, 2024 · 10 comments

Comments

@reesealexander
Copy link

reesealexander commented Mar 20, 2024

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:

        # check version to use the correct keyword for username which changed since 6.4
        if self.api_version() < '6.4':
            username_keyword = 'user'
        else:
            username_keyword = 'username'

didn´t work like expected. cause it send "user" parameter to zabbix API and not "username", even zabbix version is higher than 6.4.

@reesealexander
Copy link
Author

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.

@reesealexander
Copy link
Author

reesealexander commented Mar 21, 2024

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):
# kicked out check auth to be able to check vesion before being logged in to use the correct username keyword
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.

@robertortel
Copy link

robertortel commented Mar 22, 2024

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.

@HenriWahl
Copy link
Owner

@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?

@reesealexander
Copy link
Author

reesealexander commented Mar 25, 2024

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

@HenriWahl
Copy link
Owner

@reesealexander I added in into the latest testing release.

@reesealexander
Copy link
Author

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 #.

;-)

@HenriWahl
Copy link
Owner

Ah OK, I thought this comment was a mistake. 🤪

@HenriWahl
Copy link
Owner

@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.

@reesealexander
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants