bashclub / check-unifi-controller

Checkmk special agent for checking unifi controller
https://sysops.tv
MIT License
42 stars 15 forks source link

Check raises login error on "UniFi OS 3.2.7" #19

Open jrttr opened 9 months ago

jrttr commented 9 months ago

/share/check_mk/agents/special/agent_unifi_controller

 def check_unifi_os(self):
        _response = self.request("GET",url=self.url,allow_redirects=False)
        self.is_unifios= _response.status_code == 200 and _response.headers.get("x-csrf-token")

Header x-csrf-token is no longer available, so it is not possible to correctly determine whether unifiOS is being used. The wrong login URL is therefore used in def login()

File "/omd/sites/XXX/local/share/check_mk/agents/special/agent_unifi_controller", line 641, in <module>
_api = unifi_controller_api(**args.__dict__)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/omd/sites/XXX/local/share/check_mk/agents/special/agent_unifi_controller", line 551, in __init__
self.login(username,password)
File "/omd/sites/XXX/local/share/check_mk/agents/special/agent_unifi_controller", line 585, in login
raise unifi_api_exception("Login failed")
FirstS0ul commented 8 months ago

same here! please update ;-)

c3rberus commented 8 months ago

Same issue here, can we please get an updated check?

n00rm commented 7 months ago

Have the same issue. UniFi OS 3.2.7 on Cloudkey+ with Unifi Network Version 8.0.26.

image

@thorstenspille Will this project still be supported?

itswfpu commented 7 months ago

The issue can be resolved by modifying the check_unifi_os method as follows:

def check_unifi_os(self):
    _response = self.request("GET", url=self.url, allow_redirects=False)
    self.is_unifios = _response.status_code == 200

As you've observed, the x-csrf-token is no longer present in the response payload, resulting in self.is_unifios consistently being set to false. This creates a problem in the login method, as it relies on is_unifios being true to select the correct API endpoint. Consequently, the login process consistently fails. By implementing the revised method in ~/local/share/check_mk/agents/special/agent_unifi_controller, the plugin should function properly once again.