top of page
Search
  • Kenneth LaCroix

How To: Integrate Unifi AP metrics into Zabbix (so you can graph it in Grafana)

Updated: Nov 17, 2020


A Zabbix and Grafana server that also polls a Unifi Controller.

Credits: zbx_sadman for creating the awesome Unifi Proxy project.

Difficulty level: Intermediate

Why? The Unifi Controller software is perfectly fine but if you have a Zabbix server set up and monitoring infrastructure, you can integrate Unifi AP's into the mix, even with alerting and graphing (with Grafana). The instructions on Unifi Proxy's github are very minimal which is the reason why for this guide. You can poll and graph all kinds of interesting Unifi Controller data such as signal strength, the number of connected clients, uptime, overall WiFi health, etc.

Purpose: to obtain and display information from Unifi Access Points into a Zabbix server and finally graph the data with Grafana. This guide uses Ubuntu Linux 18.04 ran in a Container.

Prerequisites:

1) A server with (Ubuntu 18.04) Zabbix and Grafana installed and set up.

2) A Linux client with the Unifi controller and Zabbix agent installed.

3) About 30+ minutes.

On the Unifi Controller.


Step 1: Getting started.

1a: Install requirements.

sudo apt-get install git libjson-perl libjson-xs-perl libwww-perl libio-socket-ssl-perl libio-socket-ip-perl libdata-dumper-simple-perl libtime-hires-perl -y

1b: Clone the Unifi Proxy project a local folder on the server.

git clone https://github.com/zbx-sadman/unifi_proxy.git

1c: Change directory into the projects folder.

cd unifi_proxy/

Step 2: Edit the configuration files to match your environment.

2a: Edit the main config file

sudo nano ~/unifi_proxy/etc/unifi_proxy/unifi_proxy.conf

-Edit 'UniFiUser' to reflect your Unifi controllers username.

-Edit 'UniFiPass' to reflect your Unifi controllers password.

-Ensure that 'UnifiLocation' is set correctly.

-Ensure 'UnifiVersion' is correct.

-The defaults should be good, but its good to double check.

2b: OPTIONAL: Edit the zbx_unifi.conf file

sudo nano ~/unifi_proxy/etc/zabbix/zbx_unifi.conf

-Double check the module path, but the defaults should be good.

2c: OPTIONAL: Customize Unifi Proxy service scripts, if need be.

sudo nano ~/unifi_proxy/etc/init.d/unifi_proxy

-You shouldn't have to edit this file but you can if you want to customize how the Unifi Proxy service starts, stops, reloads, etc.

2d: Edit your Zabbix agent config file. The UserParameter is used by the Zabbix Agent to poll Unifi Controller based on the templates predefined parameters.

sudo nano /etc/zabbix/zabbix_agentd.conf

-Add the following to the end of the file (be careful copying and pasting):

UserParameter=unifi.proxy[*],echo "$1,$2,$3,$4,$5,$6,$7" | nc 127.0.0.1 8448 -q 1

Step 3: Copy the programs files to finish the installation and restart services.

3a: Copy the services files and make executable.

sudo cp ~/unifi_proxy/etc/init.d/unifi_proxy /etc/init.d/unifi_proxy
sudo chmod +x /etc/init.d/unifi_proxy

3b: Create the Unifi Proxies folder and copy the files.

sudo mkdir /etc/unifi_proxy/
sudo mkdir /usr/local/lib/zabbix/
sudo cp ~/unifi_proxy/etc/unifi_proxy/unifi_proxy.conf /etc/unifi_proxy/
sudo cp ~/unifi_proxy/etc/zabbix/zbx_unifi.conf /etc/zabbix/
sudo cp ~/unifi_proxy/usr/lib/systemd/system/unifi-proxy.service /lib/systemd/system/
sudo cp ~/unifi_proxy/usr/local/lib/zabbix/unifi.conf /usr/local/lib/zabbix/
sudo cp ~/unifi_proxy/usr/local/sbin/unifi_proxy.pl /usr/local/sbin/
sudo chmod +x /usr/local/sbin/unifi_proxy.pl

3c: Restart the Zabbix Agent service and make sure its running.

sudo service zabbix-agent restart
sudo service zabbix-agent status

3d: Enable on start and start the Unifi Proxy service and test it.

sudo systemctl enable unifi_proxy
sudo service unifi_proxy start
sudo zabbix_agentd -t "unifi.proxy[discovery,wlan]";


On the Zabbix Server


Step 4: Upload the template to the Zabbix server and apply it to the Agent and ensure everything is working.

4a: Template


4b: Live data collection

bottom of page