zbx-sadman / unifi_miner

UniFi Miner helps deliver data from UniFi Controller to Zabbix
66 stars 11 forks source link

malformed JSON string #10

Closed luigdima closed 7 years ago

luigdima commented 7 years ago

Hi!

When send this command:

root@zabbix:~/unifi_miner# ./unifi_miner.pl -a discovery -o uap -s bcg2fhu9 -l http://172.16.44.12:8443 -u admin -p pass00 -c 0

I will return this string:

malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "\x{15}\x{3}\x{3}\x{0}...") at ./unifi_miner.pl line 892.

Any idea? =)

Thanks!!

zbx-sadman commented 7 years ago

Hello again, Luis.

UniFi controller/Miner/Proxy works over HTTPS, not HTTP. Just use https:// instead http:// for the location option.

luigdima commented 7 years ago

If tested with https:// the response is:

[28192] 2017-07-26 13:40:45 [+] fetchData() started
[28192] 2017-07-26 13:40:45 [>]  args: object type: 'site'
[28192] 2017-07-26 13:40:45 [.]          Object path: 'https://172.16.44.12:8443/api/self/sites'
[28192] 2017-07-26 13:40:45 [.]          No read/update cache because CacheMaxAge = 0
[28192] 2017-07-26 13:40:45 [+] fetchDataFromController() started
[28192] 2017-07-26 13:40:45 [>]  args: object path: 'https://172.16.44.12:8443/api/self/sites'
[28192] 2017-07-26 13:40:45 [!] Comminication error: '500 Can't connect to 172.16.44.12:8443'

[28192] 2017-07-26 13:40:45 [!] Can't fetch data from controller
[28192] 2017-07-26 13:40:45 [.]          Going over all sites
[28192] 2017-07-26 13:40:45 [.] Make LLD JSON
[28192] 2017-07-26 13:40:45 [*] Logout from UniFi controller
{"data":[]}

:(

zbx-sadman commented 7 years ago

Seems that you use UniFi Controller >= v5.5.

Now i'm preparing new Miner/Proxy for release. It must be able to monitor a few new objects/metrics, and will have real v5 controller support, and fixed 'Error #500'.

At this time you can try to use quick fix from Proxy issue (i have fixed this error for Proxy, but did not have time for Miner, because switched to new release development...) - https://github.com/zbx-sadman/unifi_proxy/issues/11 - just change 'tlsv1' to 'TLSv12' in Miner's source code.

luigdima commented 7 years ago

Yes! I've changed 'tlsv1' to 'tlsv12' and it works! thanks!!

zbx-sadman commented 7 years ago

TLS moved to 1.2 in v1.3.5 release