zbx-sadman / unifi_proxy

Fast client-server version of UniFi Miner
45 stars 21 forks source link

responses for discovery return variable list length #27

Closed hudecof closed 6 years ago

hudecof commented 6 years ago

hi,

I'm experiencing following problem, both with unifi_miner.pl and unify_proxy.pl.

[PROD] phudec@dmplapps02: ~ $ zabbix_get -s diplapps06.cnc.sk -k unifi.proxy[discovery,wlan]
{"data":[]}
[PROD] phudec@dmplapps02: ~ $ zabbix_get -s diplapps06.cnc.sk -k unifi.proxy[discovery,wlan]
{"data":[{"{#SITEID}":"562001260cf28b7adb2609d2","{#NAME}":"CNC-GUEST","{#SITENAME}":"by486k0l","{#ISGUEST}":"0","{#ID}":"562001880cf28b7adb2609e0","{#SITEDESC}":"CNC"}]}
[PROD] phudec@dmplapps02: ~ $ zabbix_get -s diplapps06.cnc.sk -k unifi.proxy[discovery,wlan]
{"data":[{"{#SITENAME}":"by486k0l","{#SITEID}":"562001260cf28b7adb2609d2","{#NAME}":"CNC-GUEST","{#ID}":"562001880cf28b7adb2609e0","{#ISGUEST}":"0","{#SITEDESC}":"CNC"},{"{#SITEDESC}":"DCP","{#SITEID}":"562002230cf28b7adb2609e4","{#NAME}":"DCP-GUEST","{#SITENAME}":"16gwksl1","{#ISGUEST}":"0","{#ID}":"562002650cf28b7adb2609f3"},{"{#SITEID}":"562002230cf28b7adb2609e4","{#NAME}":"CNC-DCP","{#SITENAME}":"16gwksl1","{#ISGUEST}":"0","{#ID}":"562002a40cf28b7adb2609f5","{#SITEDESC}":"DCP"}]}

I run 3 times the same command and the respnse is

I suppose the problem is on the contorller side or some caching problem with the perl.

CONTROLLER VERSION: 5.7.23

zbx-sadman commented 6 years ago

Hello Peter.

You can disable cache feature for some tests - just use "... -с 0" option for unifi_miner.pl and it will be connect to UniFi Controller every time to get JSON. If you find no errors, use "... -d 3 > log,txt" option for looking to cache reading results. Value '3' will generate a few log lines, but can be very helpfull.

So... if you use unifi_miner.pl via UserScript, may be you need to increase Agent's Timeout value.

hudecof commented 6 years ago

Debug mode for the unifi_miner.pl shows

[17978] 2018-05-14 18:23:17 [.]      Going over all sites
[17978] 2018-05-14 18:23:17 [.]      Handle site: 'default'
[17978] 2018-05-14 18:23:17 [+] fetchData() started
[17978] 2018-05-14 18:23:17 [>]  args: object type: 'wlan'
[17978] 2018-05-14 18:23:17 [.]      Object path: 'https://127.0.0.1:8443/api/s/default/rest/wlanconf'
[17978] 2018-05-14 18:23:17 [.]      No read/update cache because CacheMaxAge = 0
[17978] 2018-05-14 18:23:17 [+] fetchDataFromController() started
[17978] 2018-05-14 18:23:17 [>]  args: object path: 'https://127.0.0.1:8443/api/s/default/rest/wlanconf'
[17978] 2018-05-14 18:23:17 [!] Comminication error: '403 Forbidden'

The log form the unify controller

[2018-05-14 18:25:27,844] <webapi-93> INFO  event  - [event] Admin[zabbix] log in from 127.0.0.1
[2018-05-14 18:25:28,757] <webapi-84> INFO  api    - [api] api.err.NoPermission: /api/s/super/get/setting
[2018-05-14 18:25:28,807] <webapi-92> INFO  api    - [api] api.err.NoPermission: /api/s/super/get/setting
[2018-05-14 18:25:28,857] <webapi-39> INFO  api    - [api] api.err.NoPermission: /api/s/super/get/setting

But for time to time it worksand I could retrieve full data set.

hudecof commented 6 years ago

my monitoring user is read-only with Allow read only access to all sites permission

zbx-sadman commented 6 years ago

Peter, try to use UniFi admin account for API access just for test.

hudecof commented 6 years ago

works as expected, I was not able reproduce the issue. I chage the role to SuperAdmin role

zbx-sadman commented 6 years ago

Okay...

I did not install v5.7.23 and do not know how works "Allow read only access to all sites" option. On old releases of UniFi Controller i had to add readonly user with name stat to every site (with the same password) to avoid "403 forbidden" error.