fix more ratios, combine export loops
This commit is contained in:
parent
ceb44ced85
commit
fa64b364c9
|
|
@ -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.
|
||||
|
|
@ -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)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
package promunifi
|
||||
|
||||
// This file contains all the loop methods for each device type, clients and sites.
|
||||
// Moved them here to consolate clutter from the other files. Also, if these change,
|
||||
// they usually all change at once since they're pretty much the same code.
|
||||
|
||||
func (u *promUnifi) loopSites(r report) {
|
||||
defer r.done()
|
||||
for _, s := range r.metrics().Sites {
|
||||
u.exportSite(r, s)
|
||||
}
|
||||
}
|
||||
|
||||
func (u *promUnifi) loopUAPs(r report) {
|
||||
defer r.done()
|
||||
for _, d := range r.metrics().UAPs {
|
||||
u.exportUAP(r, d)
|
||||
}
|
||||
}
|
||||
|
||||
func (u *promUnifi) loopUDMs(r report) {
|
||||
defer r.done()
|
||||
for _, d := range r.metrics().UDMs {
|
||||
u.exportUDM(r, d)
|
||||
}
|
||||
}
|
||||
|
||||
func (u *promUnifi) loopUSGs(r report) {
|
||||
defer r.done()
|
||||
for _, d := range r.metrics().USGs {
|
||||
u.exportUSG(r, d)
|
||||
}
|
||||
}
|
||||
|
||||
func (u *promUnifi) loopUSWs(r report) {
|
||||
defer r.done()
|
||||
for _, d := range r.metrics().USWs {
|
||||
u.exportUSW(r, d)
|
||||
}
|
||||
}
|
||||
|
||||
func (u *promUnifi) loopClients(r report) {
|
||||
defer r.done()
|
||||
for _, c := range r.metrics().Clients {
|
||||
u.exportClient(r, c)
|
||||
}
|
||||
}
|
||||
|
|
@ -103,10 +103,10 @@ 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),
|
||||
VAPAvgClientSignal: prometheus.NewDesc(ns+"vap_average_client_signal_ratio", "VAP Average Client Signal", labelV, nil),
|
||||
VAPSatisfaction: prometheus.NewDesc(ns+"vap_satisfaction_ratio", "VAP Satisfaction", labelV, nil),
|
||||
VAPSatisfactionNow: prometheus.NewDesc(ns+"vap_satisfaction_now_ratio", "VAP Satisfaction Now", labelV, nil),
|
||||
VAPDNSAvgLatency: prometheus.NewDesc(ns+"vap_dns_latency_average_seconds", "VAP DNS Latency Average", labelV, nil),
|
||||
|
|
@ -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, v.Ccq / 100.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 / 100.0, 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},
|
||||
|
|
|
|||
Loading…
Reference in New Issue