fix linter
This commit is contained in:
parent
7956f8e0ee
commit
a1b47e7242
|
|
@ -5,6 +5,14 @@ import (
|
|||
"golift.io/unifi"
|
||||
)
|
||||
|
||||
const (
|
||||
subsystemLAN = "lan"
|
||||
subsystemVPN = "vpn"
|
||||
subsystemWWW = "www"
|
||||
subsystemWLAN = "wlan"
|
||||
subsystemWAN = "wan"
|
||||
)
|
||||
|
||||
type site struct {
|
||||
NumUser *prometheus.Desc
|
||||
NumGuest *prometheus.Desc
|
||||
|
|
@ -75,12 +83,11 @@ func (u *unifiCollector) exportSites(sites unifi.Sites, r *Report) {
|
|||
for _, h := range s.Health {
|
||||
l := append([]string{h.Subsystem, h.Status}, labels...)
|
||||
|
||||
if h.Subsystem != "vpn" {
|
||||
if h.Subsystem != subsystemVPN {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.TxBytesR, prometheus.GaugeValue, h.TxBytesR.Val, l},
|
||||
{u.Site.RxBytesR, prometheus.GaugeValue, h.RxBytesR.Val, l},
|
||||
}...)
|
||||
|
||||
} else {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.RemoteUserNumActive, prometheus.CounterValue, h.RemoteUserNumActive.Val, l},
|
||||
|
|
@ -92,43 +99,7 @@ func (u *unifiCollector) exportSites(sites unifi.Sites, r *Report) {
|
|||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == "lan" || h.Subsystem == "wlan" || h.Subsystem == "wan" {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumAdopted, prometheus.CounterValue, h.NumAdopted.Val, l},
|
||||
{u.Site.NumDisconnected, prometheus.CounterValue, h.NumDisconnected.Val, l},
|
||||
{u.Site.NumPending, prometheus.CounterValue, h.NumPending.Val, l},
|
||||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == "lan" || h.Subsystem == "wlan" {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumUser, prometheus.CounterValue, h.NumUser.Val, l},
|
||||
{u.Site.NumGuest, prometheus.CounterValue, h.NumGuest.Val, l},
|
||||
{u.Site.NumIot, prometheus.CounterValue, h.NumIot.Val, l},
|
||||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == "wlan" {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumAp, prometheus.CounterValue, h.NumAp.Val, l},
|
||||
{u.Site.NumDisabled, prometheus.CounterValue, h.NumDisabled.Val, l},
|
||||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == "wan" {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumGw, prometheus.CounterValue, h.NumGw.Val, l},
|
||||
{u.Site.NumSta, prometheus.CounterValue, h.NumSta.Val, l},
|
||||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == "lan" {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumSw, prometheus.CounterValue, h.NumSw.Val, l},
|
||||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == "www" {
|
||||
if h.Subsystem == subsystemWWW {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.Uptime, prometheus.GaugeValue, h.Latency.Val, l},
|
||||
{u.Site.Latency, prometheus.GaugeValue, h.Latency.Val, l},
|
||||
|
|
@ -138,6 +109,42 @@ func (u *unifiCollector) exportSites(sites unifi.Sites, r *Report) {
|
|||
{u.Site.Drops, prometheus.CounterValue, h.Drops.Val, l},
|
||||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == subsystemLAN || h.Subsystem == subsystemWLAN || h.Subsystem == subsystemWAN {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumAdopted, prometheus.CounterValue, h.NumAdopted.Val, l},
|
||||
{u.Site.NumDisconnected, prometheus.CounterValue, h.NumDisconnected.Val, l},
|
||||
{u.Site.NumPending, prometheus.CounterValue, h.NumPending.Val, l},
|
||||
}...)
|
||||
|
||||
if h.Subsystem == subsystemLAN || h.Subsystem == subsystemWLAN {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumUser, prometheus.CounterValue, h.NumUser.Val, l},
|
||||
{u.Site.NumGuest, prometheus.CounterValue, h.NumGuest.Val, l},
|
||||
{u.Site.NumIot, prometheus.CounterValue, h.NumIot.Val, l},
|
||||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == subsystemWLAN {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumAp, prometheus.CounterValue, h.NumAp.Val, l},
|
||||
{u.Site.NumDisabled, prometheus.CounterValue, h.NumDisabled.Val, l},
|
||||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == subsystemWAN {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumGw, prometheus.CounterValue, h.NumGw.Val, l},
|
||||
{u.Site.NumSta, prometheus.CounterValue, h.NumSta.Val, l},
|
||||
}...)
|
||||
}
|
||||
|
||||
if h.Subsystem == subsystemLAN {
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.NumSw, prometheus.CounterValue, h.NumSw.Val, l},
|
||||
}...)
|
||||
}
|
||||
}
|
||||
}
|
||||
r.ch <- metrics
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue