Merge pull request #108 from Griffen8280/master

Add UnPoller to Templates
This commit is contained in:
Robert Middleswarth
2021-11-02 20:09:48 -04:00
committed by GitHub
6 changed files with 399 additions and 0 deletions

114
docs/unpoller-install.md Normal file
View File

@@ -0,0 +1,114 @@
# Install and setup instructions for the RPI Unifi Monitor
## Introduction
A monitoring solution for the Unifi Controller with [Grafana](http://grafana.org/), [UnPoller](https://unpoller.com/).
## Screenshot
![USG-UnPoller](https://user-images.githubusercontent.com/42878642/139702071-c481522b-96ad-425e-bdb1-493df7ec735e.PNG)
![UAP-unpoller](https://user-images.githubusercontent.com/42878642/139702089-bb165f84-81c3-4a5f-8aed-282de5ad5bbb.PNG)
# Installation
## Pre-Installation Steps
First SSH into your Pi or use Shell in a Box to get to the command line. ensure you have pulled the latest from https://github.com/novaspirit/pi-hosted/ and run unpoller-install.sh
## Folder Setup Script
First thing we need to do is setup the folder structure and install some files that need to be in place for everything to work correctly.
Run the following script
```
sudo sh ./unpoller-install.sh
```
Your output should look something like this
```
# sudo ./rpi_docker_monitor.sh
creating directories
downloading unpoller config files
--2021-10-17 00:56:28-- https://raw.githubusercontent.com/novaspirit/pi-hosted/tree/master/pi-hosted_template/configs/up.conf
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.109.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 163 [text/plain]
Saving to: /portainer/Files/AppData/Config/unpoller/up.conf
/portainer/Files/AppData/Config/unpoller/up.conf 100%[=======================================================================================================================================>] 163 --.-KB/s in 0s
2021-10-17 00:56:28 (971 KB/s) - /portainer/Files/AppData/Config/unpoller/up.conf saved [163/163]
Done You are ready to goto next step in the install document
```
### This Step is now complete go to the next step.
<br><br>
## Install the App Template.<br>
[comment]: # (FixMe)
Goto App Templates and install "UnPoller Monitor"
The default settings should all be good so **Deploy the Stack**
<br><br>
## Setup Grafana
Assuming you have already installed the pi monitoring suite we will need to install 2 new plugins for grafana to display the new dashboards correctly. Navigate to your monitoring-grafana container and click >_Console.
![console](https://user-images.githubusercontent.com/42878642/139703380-7e9804eb-6215-4294-a3c8-62907b5caf34.PNG)
Click connect on this next page
![connect](https://user-images.githubusercontent.com/42878642/139703514-e5665d58-f78b-4c96-adc0-f264a82df678.PNG)
Then type in:
```
grafana-cli plugins install grafana-clock-panel
```
&
```
grafana-cli plugins install grafana-piechart-panel
```
After each line make sure to hit enter and your output should look something like the following:
![plugin-install](https://user-images.githubusercontent.com/42878642/139704132-e14d2607-705b-4c76-9238-9aa638a32120.PNG)
Following this just restart the monitoring-grafana container and the plugins will be ready to use.
### Setup InfluxDB as a data source.
```
Grafana > Configuration > Data Sources > Add data source
```
**It is important that you set the URL to http://<Server-IP>:8086/**<br><br>
![datasource](https://user-images.githubusercontent.com/42878642/139704631-aee34f6b-606f-443a-8dff-88c2fb342295.PNG)
### Setup the Dashboard
Grafana is not preconfigured with dashboard, so you have to import it from the Grafana dashboard repo.
```
Grafana > + > Import
```
Use the table found at [UnPollers](https://unpoller.com/docs/install/grafana) website for the dashboard you need for your hardware.
Type in the number for the appropriate dashboard in the "Import via grafana.com" box and click load
![load dashboard](https://user-images.githubusercontent.com/42878642/139705535-dc2a679e-8f55-4ed1-b993-933519802f97.PNG)
Once loaded ensure you select the InfluxDB datasource at the bottom and click import
![import](https://user-images.githubusercontent.com/42878642/139705998-9f9963c2-552e-42af-84e0-2d54cc053645.PNG)
Now we can display the dashboard
```
Grafana > Dashboard > Manage
```
The dashboard should now be accessible from the dashboards menu where the Raspberry Pi monitoring dashboard is located.
## Acknowledgment
* based on [Docker-Raspberry-PI-Monitoring](https://github.com/oijkn/Docker-Raspberry-PI-Monitoring) by Oijkn

View File

@@ -0,0 +1,206 @@
# UniFi Poller v2 primary configuration file. TOML FORMAT #
###########################################################
[poller]
# Turns on line numbers, microsecond logging, and a per-device log.
# The default is false, but I personally leave this on at home (four devices).
# This may be noisy if you have a lot of devices. It adds one line per device.
debug = false
# Turns off per-interval logs. Only startup and error logs will be emitted.
# Recommend enabling debug with this setting for better error logging.
quiet = false
# Load dynamic plugins. Advanced use; only sample mysql plugin provided by default.
plugins = []
#### OUTPUTS
# If you don't use an output, you can disable it.
[prometheus]
disable = true
# This controls on which ip and port /metrics is exported when mode is "prometheus".
# This has no effect in other modes. Must contain a colon and port.
http_listen = "0.0.0.0:9130"
# Adding an SSL Cert and Cert Key will make Poller listen with SSL/https.
ssl_cert_path = ""
ssl_key_path = ""
# Errors are rare. Setting this to true will report them to Prometheus.
report_errors = false
## Record data for disabled or down (unlinked) switch ports.
dead_ports = false
[influxdb]
disable = false
# InfluxDB does not require auth by default, so the user/password are probably unimportant.
url = "http://up_influxdb:8086"
user = "unifipoller"
# Password for InfluxDB user (above).
# If the password provided here begins with file:// then the password is read in from
# the file path that follows the file:// prefix. ex: file:///etc/influxdb/passwd.file
pass = "unifipoller"
# Be sure to create this database. See the InfluxDB Wiki page for more info.
db = "unifi"
# If your InfluxDB uses a valid SSL cert, set this to true.
verify_ssl = false
# The UniFi Controller only updates traffic stats about every 30 seconds.
# Setting this to something lower may lead to "zeros" in your data.
# If you're getting zeros now, set this to "1m"
interval = "30s"
## Record data for disabled or down (unlinked) switch ports.
dead_ports = false
# To enable output of UniFi Events to Loki, add a URL; it's disabled otherwise.
# User, pass and tenant_id are optional and most folks wont set them.
# Pick which logs you want per-controller in the [unifi.controller] section.
# This is a new feature. Feedback welcome!
[loki]
url = ""
# The rest of this is advanced & optional. See wiki.
user = ""
pass = ""
verify_ssl = false
tenant_id = ""
interval = "2m"
timeout = "10s"
# Poller has an optional web server. To turn it on, set enable to true. If you
# wish to use SSL, provide SSL cert and key paths. This interface is currently
# read-only; it just displays information, like logs, devices and clients.
# Notice: Enabling the web server with many sites will increase memory usage.
# This is a new feature and lacks a UI, enabling only recommended for testing.
[webserver]
enable = false
port = 37288
# The HTML path is different on Windows and BSD/macOS.
html_path = "/usr/lib/unifi-poller/web"
ssl_cert_path = ""
ssl_key_path = ""
# How many events per event group to hold. 200-2000. Use fewer with many sites.
# With 1 site, you'll have a max total of 9 event groups; 1 per plugin, 4 per site.
# Each site adds 1 event group for each of these inputs that is enabled:
# save_ids, save_events, save_anomalies, save_alarms.
max_events = 200
# By default the web interface does not require authentication. You can change
# that by adding a username and password hash (or multiple) below.
# To create a hash, run unifi-poller with the -e CLI argument. See Wiki for more!
[webserver.accounts]
# username = "password-hash"
# captain = "$2a$04$mxw6i0LKH6u46oaLK2cq5eCTAAFkfNiRpzNbz.EyvJZZWNa2FzIlS"
#### INPUTS
[unifi]
# Setting this to true and providing default credentials allows you to skip
# configuring controllers in this config file. Instead you configure them in
# your prometheus.yml config. Prometheus then sends the controller URL to
# unifi-poller when it performs the scrape. This is useful if you have many,
# or changing controllers. See wiki for more.
dynamic = false
# The following section contains the default credentials/configuration for any
# dynamic controller (see above section), or the primary controller if you do not
# provide one and dynamic is disabled. In other words, you can just add your
# controller here and delete the following section. The internal defaults are
# shown below. Any missing values will assume these displayed defaults.
[unifi.defaults]
# URL for the UniFi Controller. Do not add any paths after the host:port.
# Do not use port 8443 if you have a UDM; just use "https://ip".
url = "https://<YOUR_IP>:8443"
# Make a read-only user in the UniFi Admin Settings, allow it access to all sites.
user = "unifipoller"
# Password for UniFi controller user (above).
# If the password provided here begins with file:// then the password is read in from
# the file path that follows the file:// prefix. ex: file:///etc/unifi/password.file
# ex: file:///etc/unifi/passwd.file, windows: file://C:\\UserData\\Unifi\\Passwd.txt
pass = "unificontroller"
# If the controller has more than one site, specify which sites to poll here.
# Set this to ["default"] to poll only the first site on the controller.
# A setting of ["all"] will poll all sites; this works if you only have 1 site too.
sites = ["all"]
# Enable collection of site data. This data powers the Network Sites dashboard.
# It's not valuable to everyone and setting this to false will save resources.
save_sites = true
# Hash, with md5, client names and MAC addresses. This attempts to protect
# personally identifiable information. Most users won't want to enable this.
hash_pii = false
# Enable collection of Intrusion Detection System Data (InfluxDB/Loki only).
# Only useful if IDS or IPS are enabled on one of the sites. This may store
# a lot of information. Only recommended for testing and debugging. There
# may not be any dashboards to display this data. It can be used for annotations.
# Enable this only if using InfluxDB or Loki. This will leak PII data!
save_ids = false
# Enable collection of UniFi Events (InfluxDB/Loki only).
# This may store a lot of information. Only recommended for testing and debugging.
# There are no dashboards to display this data. It can be used for annotations.
# This is a new (June, 2020) feature. Please provide feedback if you try it out!
# Enable this only if using InfluxDB or Loki. This will leak PII data!
save_events = false
# Enable collection of UniFi Alarms (InfluxDB/Loki only).
# There are no dashboards to display this data. It can be used for annotations.
# This is a new (June, 2020) feature. Please provide feedback if you try it out!
# Enable this only if using InfluxDB or Loki. This will leak PII data!
save_alarms = false
# Enable collection of UniFi Anomalies (InfluxDB/Loki only).
# There are no dashboards to display this data. It can be used for annotations.
# This is a new (June, 2020) feature. Please provide feedback if you try it out!
# Enable this only if using InfluxDB or Loki.
save_anomalies = false
# Enable collection of Deep Packet Inspection data. This data breaks down traffic
# types for each client and site, it powers a dedicated DPI dashboard.
# Enabling this adds roughly 150 data points per client. That's 6000 metrics for
# 40 clients. This adds a little bit of poller run time per interval and causes
# more API requests to your controller(s). Don't let these "cons" sway you:
# it's cool data. Please provide feedback on your experience with this feature.
save_dpi = false
## Enabling save_rogue stores even more data in your time series databases.
## This saves neighboring access point metrics in a dedicated table or namespace.
save_rogue = false
# If your UniFi controller has a valid SSL certificate (like lets encrypt),
# you can enable this option to validate it. Otherwise, any SSL certificate is
# valid. If you don't know if you have a valid SSL cert, then you don't have one.
verify_ssl = false
## You may provide a list of SSL cert files (PEM format) that you expect your
## controller to use. As long as one of the certs you provide here shows up in
## the cert trust chain the controller presents it will be accepted and allowed.
## These files may be re-read while poller is running.
## Example: ssl_cert_paths = ["/path/to/cert.pem", "/another/cert.pem"]
ssl_cert_paths = []
# The following is optional and used for configurations with multiple UniFi controllers.
# You may repeat the following [[unifi.controller]] section as many times as needed to
# poll multiple controllers. Uncomment the entire section including [[unifi.controller]].
# Omitted variables will have their values taken from the defaults, above.
#
#[[unifi.controller]]
# url = "https://127.0.0.1:8443"
# user = "unifipoller"
# pass = "unifipoller"
# sites = ["all"]
# save_sites = true
# hash_pii = false
# save_ids = false
# save_events = false
# save_alarms = false
# save_anomalies = false
# save_dpi = false
# save_rogue = false
# verify_ssl = false
# ssl_cert_paths = []

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

View File

@@ -0,0 +1,35 @@
version: "3"
services:
influxdb:
container_name: up_influxdb
restart: unless-stopped
image: influxdb:1.8
networks:
- UnPollerBridge
ports:
- '8086:8086'
volumes:
- /portainer/Files/AppData/Config/unpollerinflux:/var/lib/influxdb
environment:
- INFLUXDB_DB=unifi
- INFLUXDB_ADMIN_USER=unifi
- INFLUXDB_ADMIN_PASSWORD=unifi
unpoller:
container_name: up-poller
restart: unless-stopped
image: golift/unifi-poller:latest
networks:
- UnPollerBridge
depends_on:
- influxdb
volumes:
- /portainer/Files/AppData/Config/unpoller:/etc/unifi-poller
networks:
UnPollerBridge:
ipam:
driver: default
config:
- subnet: "172.15.0.0/16"
gateway: "172.15.0.1"

View File

@@ -3919,6 +3919,26 @@
}
]
},
{
"categories": [
"Monitor",
"Tools"
],
"description": "Monitor your Unifi Controller using Grafana developed by oijkn for the Raspberry Pi Monitor.",
"logo": "https://raw.githubusercontent.com/novaspirit/pi-hosted/master/pi-hosted_template/images/unpoller-logo.png",
"name": "UnPoller Unifi Controller Monitor",
"platform": "linux",
"ports": [
"8086:8086/tcp"
],
"restart_policy": "unless-stopped",
"title": "UnPoller Monitor",
"type": 3,
"repository": {
"stackfile": "pi-hosted_template/stack/unpoller-stack.yml",
"url": "https://github.com/novaspirit/pi-hosted"
}
},
{
"categories": [
"Other",

24
unpoller-install.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
function error {
echo -e "\\e[91m$1\\e[39m"
exit 1
}
function check_internet() {
printf "Checking if you are online..."
wget -q --spider http://github.com
if [ $? -eq 0 ]; then
echo "Online. Continuing."
else
error "Offline. Go connect to the internet then run the script again."
fi
}
check_internet
echo "Creating directories..."
sudo mkdir -p /portainer/Files/AppData/Config/unpoller || error "Failed to create config directory!"
echo "Downloading Unpoller config files"
sudo wget -O /portainer/Files/AppData/Config/unpoller/up.conf https://raw.githubusercontent.com/novaspirit/pi-hosted/tree/master/pi-hosted_template/configs/up.conf || error "Failed to download up.conf file!"
echo "Done You are ready to goto next step in the install document"