core: Zabbix integration unable to login.
The problem
I ran the zabbix integration for over a year now, and since a few months I get the error “Unable to login to the zabbix api”. I ran Zabbix 6.4 beta 3 with succes, but since beta 4 the message appears so I guess they made changes to the api.
What version of Home Assistant Core has the issue?
2023.1.7
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Zabbix
Link to integration documentation on our website
https://www.home-assistant.io/integrations/zabbix/
Diagnostics information
No response
Example YAML snippet
zabbix:
host: xxx.xxx.xxx.xxx
path: /
ssl: false
username: Admin
password: ***
publish_states_host: hostname-of-has
exclude:
domains:
- device_tracker
entities:
- sun.sun
- sensor.time
Anything in the logs that might be useful for us?
2023-01-29 07:22:17.741 ERROR (SyncWorker_5) [homeassistant.components.zabbix] Unable to login to the Zabbix API: {'code': -32602, 'message': 'Invalid params.', 'data': 'Invalid parameter "/": unexpected parameter "user".', 'json': "{'jsonrpc': '2.0', 'method': 'user.login', 'params': {'user': 'Admin', 'password': '********'}, 'id': '1'}"}
2023-01-29 07:22:17.830 ERROR (MainThread) [homeassistant.setup] Setup failed for zabbix: Integration failed to initialize.
Additional information
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 6
- Comments: 100 (19 by maintainers)
Yes, I am working to rewrite the integration to work with that module.
I get it working against Zabbix 6.4 by patching the file pyzabbix/api.py
However the simplest fix would be to change underlaying library from the current (unmaintained) https://github.com/adubkov/py-zabbix
to newer (maintained) https://github.com/lukecyca/pyzabbix/
This replacement will fix the current issue and in addition will also allow to use the Apikey authentication instead.
Yes, you’re right, this seems to be the more strightforward and stable way (from my personal today’s view at least…)
What I have in mind (additionally) is some discovery that
So I can neatlessly switch…
I had the same problem, and in the end, I went the API route. And ultimately, it’s a better solution for me. I’ve created a brief tutorial:
Monitoring HA in Zabbix
I have created https://github.com/home-assistant/core/pull/110132 if somebody wants to review it 😃
Just after after I was done implementing the zabbix api and the user login I realized that this is completely unnecessary if you only want to send metrics to zabbix … 🤦
Me, I am NOT using the number of active triggers. I am only using the sensors being mirrored from ha to zabbix.
Yes, I started with this one, with the devcontainers via WSL. This is how I was testing the PRs. But there are a lot of other to read. And this one from Config Flow - “Integrations with a config flow require full test coverage of all code in config_flow.py to be accepted into core.” raises the bar even higher for the begginers.
Anyway, I’ll try, but no promises about the timeline.
Thanks for your tests! Yep. Will update. I will need to make a seperate PR to update the documentation for homeassistant anyways.
No, this should be OK. Reviews are for the maintainers of homeassistant. They will probably have something to remark as well 😃
Hi @WebSpider I’ve tested the PR and it is working fine. I am able to receive the information to the zabbix server from the HA running with this PR. However I have comment on the PR description - “This moves the support for zabbix from the unmaintained py-zabbix library to the maintained pyzabbix library…” is not correct, it should be “… from the unmaintained py-zabbix library to the maintained zabbix library …” as in
manifest.jsonit is now"requirements": ["zabbix==2.0.2"].P.S. Do you want me to copy the same to the PR comments / reviews?
I’m working on a PR today, apologies for the delay 😃
The version of Zabbix server is supported and available prior to any authentication calls: https://www.zabbix.com/documentation/current/en/manual/api/reference/apiinfo/version
and is also properly handled in the newer pyzabix library implementation: https://github.com/lukecyca/pyzabbix
Douing a deeper dive into this
https://github.com/adubkov/py-zabbix/pull/155
In all fairnerss would be a fix, The maintainer seems to be gone offline on GH tho.
Why? This works for me! I have restarted home assistant many times. The fix works for me
Yes, you can use the http agent funtion within Zabbix to connect to the home assistant api. I think it is really a preferred way to get your data as home assistant otherwise spits a lot of useless data into your zabbix instance. I have started the creation of a template set you can use within Zabbix.
Blog post. Git Link.
This way you are certain to get just the data that you want. Secondly, you don’t depend on third party python modules anymore.
Do I am not a python dev, this is the first time I’ve written more than 1 line of Python. I found that py-zabbix 1.1.7 doesn’t have support for the api_token. However another conflicting library pyzabbix 1.2.1 does, however it doesn’t seem that the classes continue to work when mashed together.
I created a custom zabbix component with the below settings, and I had to manually include the logger and sender from py-zabbix
This loads without an error as modified, I don’t yet know if it’s sending states to zabbix, but it does create the sensors in Homeassistant if specified in sensors config.
It would be nice if this created a sensor for each trigger, rather than for all triggers on each host. Also, it doesn’t support ipv6 due to the ZabbixMetric class being from py-zabbix 1.1.7 which is years old without update
zabbix.yaml
manifest.json
__init__.py
sender.py
logger.py
sensor.py