unify variable names
This commit is contained in:
parent
6419422424
commit
61b43f2696
141
promunifi/uap.go
141
promunifi/uap.go
|
|
@ -220,96 +220,97 @@ func (u *unifiCollector) exportUAPs(r *Report) {
|
|||
r.wg.Add(one)
|
||||
go func() {
|
||||
defer r.wg.Done()
|
||||
for _, a := range r.Metrics.Devices.UAPs {
|
||||
u.exportUAP(r, a)
|
||||
for _, d := range r.Metrics.Devices.UAPs {
|
||||
u.exportUAP(r, d)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (u *unifiCollector) exportUAP(r *Report, a *unifi.UAP) {
|
||||
labels := []string{a.IP, a.Type, a.Version, a.SiteName, a.Mac, a.Model, a.Name, a.Serial}
|
||||
func (u *unifiCollector) exportUAP(r *Report, d *unifi.UAP) {
|
||||
labels := []string{d.IP, d.Type, d.Version, d.SiteName, d.Mac, d.Model, d.Name, d.Serial}
|
||||
|
||||
// AP data.
|
||||
r.send([]*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}, // not sure if these 3 Ds are counters or gauges.
|
||||
{u.UAP.RxBytesD, prometheus.CounterValue, a.RxBytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
||||
{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},
|
||||
{u.UAP.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
||||
{u.UAP.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
||||
{u.UAP.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
||||
{u.UAP.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
||||
{u.UAP.BytesD, prometheus.CounterValue, d.BytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
||||
{u.UAP.TxBytesD, prometheus.CounterValue, d.TxBytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
||||
{u.UAP.RxBytesD, prometheus.CounterValue, d.RxBytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
||||
{u.UAP.BytesR, prometheus.GaugeValue, d.BytesR, labels},
|
||||
{u.UAP.NumSta, prometheus.GaugeValue, d.NumSta, labels},
|
||||
{u.UAP.UserNumSta, prometheus.GaugeValue, d.UserNumSta, labels},
|
||||
{u.UAP.GuestNumSta, prometheus.GaugeValue, d.GuestNumSta, labels},
|
||||
{u.UAP.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
||||
{u.UAP.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
||||
{u.UAP.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
||||
{u.UAP.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
||||
{u.UAP.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
||||
{u.UAP.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
||||
{u.UAP.CPU, prometheus.GaugeValue, d.SystemStats.CPU, labels},
|
||||
{u.UAP.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels},
|
||||
})
|
||||
u.exportUAPstats(r, labels[2:], a.Stat.Ap)
|
||||
u.exportVAPtable(r, labels[2:], a.VapTable, a.RadioTable, a.RadioTableStats)
|
||||
u.exportUAPstats(r, labels[2:], d.Stat.Ap)
|
||||
u.exportVAPtable(r, labels[2:], d.VapTable)
|
||||
u.exportRadtable(r, labels[2:], d.RadioTable, d.RadioTableStats)
|
||||
}
|
||||
|
||||
func (u *unifiCollector) exportUAPstats(r *Report, labels []string, a *unifi.Ap) {
|
||||
func (u *unifiCollector) exportUAPstats(r *Report, labels []string, ap *unifi.Ap) {
|
||||
labelA := append([]string{"all"}, labels...)
|
||||
labelU := append([]string{"user"}, labels...)
|
||||
labelG := append([]string{"guest"}, labels...)
|
||||
|
||||
r.send([]*metricExports{
|
||||
// all
|
||||
{u.UAP.ApWifiTxDropped, prometheus.CounterValue, a.WifiTxDropped, labelA},
|
||||
{u.UAP.ApRxErrors, prometheus.CounterValue, a.RxErrors, labelA},
|
||||
{u.UAP.ApRxDropped, prometheus.CounterValue, a.RxDropped, labelA},
|
||||
{u.UAP.ApRxFrags, prometheus.CounterValue, a.RxFrags, labelA},
|
||||
{u.UAP.ApRxCrypts, prometheus.CounterValue, a.RxCrypts, labelA},
|
||||
{u.UAP.ApTxPackets, prometheus.CounterValue, a.TxPackets, labelA},
|
||||
{u.UAP.ApTxBytes, prometheus.CounterValue, a.TxBytes, labelA},
|
||||
{u.UAP.ApTxErrors, prometheus.CounterValue, a.TxErrors, labelA},
|
||||
{u.UAP.ApTxDropped, prometheus.CounterValue, a.TxDropped, labelA},
|
||||
{u.UAP.ApTxRetries, prometheus.CounterValue, a.TxRetries, labelA},
|
||||
{u.UAP.ApRxPackets, prometheus.CounterValue, a.RxPackets, labelA},
|
||||
{u.UAP.ApRxBytes, prometheus.CounterValue, a.RxBytes, labelA},
|
||||
{u.UAP.WifiTxAttempts, prometheus.CounterValue, a.WifiTxAttempts, labelA},
|
||||
{u.UAP.MacFilterRejections, prometheus.CounterValue, a.MacFilterRejections, labelA},
|
||||
{u.UAP.ApWifiTxDropped, prometheus.CounterValue, ap.WifiTxDropped, labelA},
|
||||
{u.UAP.ApRxErrors, prometheus.CounterValue, ap.RxErrors, labelA},
|
||||
{u.UAP.ApRxDropped, prometheus.CounterValue, ap.RxDropped, labelA},
|
||||
{u.UAP.ApRxFrags, prometheus.CounterValue, ap.RxFrags, labelA},
|
||||
{u.UAP.ApRxCrypts, prometheus.CounterValue, ap.RxCrypts, labelA},
|
||||
{u.UAP.ApTxPackets, prometheus.CounterValue, ap.TxPackets, labelA},
|
||||
{u.UAP.ApTxBytes, prometheus.CounterValue, ap.TxBytes, labelA},
|
||||
{u.UAP.ApTxErrors, prometheus.CounterValue, ap.TxErrors, labelA},
|
||||
{u.UAP.ApTxDropped, prometheus.CounterValue, ap.TxDropped, labelA},
|
||||
{u.UAP.ApTxRetries, prometheus.CounterValue, ap.TxRetries, labelA},
|
||||
{u.UAP.ApRxPackets, prometheus.CounterValue, ap.RxPackets, labelA},
|
||||
{u.UAP.ApRxBytes, prometheus.CounterValue, ap.RxBytes, labelA},
|
||||
{u.UAP.WifiTxAttempts, prometheus.CounterValue, ap.WifiTxAttempts, labelA},
|
||||
{u.UAP.MacFilterRejections, prometheus.CounterValue, ap.MacFilterRejections, labelA},
|
||||
// user
|
||||
{u.UAP.ApWifiTxDropped, prometheus.CounterValue, a.UserWifiTxDropped, labelU},
|
||||
{u.UAP.ApRxErrors, prometheus.CounterValue, a.UserRxErrors, labelU},
|
||||
{u.UAP.ApRxDropped, prometheus.CounterValue, a.UserRxDropped, labelU},
|
||||
{u.UAP.ApRxFrags, prometheus.CounterValue, a.UserRxFrags, labelU},
|
||||
{u.UAP.ApRxCrypts, prometheus.CounterValue, a.UserRxCrypts, labelU},
|
||||
{u.UAP.ApTxPackets, prometheus.CounterValue, a.UserTxPackets, labelU},
|
||||
{u.UAP.ApTxBytes, prometheus.CounterValue, a.UserTxBytes, labelU},
|
||||
{u.UAP.ApTxErrors, prometheus.CounterValue, a.UserTxErrors, labelU},
|
||||
{u.UAP.ApTxDropped, prometheus.CounterValue, a.UserTxDropped, labelU},
|
||||
{u.UAP.ApTxRetries, prometheus.CounterValue, a.UserTxRetries, labelU},
|
||||
{u.UAP.ApRxPackets, prometheus.CounterValue, a.UserRxPackets, labelU},
|
||||
{u.UAP.ApRxBytes, prometheus.CounterValue, a.UserRxBytes, labelU},
|
||||
{u.UAP.WifiTxAttempts, prometheus.CounterValue, a.UserWifiTxAttempts, labelU},
|
||||
{u.UAP.MacFilterRejections, prometheus.CounterValue, a.UserMacFilterRejections, labelU},
|
||||
{u.UAP.ApWifiTxDropped, prometheus.CounterValue, ap.UserWifiTxDropped, labelU},
|
||||
{u.UAP.ApRxErrors, prometheus.CounterValue, ap.UserRxErrors, labelU},
|
||||
{u.UAP.ApRxDropped, prometheus.CounterValue, ap.UserRxDropped, labelU},
|
||||
{u.UAP.ApRxFrags, prometheus.CounterValue, ap.UserRxFrags, labelU},
|
||||
{u.UAP.ApRxCrypts, prometheus.CounterValue, ap.UserRxCrypts, labelU},
|
||||
{u.UAP.ApTxPackets, prometheus.CounterValue, ap.UserTxPackets, labelU},
|
||||
{u.UAP.ApTxBytes, prometheus.CounterValue, ap.UserTxBytes, labelU},
|
||||
{u.UAP.ApTxErrors, prometheus.CounterValue, ap.UserTxErrors, labelU},
|
||||
{u.UAP.ApTxDropped, prometheus.CounterValue, ap.UserTxDropped, labelU},
|
||||
{u.UAP.ApTxRetries, prometheus.CounterValue, ap.UserTxRetries, labelU},
|
||||
{u.UAP.ApRxPackets, prometheus.CounterValue, ap.UserRxPackets, labelU},
|
||||
{u.UAP.ApRxBytes, prometheus.CounterValue, ap.UserRxBytes, labelU},
|
||||
{u.UAP.WifiTxAttempts, prometheus.CounterValue, ap.UserWifiTxAttempts, labelU},
|
||||
{u.UAP.MacFilterRejections, prometheus.CounterValue, ap.UserMacFilterRejections, labelU},
|
||||
// guest
|
||||
{u.UAP.ApWifiTxDropped, prometheus.CounterValue, a.GuestWifiTxDropped, labelG},
|
||||
{u.UAP.ApRxErrors, prometheus.CounterValue, a.GuestRxErrors, labelG},
|
||||
{u.UAP.ApRxDropped, prometheus.CounterValue, a.GuestRxDropped, labelG},
|
||||
{u.UAP.ApRxFrags, prometheus.CounterValue, a.GuestRxFrags, labelG},
|
||||
{u.UAP.ApRxCrypts, prometheus.CounterValue, a.GuestRxCrypts, labelG},
|
||||
{u.UAP.ApTxPackets, prometheus.CounterValue, a.GuestTxPackets, labelG},
|
||||
{u.UAP.ApTxBytes, prometheus.CounterValue, a.GuestTxBytes, labelG},
|
||||
{u.UAP.ApTxErrors, prometheus.CounterValue, a.GuestTxErrors, labelG},
|
||||
{u.UAP.ApTxDropped, prometheus.CounterValue, a.GuestTxDropped, labelG},
|
||||
{u.UAP.ApTxRetries, prometheus.CounterValue, a.GuestTxRetries, labelG},
|
||||
{u.UAP.ApRxPackets, prometheus.CounterValue, a.GuestRxPackets, labelG},
|
||||
{u.UAP.ApRxBytes, prometheus.CounterValue, a.GuestRxBytes, labelG},
|
||||
{u.UAP.WifiTxAttempts, prometheus.CounterValue, a.GuestWifiTxAttempts, labelG},
|
||||
{u.UAP.MacFilterRejections, prometheus.CounterValue, a.GuestMacFilterRejections, labelG},
|
||||
{u.UAP.ApWifiTxDropped, prometheus.CounterValue, ap.GuestWifiTxDropped, labelG},
|
||||
{u.UAP.ApRxErrors, prometheus.CounterValue, ap.GuestRxErrors, labelG},
|
||||
{u.UAP.ApRxDropped, prometheus.CounterValue, ap.GuestRxDropped, labelG},
|
||||
{u.UAP.ApRxFrags, prometheus.CounterValue, ap.GuestRxFrags, labelG},
|
||||
{u.UAP.ApRxCrypts, prometheus.CounterValue, ap.GuestRxCrypts, labelG},
|
||||
{u.UAP.ApTxPackets, prometheus.CounterValue, ap.GuestTxPackets, labelG},
|
||||
{u.UAP.ApTxBytes, prometheus.CounterValue, ap.GuestTxBytes, labelG},
|
||||
{u.UAP.ApTxErrors, prometheus.CounterValue, ap.GuestTxErrors, labelG},
|
||||
{u.UAP.ApTxDropped, prometheus.CounterValue, ap.GuestTxDropped, labelG},
|
||||
{u.UAP.ApTxRetries, prometheus.CounterValue, ap.GuestTxRetries, labelG},
|
||||
{u.UAP.ApRxPackets, prometheus.CounterValue, ap.GuestRxPackets, labelG},
|
||||
{u.UAP.ApRxBytes, prometheus.CounterValue, ap.GuestRxBytes, labelG},
|
||||
{u.UAP.WifiTxAttempts, prometheus.CounterValue, ap.GuestWifiTxAttempts, labelG},
|
||||
{u.UAP.MacFilterRejections, prometheus.CounterValue, ap.GuestMacFilterRejections, labelG},
|
||||
})
|
||||
}
|
||||
|
||||
func (u *unifiCollector) exportVAPtable(r *Report, labels []string, vt unifi.VapTable, rt unifi.RadioTable, rts unifi.RadioTableStats) {
|
||||
func (u *unifiCollector) exportVAPtable(r *Report, labels []string, vt unifi.VapTable) {
|
||||
// vap table stats
|
||||
for _, v := range vt {
|
||||
if !v.Up.Val {
|
||||
|
|
@ -356,7 +357,9 @@ func (u *unifiCollector) exportVAPtable(r *Report, labels []string, vt unifi.Vap
|
|||
{u.UAP.VAPWifiTxLatencyMovCount, prometheus.CounterValue, v.WifiTxLatencyMov.TotalCount, labelV}, // not sure if gauge or counter.
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (u *unifiCollector) exportRadtable(r *Report, labels []string, rt unifi.RadioTable, rts unifi.RadioTableStats) {
|
||||
// radio table
|
||||
for _, p := range rt {
|
||||
labelR := append([]string{p.Name, p.Radio}, labels...)
|
||||
|
|
|
|||
|
|
@ -19,35 +19,36 @@ func (u *unifiCollector) exportUDMs(r *Report) {
|
|||
}
|
||||
|
||||
// UDM is a collection of stats from USG, USW and UAP. It has no unique stats.
|
||||
func (u *unifiCollector) exportUDM(r *Report, s *unifi.UDM) {
|
||||
labels := []string{s.IP, s.Type, s.Version, s.SiteName, s.Mac, s.Model, s.Name, s.Serial}
|
||||
func (u *unifiCollector) exportUDM(r *Report, d *unifi.UDM) {
|
||||
labels := []string{d.IP, d.Type, d.Version, d.SiteName, d.Mac, d.Model, d.Name, d.Serial}
|
||||
// Gateway System Data.
|
||||
r.send([]*metricExports{
|
||||
{u.USG.Uptime, prometheus.GaugeValue, s.Uptime, labels},
|
||||
{u.USG.TotalTxBytes, prometheus.CounterValue, s.TxBytes, labels},
|
||||
{u.USG.TotalRxBytes, prometheus.CounterValue, s.RxBytes, labels},
|
||||
{u.USG.TotalBytes, prometheus.CounterValue, s.Bytes, labels},
|
||||
{u.USG.NumSta, prometheus.GaugeValue, s.NumSta, labels},
|
||||
{u.USG.UserNumSta, prometheus.GaugeValue, s.UserNumSta, labels},
|
||||
{u.USG.GuestNumSta, prometheus.GaugeValue, s.GuestNumSta, labels},
|
||||
{u.USG.NumDesktop, prometheus.GaugeValue, s.NumDesktop, labels},
|
||||
{u.USG.NumMobile, prometheus.GaugeValue, s.NumMobile, labels},
|
||||
{u.USG.NumHandheld, prometheus.GaugeValue, s.NumHandheld, labels},
|
||||
{u.USG.Loadavg1, prometheus.GaugeValue, s.SysStats.Loadavg1, labels},
|
||||
{u.USG.Loadavg5, prometheus.GaugeValue, s.SysStats.Loadavg5, labels},
|
||||
{u.USG.Loadavg15, prometheus.GaugeValue, s.SysStats.Loadavg15, labels},
|
||||
{u.USG.MemUsed, prometheus.GaugeValue, s.SysStats.MemUsed, labels},
|
||||
{u.USG.MemTotal, prometheus.GaugeValue, s.SysStats.MemTotal, labels},
|
||||
{u.USG.MemBuffer, prometheus.GaugeValue, s.SysStats.MemBuffer, labels},
|
||||
{u.USG.CPU, prometheus.GaugeValue, s.SystemStats.CPU, labels},
|
||||
{u.USG.Mem, prometheus.GaugeValue, s.SystemStats.Mem, labels},
|
||||
{u.USG.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
||||
{u.USG.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
||||
{u.USG.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
||||
{u.USG.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
||||
{u.USG.NumSta, prometheus.GaugeValue, d.NumSta, labels},
|
||||
{u.USG.UserNumSta, prometheus.GaugeValue, d.UserNumSta, labels},
|
||||
{u.USG.GuestNumSta, prometheus.GaugeValue, d.GuestNumSta, labels},
|
||||
{u.USG.NumDesktop, prometheus.GaugeValue, d.NumDesktop, labels},
|
||||
{u.USG.NumMobile, prometheus.GaugeValue, d.NumMobile, labels},
|
||||
{u.USG.NumHandheld, prometheus.GaugeValue, d.NumHandheld, labels},
|
||||
{u.USG.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
||||
{u.USG.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
||||
{u.USG.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
||||
{u.USG.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
||||
{u.USG.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
||||
{u.USG.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
||||
{u.USG.CPU, prometheus.GaugeValue, d.SystemStats.CPU, labels},
|
||||
{u.USG.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels},
|
||||
})
|
||||
u.exportUSWstats(r, s.Stat.Sw, labels)
|
||||
u.exportUSGstats(r, s.Stat.Gw, s.SpeedtestStatus, labels)
|
||||
u.exportWANPorts(r, labels, s.Wan1, s.Wan2)
|
||||
u.exportPortTable(r, s.PortTable, labels[4:])
|
||||
if s.Stat.Ap != nil && s.VapTable != nil {
|
||||
u.exportUAPstats(r, labels[2:], s.Stat.Ap)
|
||||
u.exportVAPtable(r, labels[2:], *s.VapTable, *s.RadioTable, *s.RadioTableStats)
|
||||
u.exportUSWstats(r, d.Stat.Sw, labels)
|
||||
u.exportUSGstats(r, d.Stat.Gw, d.SpeedtestStatus, labels)
|
||||
u.exportWANPorts(r, labels, d.Wan1, d.Wan2)
|
||||
u.exportPortTable(r, d.PortTable, labels[4:])
|
||||
if d.Stat.Ap != nil && d.VapTable != nil {
|
||||
u.exportUAPstats(r, labels[2:], d.Stat.Ap)
|
||||
u.exportVAPtable(r, labels[2:], *d.VapTable)
|
||||
u.exportRadtable(r, labels[2:], *d.RadioTable, *d.RadioTableStats)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,54 +114,54 @@ func (u *unifiCollector) exportUSGs(r *Report) {
|
|||
r.wg.Add(one)
|
||||
go func() {
|
||||
defer r.wg.Done()
|
||||
for _, s := range r.Metrics.Devices.USGs {
|
||||
u.exportUSG(r, s)
|
||||
for _, d := range r.Metrics.Devices.USGs {
|
||||
u.exportUSG(r, d)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (u *unifiCollector) exportUSG(r *Report, s *unifi.USG) {
|
||||
labels := []string{s.IP, s.Type, s.Version, s.SiteName, s.Mac, s.Model, s.Name, s.Serial}
|
||||
func (u *unifiCollector) exportUSG(r *Report, d *unifi.USG) {
|
||||
labels := []string{d.IP, d.Type, d.Version, d.SiteName, d.Mac, d.Model, d.Name, d.Serial}
|
||||
// Gateway System Data.
|
||||
r.send([]*metricExports{
|
||||
{u.USG.Uptime, prometheus.GaugeValue, s.Uptime, labels},
|
||||
{u.USG.TotalTxBytes, prometheus.CounterValue, s.TxBytes, labels},
|
||||
{u.USG.TotalRxBytes, prometheus.CounterValue, s.RxBytes, labels},
|
||||
{u.USG.TotalBytes, prometheus.CounterValue, s.Bytes, labels},
|
||||
{u.USG.NumSta, prometheus.GaugeValue, s.NumSta, labels},
|
||||
{u.USG.UserNumSta, prometheus.GaugeValue, s.UserNumSta, labels},
|
||||
{u.USG.GuestNumSta, prometheus.GaugeValue, s.GuestNumSta, labels},
|
||||
{u.USG.NumDesktop, prometheus.GaugeValue, s.NumDesktop, labels},
|
||||
{u.USG.NumMobile, prometheus.GaugeValue, s.NumMobile, labels},
|
||||
{u.USG.NumHandheld, prometheus.GaugeValue, s.NumHandheld, labels},
|
||||
{u.USG.Loadavg1, prometheus.GaugeValue, s.SysStats.Loadavg1, labels},
|
||||
{u.USG.Loadavg5, prometheus.GaugeValue, s.SysStats.Loadavg5, labels},
|
||||
{u.USG.Loadavg15, prometheus.GaugeValue, s.SysStats.Loadavg15, labels},
|
||||
{u.USG.MemUsed, prometheus.GaugeValue, s.SysStats.MemUsed, labels},
|
||||
{u.USG.MemTotal, prometheus.GaugeValue, s.SysStats.MemTotal, labels},
|
||||
{u.USG.MemBuffer, prometheus.GaugeValue, s.SysStats.MemBuffer, labels},
|
||||
{u.USG.CPU, prometheus.GaugeValue, s.SystemStats.CPU, labels},
|
||||
{u.USG.Mem, prometheus.GaugeValue, s.SystemStats.Mem, labels},
|
||||
{u.USG.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
||||
{u.USG.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
||||
{u.USG.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
||||
{u.USG.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
||||
{u.USG.NumSta, prometheus.GaugeValue, d.NumSta, labels},
|
||||
{u.USG.UserNumSta, prometheus.GaugeValue, d.UserNumSta, labels},
|
||||
{u.USG.GuestNumSta, prometheus.GaugeValue, d.GuestNumSta, labels},
|
||||
{u.USG.NumDesktop, prometheus.GaugeValue, d.NumDesktop, labels},
|
||||
{u.USG.NumMobile, prometheus.GaugeValue, d.NumMobile, labels},
|
||||
{u.USG.NumHandheld, prometheus.GaugeValue, d.NumHandheld, labels},
|
||||
{u.USG.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
||||
{u.USG.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
||||
{u.USG.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
||||
{u.USG.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
||||
{u.USG.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
||||
{u.USG.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
||||
{u.USG.CPU, prometheus.GaugeValue, d.SystemStats.CPU, labels},
|
||||
{u.USG.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels},
|
||||
})
|
||||
u.exportWANPorts(r, labels, s.Wan1, s.Wan2)
|
||||
u.exportUSGstats(r, s.Stat.Gw, s.SpeedtestStatus, labels)
|
||||
u.exportWANPorts(r, labels, d.Wan1, d.Wan2)
|
||||
u.exportUSGstats(r, d.Stat.Gw, d.SpeedtestStatus, labels)
|
||||
}
|
||||
|
||||
func (u *unifiCollector) exportUSGstats(r *Report, s *unifi.Gw, st unifi.SpeedtestStatus, labels []string) {
|
||||
func (u *unifiCollector) exportUSGstats(r *Report, gw *unifi.Gw, st unifi.SpeedtestStatus, labels []string) {
|
||||
labelWan := append([]string{"all"}, labels...)
|
||||
r.send([]*metricExports{
|
||||
// Combined Port Stats
|
||||
{u.USG.WanRxPackets, prometheus.CounterValue, s.WanRxPackets, labelWan},
|
||||
{u.USG.WanRxBytes, prometheus.CounterValue, s.WanRxBytes, labelWan},
|
||||
{u.USG.WanRxDropped, prometheus.CounterValue, s.WanRxDropped, labelWan},
|
||||
{u.USG.WanTxPackets, prometheus.CounterValue, s.WanTxPackets, labelWan},
|
||||
{u.USG.WanTxBytes, prometheus.CounterValue, s.WanTxBytes, labelWan},
|
||||
{u.USG.WanRxErrors, prometheus.CounterValue, s.WanRxErrors, labelWan},
|
||||
{u.USG.LanRxPackets, prometheus.CounterValue, s.LanRxPackets, labels},
|
||||
{u.USG.LanRxBytes, prometheus.CounterValue, s.LanRxBytes, labels},
|
||||
{u.USG.LanTxPackets, prometheus.CounterValue, s.LanTxPackets, labels},
|
||||
{u.USG.LanTxBytes, prometheus.CounterValue, s.LanTxBytes, labels},
|
||||
{u.USG.LanRxDropped, prometheus.CounterValue, s.LanRxDropped, labels},
|
||||
{u.USG.WanRxPackets, prometheus.CounterValue, gw.WanRxPackets, labelWan},
|
||||
{u.USG.WanRxBytes, prometheus.CounterValue, gw.WanRxBytes, labelWan},
|
||||
{u.USG.WanRxDropped, prometheus.CounterValue, gw.WanRxDropped, labelWan},
|
||||
{u.USG.WanTxPackets, prometheus.CounterValue, gw.WanTxPackets, labelWan},
|
||||
{u.USG.WanTxBytes, prometheus.CounterValue, gw.WanTxBytes, labelWan},
|
||||
{u.USG.WanRxErrors, prometheus.CounterValue, gw.WanRxErrors, labelWan},
|
||||
{u.USG.LanRxPackets, prometheus.CounterValue, gw.LanRxPackets, labels},
|
||||
{u.USG.LanRxBytes, prometheus.CounterValue, gw.LanRxBytes, labels},
|
||||
{u.USG.LanTxPackets, prometheus.CounterValue, gw.LanTxPackets, labels},
|
||||
{u.USG.LanTxBytes, prometheus.CounterValue, gw.LanTxBytes, labels},
|
||||
{u.USG.LanRxDropped, prometheus.CounterValue, gw.LanRxDropped, labels},
|
||||
// Speed Test Stats
|
||||
{u.USG.Latency, prometheus.GaugeValue, st.Latency.Val / 1000, labels},
|
||||
{u.USG.Runtime, prometheus.GaugeValue, st.Runtime, labels},
|
||||
|
|
|
|||
|
|
@ -142,63 +142,63 @@ func (u *unifiCollector) exportUSWs(r *Report) {
|
|||
r.wg.Add(one)
|
||||
go func() {
|
||||
defer r.wg.Done()
|
||||
for _, s := range r.Metrics.Devices.USWs {
|
||||
u.exportUSW(r, s)
|
||||
for _, d := range r.Metrics.Devices.USWs {
|
||||
u.exportUSW(r, d)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (u *unifiCollector) exportUSW(r *Report, s *unifi.USW) {
|
||||
labels := []string{s.IP, s.Type, s.Version, s.SiteName, s.Mac, s.Model, s.Name, s.Serial}
|
||||
func (u *unifiCollector) exportUSW(r *Report, d *unifi.USW) {
|
||||
labels := []string{d.IP, d.Type, d.Version, d.SiteName, d.Mac, d.Model, d.Name, d.Serial}
|
||||
|
||||
if s.HasTemperature.Val {
|
||||
r.send([]*metricExports{{u.USW.Temperature, prometheus.GaugeValue, s.GeneralTemperature, labels}})
|
||||
if d.HasTemperature.Val {
|
||||
r.send([]*metricExports{{u.USW.Temperature, prometheus.GaugeValue, d.GeneralTemperature, labels}})
|
||||
}
|
||||
if s.HasFan.Val {
|
||||
r.send([]*metricExports{{u.USW.FanLevel, prometheus.GaugeValue, s.FanLevel, labels}})
|
||||
if d.HasFan.Val {
|
||||
r.send([]*metricExports{{u.USW.FanLevel, prometheus.GaugeValue, d.FanLevel, labels}})
|
||||
}
|
||||
|
||||
// Switch data.
|
||||
r.send([]*metricExports{
|
||||
{u.USW.Uptime, prometheus.GaugeValue, s.Uptime, labels},
|
||||
{u.USW.TotalMaxPower, prometheus.GaugeValue, s.TotalMaxPower, labels},
|
||||
{u.USW.TotalTxBytes, prometheus.CounterValue, s.TxBytes, labels},
|
||||
{u.USW.TotalRxBytes, prometheus.CounterValue, s.RxBytes, labels},
|
||||
{u.USW.TotalBytes, prometheus.CounterValue, s.Bytes, labels},
|
||||
{u.USW.NumSta, prometheus.GaugeValue, s.NumSta, labels},
|
||||
{u.USW.UserNumSta, prometheus.GaugeValue, s.UserNumSta, labels},
|
||||
{u.USW.GuestNumSta, prometheus.GaugeValue, s.GuestNumSta, labels},
|
||||
{u.USW.Loadavg1, prometheus.GaugeValue, s.SysStats.Loadavg1, labels},
|
||||
{u.USW.Loadavg5, prometheus.GaugeValue, s.SysStats.Loadavg5, labels},
|
||||
{u.USW.Loadavg15, prometheus.GaugeValue, s.SysStats.Loadavg15, labels},
|
||||
{u.USW.MemUsed, prometheus.GaugeValue, s.SysStats.MemUsed, labels},
|
||||
{u.USW.MemTotal, prometheus.GaugeValue, s.SysStats.MemTotal, labels},
|
||||
{u.USW.MemBuffer, prometheus.GaugeValue, s.SysStats.MemBuffer, labels},
|
||||
{u.USW.CPU, prometheus.GaugeValue, s.SystemStats.CPU, labels},
|
||||
{u.USW.Mem, prometheus.GaugeValue, s.SystemStats.Mem, labels},
|
||||
{u.USW.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
||||
{u.USW.TotalMaxPower, prometheus.GaugeValue, d.TotalMaxPower, labels},
|
||||
{u.USW.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
||||
{u.USW.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
||||
{u.USW.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
||||
{u.USW.NumSta, prometheus.GaugeValue, d.NumSta, labels},
|
||||
{u.USW.UserNumSta, prometheus.GaugeValue, d.UserNumSta, labels},
|
||||
{u.USW.GuestNumSta, prometheus.GaugeValue, d.GuestNumSta, labels},
|
||||
{u.USW.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
||||
{u.USW.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
||||
{u.USW.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
||||
{u.USW.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
||||
{u.USW.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
||||
{u.USW.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
||||
{u.USW.CPU, prometheus.GaugeValue, d.SystemStats.CPU, labels},
|
||||
{u.USW.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels},
|
||||
})
|
||||
u.exportPortTable(r, s.PortTable, labels[4:])
|
||||
u.exportUSWstats(r, s.Stat.Sw, labels)
|
||||
u.exportPortTable(r, d.PortTable, labels[4:])
|
||||
u.exportUSWstats(r, d.Stat.Sw, labels)
|
||||
}
|
||||
|
||||
func (u *unifiCollector) exportUSWstats(r *Report, s *unifi.Sw, labels []string) {
|
||||
func (u *unifiCollector) exportUSWstats(r *Report, sw *unifi.Sw, labels []string) {
|
||||
r.send([]*metricExports{
|
||||
{u.USW.SwRxPackets, prometheus.CounterValue, s.RxPackets, labels},
|
||||
{u.USW.SwRxBytes, prometheus.CounterValue, s.RxBytes, labels},
|
||||
{u.USW.SwRxErrors, prometheus.CounterValue, s.RxErrors, labels},
|
||||
{u.USW.SwRxDropped, prometheus.CounterValue, s.RxDropped, labels},
|
||||
{u.USW.SwRxCrypts, prometheus.CounterValue, s.RxCrypts, labels},
|
||||
{u.USW.SwRxFrags, prometheus.CounterValue, s.RxFrags, labels},
|
||||
{u.USW.SwTxPackets, prometheus.CounterValue, s.TxPackets, labels},
|
||||
{u.USW.SwTxBytes, prometheus.CounterValue, s.TxBytes, labels},
|
||||
{u.USW.SwTxErrors, prometheus.CounterValue, s.TxErrors, labels},
|
||||
{u.USW.SwTxDropped, prometheus.CounterValue, s.TxDropped, labels},
|
||||
{u.USW.SwTxRetries, prometheus.CounterValue, s.TxRetries, labels},
|
||||
{u.USW.SwRxMulticast, prometheus.CounterValue, s.RxMulticast, labels},
|
||||
{u.USW.SwRxBroadcast, prometheus.CounterValue, s.RxBroadcast, labels},
|
||||
{u.USW.SwTxMulticast, prometheus.CounterValue, s.TxMulticast, labels},
|
||||
{u.USW.SwTxBroadcast, prometheus.CounterValue, s.TxBroadcast, labels},
|
||||
{u.USW.SwBytes, prometheus.CounterValue, s.Bytes, labels},
|
||||
{u.USW.SwRxPackets, prometheus.CounterValue, sw.RxPackets, labels},
|
||||
{u.USW.SwRxBytes, prometheus.CounterValue, sw.RxBytes, labels},
|
||||
{u.USW.SwRxErrors, prometheus.CounterValue, sw.RxErrors, labels},
|
||||
{u.USW.SwRxDropped, prometheus.CounterValue, sw.RxDropped, labels},
|
||||
{u.USW.SwRxCrypts, prometheus.CounterValue, sw.RxCrypts, labels},
|
||||
{u.USW.SwRxFrags, prometheus.CounterValue, sw.RxFrags, labels},
|
||||
{u.USW.SwTxPackets, prometheus.CounterValue, sw.TxPackets, labels},
|
||||
{u.USW.SwTxBytes, prometheus.CounterValue, sw.TxBytes, labels},
|
||||
{u.USW.SwTxErrors, prometheus.CounterValue, sw.TxErrors, labels},
|
||||
{u.USW.SwTxDropped, prometheus.CounterValue, sw.TxDropped, labels},
|
||||
{u.USW.SwTxRetries, prometheus.CounterValue, sw.TxRetries, labels},
|
||||
{u.USW.SwRxMulticast, prometheus.CounterValue, sw.RxMulticast, labels},
|
||||
{u.USW.SwRxBroadcast, prometheus.CounterValue, sw.RxBroadcast, labels},
|
||||
{u.USW.SwTxMulticast, prometheus.CounterValue, sw.TxMulticast, labels},
|
||||
{u.USW.SwTxBroadcast, prometheus.CounterValue, sw.TxBroadcast, labels},
|
||||
{u.USW.SwBytes, prometheus.CounterValue, sw.Bytes, labels},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue