Skip to content

Commit eee4beb

Browse files
committed
Add unpoller support
1 parent 35badb3 commit eee4beb

8 files changed

+91
-0
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Other features:
2323
- **Shelly Plug Monitoring**: Installs a [`shelly-plug-prometheus` exporter](https://github.com/geerlingguy/shelly-plug-prometheus) and a Grafana dashboard, which tracks and displays power usage on a Shelly Plug running on the local network. (Disabled by default. Enable and configure using the `shelly_plug_*` vars in `config.yml`.)
2424
- **AirGradient Monitoring**: Configures [`airgradient-prometheus`](https://github.com/geerlingguy/airgradient-prometheus) and a Grafana dashboard, which tracks and displays air quality over time via one or more AirGradient DIY monitors. (Disabled by default. Enable and configure using the `airgradient_enable` var in `config.yml`. See example configuration for ability to monitor multiple AirGradient DIY stations.)
2525
- **Starlink Monitoring**: Installs a [`starlink` prometheus exporter](https://github.com/danopstech/starlink_exporter) and a Grafana dashboard, which tracks and displays Starlink statistics. (Disabled by default. Enable and configure using the `starlink_enable` var in `config.yml`.)
26+
- **UniFi Monitoring**: Installs the [`unpoller` prometheus exporter](https://unpoller.com/) which queries your UniFi hardware. (Disabled by default. Enable and configure using the `unpoller_enable` var in `config.yml`.)
2627

2728
**IMPORTANT NOTE**: If you use the included Internet monitoring, it will download a decently-large amount of data through your Internet connection on a daily basis. Don't use it, or tune the `internet-monitoring` setup to not run the speedtests as often, if you have a metered connection!
2829

@@ -87,6 +88,12 @@ prometheus_node_exporter_targets:
8788
- 'another-server.local:9100'
8889
```
8990

91+
#### Unifi monitoring
92+
93+
Optionally, you can enable monitoring of your unifi gear by adding the [UnPoller](https://unpoller.com/) image. In your config, set `unifi_unpoller_enable` to true, add the ip of your controller, [the password of a user you are creating for this purpose](https://unpoller.com/docs/install/gettingstarted#configuring-the-controller), and you are good to go.
94+
95+
There are plenty of useful [predefined grafana dashboards](https://grafana.com/grafana/dashboards/?search=unifi-poller) that can be used.
96+
9097
## Updating
9198

9299
### pi-hole

example.config.yml

+10
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,13 @@ airgradient_sensors:
4747

4848
# Starlink configuration. (Also requires `monitoring_enable`)
4949
starlink_enable: false
50+
51+
# Unifi Unpoller configuration
52+
unpoller_enable: false
53+
# URL for the UniFi Controller. Do not add any paths after the host:port
54+
# Do not use port 8443 if you have a UDM; just use "https://ip".
55+
unpoller_unifi_url: https://192.168.1.1
56+
# The password for the user created in the unifi admin, insructions at
57+
# https://unpoller.com/docs/install/gettingstarted#configuring-the-controller
58+
unpoller_unifi_admin_username: "unifipoller"
59+
unpoller_unifi_admin_password: "change-this-password"

files/unpoller-overview.json

Whitespace-only changes.

main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@
4949
- name: Set up Starlink Monitoring.
5050
ansible.builtin.import_tasks: tasks/starlink.yml
5151
when: starlink_enable
52+
53+
- name: Set up Unpoller Monitoring.
54+
ansible.builtin.import_tasks: tasks/unpoller.yml
55+
when: unpoller_enable

tasks/handlers.yml

+7
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@
2626
build: false
2727
restarted: true
2828
become: false
29+
30+
- name: Restart unpoller-exporter
31+
community.docker.docker_compose:
32+
project_src: "{{ config_dir }}/unpoller-exporter/"
33+
build: false
34+
restarted: true
35+
become: false

tasks/unpoller.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
- name: Ensure unpoller directory exists.
3+
file:
4+
path: "{{ config_dir }}/unpoller-exporter"
5+
state: directory
6+
mode: 0755
7+
become: false
8+
9+
- name: Copy unpoller docker-compose template to Pi.
10+
ansible.builtin.template:
11+
src: templates/unpoller-docker-compose.yml.j2
12+
dest: "{{ config_dir }}/unpoller-exporter/docker-compose.yml"
13+
mode: '0640'
14+
become: false
15+
notify: Restart unpoller-exporter
16+
17+
- name: Ensure unpoller Prometheus exporter is running.
18+
community.docker.docker_compose:
19+
project_src: "{{ config_dir }}/unpoller-exporter/"
20+
build: false
21+
become: false
22+
23+
- name: Copy unpoller dashboard config to grafana.
24+
ansible.builtin.copy:
25+
src: files/unpoller-overview.json
26+
dest: "{{ config_dir }}/internet-monitoring/grafana/provisioning/dashboards/"
27+
mode: 0644
28+
become: false

templates/prometheus.yml.j2

+7
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ scrape_configs:
8181
- targets: ['{{ pihole_hostname }}:9617']
8282
{% endif %}
8383

84+
{% if unpoller_enable %}
85+
- job_name: 'unpoller'
86+
scrape_interval: 30s
87+
static_configs:
88+
- targets: ['unpoller:9130']
89+
{% endif %}
90+
8491
{% filter indent(width=2,first=True) %}
8592
{{ prometheus_extra_scrape_configs }}
8693
{% endfilter %}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# {{ ansible_managed }}
2+
---
3+
version: "3.5"
4+
5+
networks:
6+
back-tier:
7+
name: internet-monitoring-back-tier
8+
9+
services:
10+
unpoller:
11+
container_name: unpoller
12+
hostname: 'unpoller'
13+
restart: unless-stopped
14+
image: golift/unifi-poller:latest
15+
expose:
16+
- 9130
17+
ports:
18+
- 9130:9130
19+
networks:
20+
- back-tier
21+
environment:
22+
# The documentation on these vars isn't great. The best example can be found at
23+
# https://github.com/unpoller/unpoller/blob/51d0b2109ffe455c8ed2ef711e1a9ae46a6c15c7/init/docker/docker-compose.yml
24+
UP_INFLUXDB_DISABLE: 'true'
25+
UP_UNIFI_DEFAULT_SAVE_DPI: 'true'
26+
UP_UNIFI_DEFAULT_USER: '{{ unpoller_unifi_admin_username }}'
27+
UP_UNIFI_DEFAULT_PASS: '{{ unpoller_unifi_admin_password }}'
28+
UP_UNIFI_DEFAULT_URL: '{{ unpoller_unifi_url }}'

0 commit comments

Comments
 (0)