found a bug in site code
This commit is contained in:
parent
ba42bb3c13
commit
8a01655d91
|
|
@ -37,8 +37,7 @@ func descSite(ns string) *site {
|
|||
if ns += "_site_"; ns == "_site_" {
|
||||
ns = "site_"
|
||||
}
|
||||
|
||||
labels := []string{"name", "desc", "site_name", "subsystem", "status", "gwversion"}
|
||||
labels := []string{"subsystem", "status", "gwversion", "name", "desc", "site_name"}
|
||||
|
||||
return &site{
|
||||
NumUser: prometheus.NewDesc(ns+"user_total", "Number of Users", labels, nil),
|
||||
|
|
@ -71,10 +70,13 @@ func descSite(ns string) *site {
|
|||
// exportSite exports Network Site Data
|
||||
func (u *unifiCollector) exportSite(s *unifi.Site) []*metricExports {
|
||||
labels := []string{s.Name, s.Desc, s.SiteName}
|
||||
var m []*metricExports
|
||||
var metrics []*metricExports
|
||||
|
||||
for _, h := range s.Health {
|
||||
l := append(labels, h.Subsystem, h.Status, h.GwVersion)
|
||||
m = append(m, []*metricExports{
|
||||
l := append([]string{h.Subsystem, h.Status, h.GwVersion}, labels...)
|
||||
|
||||
// XXX: More of these are subsystem specific (like the vpn/remote user stuff below)
|
||||
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},
|
||||
|
|
@ -94,8 +96,9 @@ func (u *unifiCollector) exportSite(s *unifi.Site) []*metricExports {
|
|||
{u.Site.XputDown, prometheus.GaugeValue, h.XputDown.Val, l},
|
||||
{u.Site.SpeedtestPing, prometheus.GaugeValue, h.SpeedtestPing.Val, l},
|
||||
}...)
|
||||
|
||||
if h.Subsystem == "vpn" {
|
||||
m = append(m, []*metricExports{
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.Site.RemoteUserNumActive, prometheus.CounterValue, h.RemoteUserNumActive.Val, l},
|
||||
{u.Site.RemoteUserNumInactive, prometheus.CounterValue, h.RemoteUserNumInactive.Val, l},
|
||||
{u.Site.RemoteUserRxBytes, prometheus.CounterValue, h.RemoteUserRxBytes.Val, l},
|
||||
|
|
@ -105,5 +108,6 @@ func (u *unifiCollector) exportSite(s *unifi.Site) []*metricExports {
|
|||
}...)
|
||||
}
|
||||
}
|
||||
return m
|
||||
|
||||
return metrics
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,31 +103,31 @@ func descUAP(ns string) *uap {
|
|||
}
|
||||
|
||||
// exportUAP exports Access Point Data
|
||||
func (u *unifiCollector) exportUAP(s *unifi.UAP) []*metricExports {
|
||||
labels := []string{s.SiteName, s.Mac, s.Model, s.Name, s.Serial, s.SiteID,
|
||||
s.Type, s.Version, s.DeviceID, s.IP}
|
||||
func (u *unifiCollector) exportUAP(a *unifi.UAP) []*metricExports {
|
||||
labels := []string{a.SiteName, a.Mac, a.Model, a.Name, a.Serial, a.SiteID,
|
||||
a.Type, a.Version, a.DeviceID, a.IP}
|
||||
|
||||
// Switch data.
|
||||
m := []*metricExports{
|
||||
{u.UAP.Uptime, prometheus.GaugeValue, s.Uptime, labels},
|
||||
{u.UAP.TotalTxBytes, prometheus.CounterValue, s.TxBytes, labels},
|
||||
{u.UAP.TotalRxBytes, prometheus.CounterValue, s.RxBytes, labels},
|
||||
{u.UAP.TotalBytes, prometheus.CounterValue, s.Bytes, labels},
|
||||
{u.UAP.BytesD, prometheus.CounterValue, s.BytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
||||
{u.UAP.TxBytesD, prometheus.CounterValue, s.TxBytesD, labels},
|
||||
{u.UAP.RxBytesD, prometheus.CounterValue, s.RxBytesD, labels},
|
||||
{u.UAP.BytesR, prometheus.GaugeValue, s.BytesR, labels},
|
||||
{u.UAP.NumSta, prometheus.GaugeValue, s.NumSta, labels},
|
||||
{u.UAP.UserNumSta, prometheus.GaugeValue, s.UserNumSta, labels},
|
||||
{u.UAP.GuestNumSta, prometheus.GaugeValue, s.GuestNumSta, labels},
|
||||
{u.UAP.Loadavg1, prometheus.GaugeValue, s.SysStats.Loadavg1, labels},
|
||||
{u.UAP.Loadavg5, prometheus.GaugeValue, s.SysStats.Loadavg5, labels},
|
||||
{u.UAP.Loadavg15, prometheus.GaugeValue, s.SysStats.Loadavg15, labels},
|
||||
{u.UAP.MemUsed, prometheus.GaugeValue, s.SysStats.MemUsed, labels},
|
||||
{u.UAP.MemTotal, prometheus.GaugeValue, s.SysStats.MemTotal, labels},
|
||||
{u.UAP.MemBuffer, prometheus.GaugeValue, s.SysStats.MemBuffer, labels},
|
||||
{u.UAP.CPU, prometheus.GaugeValue, s.SystemStats.CPU, labels},
|
||||
{u.UAP.Mem, prometheus.GaugeValue, s.SystemStats.Mem, labels},
|
||||
metrics := []*metricExports{
|
||||
{u.UAP.Uptime, prometheus.GaugeValue, a.Uptime, labels},
|
||||
{u.UAP.TotalTxBytes, prometheus.CounterValue, a.TxBytes, labels},
|
||||
{u.UAP.TotalRxBytes, prometheus.CounterValue, a.RxBytes, labels},
|
||||
{u.UAP.TotalBytes, prometheus.CounterValue, a.Bytes, labels},
|
||||
{u.UAP.BytesD, prometheus.CounterValue, a.BytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
||||
{u.UAP.TxBytesD, prometheus.CounterValue, a.TxBytesD, labels},
|
||||
{u.UAP.RxBytesD, prometheus.CounterValue, a.RxBytesD, labels},
|
||||
{u.UAP.BytesR, prometheus.GaugeValue, a.BytesR, labels},
|
||||
{u.UAP.NumSta, prometheus.GaugeValue, a.NumSta, labels},
|
||||
{u.UAP.UserNumSta, prometheus.GaugeValue, a.UserNumSta, labels},
|
||||
{u.UAP.GuestNumSta, prometheus.GaugeValue, a.GuestNumSta, labels},
|
||||
{u.UAP.Loadavg1, prometheus.GaugeValue, a.SysStats.Loadavg1, labels},
|
||||
{u.UAP.Loadavg5, prometheus.GaugeValue, a.SysStats.Loadavg5, labels},
|
||||
{u.UAP.Loadavg15, prometheus.GaugeValue, a.SysStats.Loadavg15, labels},
|
||||
{u.UAP.MemUsed, prometheus.GaugeValue, a.SysStats.MemUsed, labels},
|
||||
{u.UAP.MemTotal, prometheus.GaugeValue, a.SysStats.MemTotal, labels},
|
||||
{u.UAP.MemBuffer, prometheus.GaugeValue, a.SysStats.MemBuffer, labels},
|
||||
{u.UAP.CPU, prometheus.GaugeValue, a.SystemStats.CPU, labels},
|
||||
{u.UAP.Mem, prometheus.GaugeValue, a.SystemStats.Mem, labels},
|
||||
}
|
||||
return m
|
||||
return metrics
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,14 +157,14 @@ func (u *unifiCollector) exportUSG(s *unifi.USG) []*metricExports {
|
|||
}
|
||||
|
||||
func (u *unifiCollector) exportWANPorts(labels []string, wans ...unifi.Wan) []*metricExports {
|
||||
var m []*metricExports
|
||||
var metrics []*metricExports
|
||||
for _, wan := range wans {
|
||||
if !wan.Up.Val {
|
||||
continue // only record UP interfaces.
|
||||
}
|
||||
l := append([]string{wan.Name}, labels...)
|
||||
|
||||
m = append(m, []*metricExports{
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.USG.WanRxPackets, prometheus.CounterValue, wan.RxPackets, l},
|
||||
{u.USG.WanRxBytes, prometheus.CounterValue, wan.RxBytes, l},
|
||||
{u.USG.WanRxDropped, prometheus.CounterValue, wan.RxDropped, l},
|
||||
|
|
@ -183,5 +183,5 @@ func (u *unifiCollector) exportWANPorts(labels []string, wans ...unifi.Wan) []*m
|
|||
}...)
|
||||
}
|
||||
|
||||
return m
|
||||
return metrics
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,12 +182,13 @@ func (u *unifiCollector) exportUSW(s *unifi.USW) []*metricExports {
|
|||
}
|
||||
|
||||
func (u *unifiCollector) exportPortTable(pt []unifi.Port, labels []string) []*metricExports {
|
||||
var m []*metricExports
|
||||
var metrics []*metricExports
|
||||
// Per-port data on a switch
|
||||
for _, p := range pt {
|
||||
// Copy labels, and add four new ones.
|
||||
l := append(append([]string{}, labels...), p.PortIdx.Txt, p.Name, p.Mac, p.IP)
|
||||
m = append(m, []*metricExports{
|
||||
|
||||
metrics = append(metrics, []*metricExports{
|
||||
{u.USW.PoeCurrent, prometheus.GaugeValue, p.PoeCurrent, l},
|
||||
{u.USW.PoePower, prometheus.GaugeValue, p.PoePower, l},
|
||||
{u.USW.PoeVoltage, prometheus.GaugeValue, p.PoeVoltage, l},
|
||||
|
|
@ -208,5 +209,6 @@ func (u *unifiCollector) exportPortTable(pt []unifi.Port, labels []string) []*me
|
|||
{u.USW.TxMulticast, prometheus.CounterValue, p.TxMulticast, l},
|
||||
}...)
|
||||
}
|
||||
return m
|
||||
|
||||
return metrics
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue