Skip to content

Commit

Permalink
Merge pull request #144 from davidnewhall/dn2_ratios
Browse files Browse the repository at this point in the history
Metrics Fixes
  • Loading branch information
davidnewhall committed Dec 2, 2019
2 parents ceb44ce + 935582c commit 64d861d
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 61 deletions.
7 changes: 3 additions & 4 deletions README.md
Expand Up @@ -2,7 +2,7 @@

[![discord](https://badgen.net/badge/icon/Discord?color=0011ff&label&icon=https://simpleicons.now.sh/discord/eee "Ubiquiti Discord")](https://discord.gg/KnyKYt2)
[![twitter](https://badgen.net/twitter/follow/TwitchCaptain?icon=https://simpleicons.now.sh/twitter/0099ff&label=TwitchCaptain&color=0116ff "TwitchCaptain @ Twitter")](https://twitter.com/TwitchCaptain)
[![grafana](https://badgen.net/https/golift.io/bd/grafana/dashboard-downloads/10414,10415,10416,10417,10418,11314,11315?icon=https://simpleicons.now.sh/grafana/ED7F38&color=0011ff "Grafana Dashboard Downloads")](http://grafana.com/dashboards?search=unifi-poller)
[![grafana](https://badgen.net/https/golift.io/bd/grafana/dashboard-downloads/10414,10415,10416,10417,10418,11311,11312,11313,11314,11315?icon=https://simpleicons.now.sh/grafana/ED7F38&color=0011ff "Grafana Dashboard Downloads")](http://grafana.com/dashboards?search=unifi-poller)
[![pulls](https://badgen.net/docker/pulls/golift/unifi-poller?icon=https://simpleicons.now.sh/docker/38B1ED&label=pulls&color=0011ff "Docker Pulls")](https://hub.docker.com/r/golift/unifi-poller)
[![DLs](https://img.shields.io/github/downloads/davidnewhall/unifi-poller/total.svg?logo=github&color=0116ff "GitHub Downloads")](https://www.somsubhra.com/github-release-stats/?username=davidnewhall&repository=unifi-poller)

Expand All @@ -15,9 +15,8 @@ Collect your UniFi controller data and report it to an InfluxDB instance,
or export it for Prometheus collection. Prometheus support is
[new](https://github.com/davidnewhall/unifi-poller/issues/88), and much
of the documentation still needs to be updated; 11/30/2019.
[Seven Grafana Dashboards](http://grafana.com/dashboards?search=unifi-poller)
included; with screenshots. Five for InfluxDB and two for Prometheus, although
three more Prometheus dashboards are coming!
[Ten Grafana Dashboards](http://grafana.com/dashboards?search=unifi-poller)
included; with screenshots. Five for InfluxDB and five for Prometheus.

## Installation
[See the Wiki!](https://github.com/davidnewhall/unifi-poller/wiki/Installation)
Expand Down
2 changes: 0 additions & 2 deletions examples/up.conf.example
Expand Up @@ -33,8 +33,6 @@ quiet = false
#
# Mode "prometheus" opens an HTTP server on port 9130 and exports the metrics at
# /metrics for polling collection by a prometheus server. This disables influxdb.
# IMPORTANT: The prometheus mode is still beta.
# Please help us test and provide your feedback on the github repo!
mode = "influx"

# This controls on which ip and port /metrics is exported when mode is "prometheus".
Expand Down
2 changes: 1 addition & 1 deletion pkg/promunifi/clients.go
Expand Up @@ -95,7 +95,7 @@ func (u *promUnifi) exportClient(r report, c *unifi.Client) {
labelW[len(labelW)-1] = "false"
r.send([]*metric{
{u.Client.Anomalies, prometheus.CounterValue, c.Anomalies, labelW},
{u.Client.CCQ, prometheus.GaugeValue, c.Ccq / 1000, labelW},
{u.Client.CCQ, prometheus.GaugeValue, float64(c.Ccq) / 1000.0, labelW},
{u.Client.Satisfaction, prometheus.GaugeValue, c.Satisfaction.Val / 100.0, labelW},
{u.Client.Noise, prometheus.GaugeValue, c.Noise, labelW},
{u.Client.RoamCount, prometheus.CounterValue, c.RoamCount, labelW},
Expand Down
55 changes: 51 additions & 4 deletions pkg/promunifi/collector.go
Expand Up @@ -118,10 +118,7 @@ func (u *promUnifi) Collect(ch chan<- prometheus.Metric) {

// Pass Report interface into our collecting and reporting methods.
go u.exportMetrics(r, ch)
for _, f := range []func(report){u.loopClients, u.loopSites, u.loopUAPs, u.loopUSWs, u.loopUSGs, u.loopUDMs} {
r.add()
go f(r) // in loops.go.
}
u.loopExports(r)
}

// This is closely tied to the method above with a sync.WaitGroup.
Expand All @@ -148,3 +145,53 @@ func (u *promUnifi) exportMetrics(r report, ch chan<- prometheus.Metric) {
r.done()
}
}

func (u *promUnifi) loopExports(r report) {
r.add()
go func() {
defer r.done()
for _, s := range r.metrics().Sites {
u.exportSite(r, s)
}
}()

r.add()
go func() {
defer r.done()
for _, d := range r.metrics().UAPs {
u.exportUAP(r, d)
}
}()

r.add()
go func() {
defer r.done()
for _, d := range r.metrics().UDMs {
u.exportUDM(r, d)
}
}()

r.add()
go func() {
defer r.done()
for _, d := range r.metrics().USGs {
u.exportUSG(r, d)
}
}()

r.add()
go func() {
defer r.done()
for _, d := range r.metrics().USWs {
u.exportUSW(r, d)
}
}()

r.add()
go func() {
defer r.done()
for _, c := range r.metrics().Clients {
u.exportClient(r, c)
}
}()
}
47 changes: 0 additions & 47 deletions pkg/promunifi/loops.go

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/promunifi/uap.go
Expand Up @@ -103,7 +103,7 @@ func descUAP(ns string) *uap {
WifiTxAttempts: prometheus.NewDesc(ns+"stat_wifi_transmit_attempts_total", "Wifi Transmission Attempts", labelA, nil),
MacFilterRejections: prometheus.NewDesc(ns+"stat_mac_filter_rejects_total", "MAC Filter Rejections", labelA, nil),
// N each - 1 per Virtual AP (VAP)
VAPCcq: prometheus.NewDesc(ns+"vap_ccq", "VAP Client Connection Quality", labelV, nil),
VAPCcq: prometheus.NewDesc(ns+"vap_ccq_ratio", "VAP Client Connection Quality", labelV, nil),
VAPMacFilterRejections: prometheus.NewDesc(ns+"vap_mac_filter_rejects_total", "VAP MAC Filter Rejections", labelV, nil),
VAPNumSatisfactionSta: prometheus.NewDesc(ns+"vap_satisfaction_stations", "VAP Number Satisifaction Stations", labelV, nil),
VAPAvgClientSignal: prometheus.NewDesc(ns+"vap_average_client_signal", "VAP Average Client Signal", labelV, nil),
Expand Down Expand Up @@ -256,10 +256,10 @@ func (u *promUnifi) exportVAPtable(r report, labels []string, vt unifi.VapTable)
labelV := append([]string{v.Name, v.Bssid, v.Radio, v.RadioName, v.Essid, v.Usage}, labels[6:]...)

r.send([]*metric{
{u.UAP.VAPCcq, prometheus.GaugeValue, v.Ccq / 10, labelV},
{u.UAP.VAPCcq, prometheus.GaugeValue, float64(v.Ccq) / 1000.0, labelV},
{u.UAP.VAPMacFilterRejections, prometheus.CounterValue, v.MacFilterRejections, labelV},
{u.UAP.VAPNumSatisfactionSta, prometheus.GaugeValue, v.NumSatisfactionSta, labelV},
{u.UAP.VAPAvgClientSignal, prometheus.GaugeValue, v.AvgClientSignal, labelV},
{u.UAP.VAPAvgClientSignal, prometheus.GaugeValue, v.AvgClientSignal.Val, labelV},
{u.UAP.VAPSatisfaction, prometheus.GaugeValue, v.Satisfaction.Val / 100.0, labelV},
{u.UAP.VAPSatisfactionNow, prometheus.GaugeValue, v.SatisfactionNow.Val / 100.0, labelV},
{u.UAP.VAPDNSAvgLatency, prometheus.GaugeValue, v.DNSAvgLatency.Val / 1000, labelV},
Expand Down

0 comments on commit 64d861d

Please sign in to comment.