binarybear-de / cmk_check_unifi-controller

Local Check for Check_MK to get information about UniFi devices from Controller
21 stars 2 forks source link

Error when running the script #8

Closed christianhau closed 2 years ago

christianhau commented 3 years ago

First of all, great work :) I followed the installation and was able to run the script (I have made the read only user local and added the localip:8443 as the base url). When I run the script I get the following printout: ./check_unifi-controller.sh: line 59: [: =: unary operator expected 0 UniFi-Controller - Hostname: , Build , Check-Script BUILD 2021-02-27 0 UniFi-Devices devices=|sites=|unamed=0|unadopted=0 devices on sites - no unnamed or unadopted devices found./check_unifi-controller.sh: line 59: [: =: unary operator expected 0 UniFi-Controller - Hostname: , Build , Check-Script BUILD 2021-02-27 0 UniFi-Devices devices=|sites=|unamed=0|unadopted=0 devices on sites - no unnamed or unadopted devices found

My controller has two APs, a security gateway device and a 24 port switch. But these don't show up.

an0key commented 3 years ago

Also having the same issue here :( On both UDM-P using the proxy address, and also a standalone ubuntu controller.

kingcin commented 3 years ago

Hello, api calls apprently changed in controller version 6.2.x (using 6.2.25) on cloud key2

I find out that in order to meke script workign correcly in all api calls beside login it is required to add

/proxy/network eg $BASEURL/proxy/network/api/s/$SITE/stat/device

and to login itsealf path is $BASEURL/api/auth/login

and it is also required to add in curl header Content-Type: application/json

cinntech commented 3 years ago

have these changes been updated?

I'm having same issue with 6.2.26 controller and cloudkey plus 2.1.11 (unifi controller 6.2.26).

Where exactly do we update the curl header?

binarybear-de commented 2 years ago

Hey there, sorry for the long silence- too much work around..

My controller has two APs, a security gateway device and a 24 port switch. But these don't show up.

Line 59 is the first Call of the getValueFromController after Login. This indeed indicates that there is a problem with the API call - either not working (misconfiguration?) or renamed/moved by Ubiquiti.

I am running the script on a 6.4.54 Controller on Debian (upgraded since 6.1.x), maybe this only affects new installations? I'll need some time to figure that out.. If someone can confirm that cloud key is using different API paths I will move those to the config file as well

and it is also required to add in curl header Content-Type: application/json

This can be set in the config file /etc/check_mk/unifi.cfg. Replace or Append the CURLOPTS: CURLOPTS="--insecure --tlsv1.2 -H Content-Type: application/json"