Closed philthynz closed 8 years ago
Hmm.
Do u have UniFi Controller and Zabbix Server on the same host?
No. Same site, same lan.
Unifi controller on Windows 10 PC Zabbix v3 and zabbix agent on Ubuntu 14.04
Hmm. I see some confusion somewhere too.
UserParameter=unifi.discovery[*],/usr/lib/zabbix/externalscripts/unifi_miner.pl -o $1 -u $2 -p $3
UserParameter=unifi.uap.state[*],/usr/lib/zabbix/externalscripts/unifi_miner.pl -o uap -i $1 -k $2 -a $3
UserParameter=unifi.uap.mac.state[*],/usr/lib/zabbix/externalscripts/unifi_miner.pl -o uap -m $1 -k $2 -a $3
UserParameter=unifi.wlan.state[*],/usr/lib/zabbix/externalscripts/unifi_miner.pl -o wlan -i $1 -k $2
UserParameter=unifi.site.state[*],/usr/lib/zabbix/externalscripts/unifi_miner.pl -o $1 -k $2 -a $3
The zabbix templates are setup to use "unifi.proxy".
Which template should i use for unifi_miner?
Unifi controller on Windows Windows 10 is an challenge because no perl support on host.
So, you can use Miner with Zabbix Agent, that placed on other linux box. And on Zabbix Server host (Ubuntu 14.04 server), too, of course.
I would do the following:
1) Move unifi_miner.pl
to /usr/local/bin/zabbix
or other non-related to Zabbix Server dir (just to avoid confusion in the future);
2) Take unifi.conf
from github for actual release (1.3.x) and place to /etc/zabbix/zabbix_agentd.d/
with using Include=
in zabbix_agentd.conf
. Or just paste UserParameter=unifi.proxy[*],/usr/local/bin/zabbix/unifi_miner.pl -a "$1" -o "$2" -s "$3" -k "$4" -i "$5" -n "$6" -c "$7"
to tail of zabbix_agentd.conf
.
3) Restart Zabbix Agentd, delete all Miner's cache files (it's important) from cachedir (/dev/shm) and test integration: zabbix_get -s 127.0.0.2 "unifi.proxy[discovery,wlan]"
(127.0.0.2 is the same that 127.0.0.1, used just for convenience);
4) On success - create via Zabbix web interface new host with address 127.0.0.2 and link to its the template for Proxy actual release - Miner and Proxy use the same template;
5) Open the beer and see to Zabbix's Latest Data.
Instructions on the forum quite outdated.
@zbx-sadman Thanks for the help. I won't read those old forums anymore :)
So i have done what you recommended. And i have:
root@zabbix:~# ls /usr/local/bin/zabbix/unifi_miner.pl
/usr/local/bin/zabbix/unifi_miner.pl
unifi.conf
to zabbix_agentd.conf
root@zabbix:~# tail -5 /etc/zabbix/zabbix_agentd.conf
# Default:
# TLSPSKFile=
##unifi config##
UserParameter=unifi.proxy[*],/usr/local/bin/zabbix/unifi_miner.pl -a "$1" -o "$2" -s "$3" -k "$4" -i "$5" -n "$6" -c "$7"
The server and the controller are on the same lan. The zabbix server and agent are on the same server. Do i need to adjust unifi_miner.pl
in anyway?
And if i run the test command like you recommended. It has no output:
root@zabbix:~# zabbix_get -s 127.0.0.2 "unifi.proxy[discovery,wlan]"
usage:
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address] -k item-key
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address]
--tls-connect cert --tls-ca-file CA-file
[--tls-crl-file CRL-file] [--tls-agent-cert-issuer cert-issuer]
[--tls-agent-cert-subject cert-subject]
--tls-cert-file cert-file --tls-key-file key-file -k item-key
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address]
--tls-connect psk --tls-psk-identity PSK-identity
--tls-psk-file PSK-file -k item-key
zabbix_get -h
zabbix_get -V
Yes, i've lost something: _zabbixget -s 127.0.0.2 -k "unifi.proxy[discovery,wlan]".
Don't use with zabbix_get
IP and port of UniFi Controller. You must ask zabbix agent for metric, it call unifi_miner.pl
via UserParameter. Miner fetch data from UniFi Controller, return back result to zabbix agent and its return value of metric to you.
So, point zabbix_get
to IP of host where agent with Miner is placed. I guess that is Ubuntu server and its reacheable with 127.0.0.2 address or localhost
hostname (and via its adress in your local network, of course).
And don't forget to restart agent after config change.
So that output gives a connection error
root@zabbix:~# zabbix_get -s 127.0.0.2 -k "unifi.proxy[discovery,wlan]"
zabbix_get [9387]: Get value error: cannot connect to [[127.0.0.2]:10050]: [111] Connection refused
root@zabbix:~#
And the zabbix agent was restarted after i changed zabbix_agentd.conf.
Do i need to edit unifi_miner.pl
with my connection settings? IP, port, username etc...? Or will it ask for them?
If you already set in unifi_miner.pl
location of UniFi Controller, change username and password to actual and got any information with making simple request (like unifi_miner.pl -a discovery -o uap
) then Miner work well.
Now you must resolve zabbix_agentd
issue. I think that you need to looking agent's log and search refusing connection reason. May be you need to add an IP address to Server=
or zabbix_agentd
just not started after editing the config (can't access to Include=
dir for example, or so).
You can do simple testing of agentd works with zabbix_get -s <hostname-or-ip> -k "agent.ping"
.
Ok, i have the miner working from zabbix_get
. I just had to change unifi_miner.pl
with my controller.
I have also imported the template zabbix. But now i am receiving an error "Value should be a JSON object" in from the discovery rules. Do you know what this could be?
Yes, i think that is common Miner newbees problem:
https://github.com/zbx-sadman/unifi_miner/wiki/UniFi-Miner-guide-in-English
Low-level discovering rule not running or new values into data items does not appear
Symptom: a Miner script fails with the error like '...unlink error' or 'Presumably no rights to unlink', which is showed in the Zabbix's web interface. The LLD rule fails with error "Value should be a JSON object".
Possible reason: there was a single or multiple script runs under the account other (e.g. root), that of a limited user (e.g. zabbix) account. Causing the cache files were created and owned by non-regular user and cannot be deleted with limited user.
Fix: Change group/owner of the cache files or delete them from cachedir. If u delete its, they will be recreated when UniFi Miner will be started. To speed up the fix process you can delete all the cache files.
Just clear cache dir and wait while discovery rule re-run. Or unlink template and link again to kick Zabbix's LLD procedure.
Thanks again for the help :)
Unfortunately that is not working.
/dev/shm
root@zabbix:/usr/local/bin/zabbix# ls -l /dev/shm/
total 64
-rw-rw-rw- 1 zabbix zabbix 2 Jul 1 17:25 https___192_168_2_10_8443_api_s_default_list_extension
-rw-rw-rw- 1 zabbix zabbix 4351 Jul 1 17:25 https___192_168_2_10_8443_api_s_default_list_wlanconf
-rw-rw-rw- 1 zabbix zabbix 43912 Jul 1 17:25 https___192_168_2_10_8443_api_s_default_stat_device
-rw-rw-rw- 1 zabbix zabbix 602 Jul 1 17:25 https___192_168_2_10_8443_api_s_default_stat_health
-rw-rw-rw- 1 zabbix zabbix 145 Jul 1 17:25 https___192_168_2_10_8443_api_self_sites
I have also added the zabbix user to the sudo
group just as a test for permissions. I am still getting the same "Value should be a JSON object" error from LLD.
Hmm server restart seemed to fix it :) I can see some stats being pulled now. I'll leave it for a while and see what we get. Thanks!
May be Zabbix 3 works with LLD timeouts a little differently that my Zabbix 2.4 - i don't know. But this problem is mostly caused by a problem with the cache.
/dev/shm is a RAM-partition and that certainly will be cleared on reboot. And LLD timeout expires while your server restart. You can choose any explanation ;)
Ok, we're getting there :)
The LLD has added the items to the host. I am still waiting for some data to come through, maybe it just takes a while.
Also, there is an error for the "Network LAN DHCPD start" LLD items:
In the error log:
item "Unifi Controller:unifi.proxy[get,network,default,"[_id=570c93582ed0a10ddd9bc7bb].dhcpd_start"]" became not supported: Special characters "\, ', ", `, *, ?, [, ], {, }, ~, $, !, &, ;, (, ), <, >, |, #, @, 0x0a" are not allowed in the parameters.
I presume that _id
is causing the issue. Can i just change the template and then change _id
to id
in "unifi_miner.pl"?
No, you must try to find solution in Wiki before any actions:
Zabbix's data item going to UNSUPPORTED state
Symptom: complex keys, which contains the filter causes data item going to UNSUPPORTED state.
Possible reason: the Zabbix agent cannot process the key containing the characters'[', '&', ']' and etc.
Fix: use the UnsafeUserParameters=1 directive in the Zabbix-agent configuration file.
Ok, thanks. I will check the Wiki for common issues :)
I am still seeing an error "Value should be a JSON object" after re-adding the template to the host. No data was coming through so i removed and re-added it. I don't think there is an issue with permissions. I am writing the cache to /run/shm
, and the zabbix user has rw access to the json files created:
root@zabbix:~# ls -la /run/shm/
total 8
drwxrwxrwx 2 root root 80 Jul 5 12:09 .
drwxr-xr-x 23 root root 760 Jul 5 11:12 ..
-rw-rw-rw- 1 zabbix zabbix 602 Jul 5 12:09 https___192_168_2_10_8443_api_s_default_stat_health
-rw-rw-rw- 1 zabbix zabbix 145 Jul 5 12:09 https___192_168_2_10_8443_api_self_sites
Any other ideas why this error is happening?
Be sure that you use actual Miner (currently v1.3.4). An oldest releases had one error, thah causes "Value should be a JSON object" errror.
If you still get error with actual release, try this: zabbix_get -s <host> -k "<zabbix_key_from_discovery_rule>"
You must see pure JSON with LLD information. Its can be validated by http://pro.jsonlint.com/ for example. If you see additional data in output (may be perl erorr like Argument "" isn't numeric in addition (+) at... or another) - show its.
Take in account that Zabbix have limit of incoming data (65535 chars) and big JSONs (like Users discovery, or discovery of over that 9000 UAP on site) will be cutted and become invalid.
Ok, So i am running v1.3.4
. If i run zabbix_get -s 127.0.0.1 -k "unifi.proxy[discovery,health]"
it is not a normal JSON. Here are the first 4 lines of the output.
root@zabbix:~# zabbix_get -s 127.0.0.1 -k "unifi.proxy[discovery,health]"
[2681] 2016-07-05 12:43:05 [.] globalConfig:
$VAR1 = {
'key' => '',
'objecttype' => 'health',
This is different to the JSON files in /run/shm
. Those JSON files are fine:
root@zabbix:~# cat /run/shm/https___192_168_2_10_8443_api_s_default_stat_health
[{"num_disabled":0,"rx_bytes-r":22222,"status":"ok","num_disconnected":0,"tx_bytes-r":36025
The JSON files created under run/shm
can be validated with http://jsonlint.com/
Seems that debug is enabled. configDefs -> debuglevel in unifi_miner.pl
must be FALSE (its equal 0 => debuglevel=0). Do u set it to a number? ...or you use -d n option with UserParameter in your zabbix_agentd.conf
See example with debug enabled:
./unifi_miner.pl -a "discovery" -o "health" -s "" -k "" -i "" -n "" -c "" -d 2
[3516] 2016-07-05 14:14:15 [.] globalConfig:
$VAR1 = {
'sitename' => 'default',
'ua' => undef,
....
And without debug:
./unifi_miner.pl -a "discovery" -o "health" -s "" -k "" -i "" -n "" -c ""
{"data":[{"{#SITENAME}":"default","{#SITEID}":"5523f87e99320d293df816fd","{#SUBSYSTEM}":"wlan","{#SITEDESC}":"Default","{#STATUS}":"warning"},{"{#SITENAME}":
...
Ahh ok. Yes i did have debug on:
# Debug level
'debuglevel' => ['d', TYPE_NUMBER, 2],
I've put it to FALSE
, the JSON output is fine now:
root@zabbix:/usr/local/bin/zabbix# zabbix_get -s 127.0.0.1 -k "unifi.proxy[discovery,health]"
{"data":[{"{#SITEID}":"5404a3f0d0f9054c70518eb0","{#SUBSYSTEM}":"wlan","{#STATUS}":"ok"
I will use -d n
if i want to debug next time. Now i'll just wait for some data to come through.
Hey @zbx-sadman Thanks for the help so far.
How long does it usually take for the data to come under "Latest Data" in Zabbix? I have all the items imported without error. Only the ICMP data seems to be coming through. I have put the Zabbix server config on debug level 3, and i'm seeing the unifi.proxy activity in /var/log/zabbix/zabbix_server.log
4206:20160705:151938.432 In substitute_key_macros() data:'unifi.proxy[get,wlan,{#SITENAME},_id,{#ID}]'
4206:20160705:151938.432 End of substitute_key_macros():SUCCEED data:'unifi.proxy[get,wlan,default,_id,5756f7692ed0b5ae05f3e159]'
4206:20160705:151938.432 In substitute_key_macros() data:'unifi.proxy[get,wlan,{#SITENAME},_id,{#ID}]'
4206:20160705:151938.432 End of substitute_key_macros():SUCCEED data:'unifi.proxy[get,wlan,default,_id,5756f7552ed0b5ae05f3e158]'
4206:20160705:151938.432 In substitute_key_macros() data:'unifi.proxy[get,wlan,{#SITENAME},_id,{#ID}]'
4206:20160705:151938.432 End of substitute_key_macros():SUCCEED data:'unifi.proxy[get,wlan,default,_id,574e872f2ed0ebdec8493d7d]'
4206:20160705:151938.432 In substitute_key_macros() data:'unifi.proxy[get,wlan,{#SITENAME},_id,{#ID}]'
4206:20160705:151938.432 End of substitute_key_macros():SUCCEED data:'unifi.proxy[get,wlan,default,_id,5404a444d0f9054c70518ec4]'
4206:20160705:151938.432 In substitute_key_macros() data:'unifi.proxy[get,wlan,{#SITENAME},_id,{#ID}]'
4206:20160705:151938.432 End of substitute_key_macros():SUCCEED data:'unifi.proxy[get,wlan,default,_id,5404a444d0f9054c70518ec3]'
4206:20160705:151938.432 In substitute_key_macros() data:'unifi.proxy[get,wlan,{#SITENAME},_id,{#ID}]'
4206:20160705:151938.432 End of substitute_key_macros():SUCCEED data:'unifi.proxy[get,wlan,default,_id,574e870d2ed0ebdec8493d7c]'
4206:20160705:151938.432 In substitute_key_macros() data:'unifi.proxy[get,wlan,{#SITENAME},_id,{#ID}]'
4206:20160705:151938.432 End of substitute_key_macros():SUCCEED data:'unifi.proxy[get,wlan,default,_id,574e864d2ed0ebdec8493d78]'
4206:20160705:151938.432 In substitute_key_macros() data:'unifi.proxy[get,wlan,{#SITENAME},_id,{#ID}]'
4206:20160705:151938.433 End of substitute_key_macros():SUCCEED data:'unifi.proxy[get,wlan,default,_id,574e86172ed0ebdec8493d77]'
But no other data apart from ICMP
Ough. I think that you observe to Imported Template and sight that Data Items has Zabbix agent (active) type.
I also think that you do not enable Active checks in zabbix_agentd.conf
. Just find ActiveServer directive...
I remembered that I did the video of installation and setiing up process. May be its will helpful: UniFi Miner installation and setting up (Change video quality to 720p by clicking on the gear icon)
Thanks for the video's. That is the same config i have done.
Each item is "zabbix agent (active)":
And in /etc/zabbix/zabbix_agentd.conf
i already have:
##### Passive checks related
### Option: Server
# List of comma delimited IP addresses (or hostnames) of Zabbix servers.
# Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
#
# Mandatory: no
# Default:
# Server=
Server=127.0.0.1
and
### Option: ServerActive
# List of comma delimited IP:port (or #hostname:port) pairs of Zabbix servers for active checks.
# If port is not specified, default port is used.
# IPv6 addresses must be enclosed in square brackets if port for that host is specified.
# If port is not specified, square brackets for IPv6 addresses are optional.
# If this parameter is not specified, active checks are disabled.
# Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1]
#
# Mandatory: no
# Default:
# ServerActive=
ServerActive=127.0.0.1
Thats the same config you did in the video's :) In my config, the server, agent and miner box are all the same server. The miner is pulling info from a Windows PC with the Unifi controller
I will wait a while and see if any more data comes through.
Ok, all seems ok.
Make sure that Hostname in zabbix_agentd.conf
the same Hostname to which Template linked. If names is different - Zabbix server send empty active checks list to Zabbix agentd and its do nothing. This showed into _zabbixagentd log on debuglevel=4: request to Zabbix Server of active checks on agentd start and every 120 sec after, and reply with keys that need to gather and send back to server.
Or change type to Zabbix agent (non-active) for several items. Just for test. And you can change type for all items, but then Zabbix server pollers must be increased. There are many ways to put data into Zabbix DB - you must find better for you ;)
@zbx-sadman Thanks for all the help. The issue was the hostname needed to be 127.0.0.1
. I had it set to a generic name before, because i though the agent would pull through the data regardless of the hostname.
It all seems to be working very well with Zabbix v.3 and a windows controller.
So good.
Please contact with me via email if you have more that UAPs - a need live info / statistic for Switches / Routers / Phones / etc.
Hi all,
I am trying to setup the uifi miner with zabbix 3. I am currently following the steps here https://www.zabbix.com/forum/showthread.php?t=44717&page=2
I have:
unifi_miner.pl
to/usr/lib/zabbix/externalscripts/
. And it is working with some input commands.unifi.conf
that i found here to/etc/zabbix/zabbix_agentd.d/
.Include=/etc/zabbix/zabbix_agentd.d/
in/etc/zabbix/zabbix_agentd.d/
UserParameter
in/etc/zabbix/zabbix_agentd.d/unifi.conf
to include/usr/lib/zabbix/externalscripts/unifi_miner.pl
Just a question before i continue. Should i be using
unifi.conf
orunifi_proxy.conf
? Can i use Miner withunifi_proxy.conf
? I can't see that mentioned in the miner guide