Merge pull request #151 from davidnewhall/dn2_merge
Metrics Cleanup and Consolidation
This commit is contained in:
commit
0157ed9196
|
|
@ -101,7 +101,10 @@ func (u *UnifiPoller) AugmentMetrics(metrics *metrics.Metrics) {
|
||||||
for _, r := range metrics.USWs {
|
for _, r := range metrics.USWs {
|
||||||
devices[r.Mac] = r.Name
|
devices[r.Mac] = r.Name
|
||||||
}
|
}
|
||||||
for _, r := range metrics.UDMs {
|
for i, r := range metrics.UDMs {
|
||||||
|
if r.Model == "UDMPRO" {
|
||||||
|
metrics.UDMs[i].Type = "udmp"
|
||||||
|
}
|
||||||
devices[r.Mac] = r.Name
|
devices[r.Mac] = r.Name
|
||||||
}
|
}
|
||||||
// These come blank, so set them here.
|
// These come blank, so set them here.
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,7 @@ type uap struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func descUAP(ns string) *uap {
|
func descUAP(ns string) *uap {
|
||||||
// labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
|
labelA := []string{"stat", "site_name", "name"} // stat + labels[1:]
|
||||||
labelA := []string{"stat", "site_name", "name"} // stat + labels[6:]
|
|
||||||
labelV := []string{"vap_name", "bssid", "radio", "radio_name", "essid", "usage", "site_name", "name"}
|
labelV := []string{"vap_name", "bssid", "radio", "radio_name", "essid", "usage", "site_name", "name"}
|
||||||
labelR := []string{"radio_name", "radio", "site_name", "name"}
|
labelR := []string{"radio_name", "radio", "site_name", "name"}
|
||||||
return &uap{
|
return &uap{
|
||||||
|
|
@ -160,10 +159,12 @@ func descUAP(ns string) *uap {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *promUnifi) exportUAP(r report, d *unifi.UAP) {
|
func (u *promUnifi) exportUAP(r report, d *unifi.UAP) {
|
||||||
labels := []string{d.IP, d.Version, d.Model, d.Serial, d.Type, d.Mac, d.SiteName, d.Name}
|
labels := []string{d.Type, d.SiteName, d.Name}
|
||||||
|
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt}
|
||||||
|
|
||||||
// Wireless System Data.
|
// Wireless System Data.
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
{u.Device.Info, prometheus.GaugeValue, d.Uptime, append(labels, infoLabels...)},
|
||||||
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
||||||
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
||||||
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
||||||
|
|
@ -171,16 +172,16 @@ func (u *promUnifi) exportUAP(r report, d *unifi.UAP) {
|
||||||
{u.Device.TxBytesD, prometheus.CounterValue, d.TxBytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
{u.Device.TxBytesD, prometheus.CounterValue, d.TxBytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
||||||
{u.Device.RxBytesD, prometheus.CounterValue, d.RxBytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
{u.Device.RxBytesD, prometheus.CounterValue, d.RxBytesD, labels}, // not sure if these 3 Ds are counters or gauges.
|
||||||
{u.Device.BytesR, prometheus.GaugeValue, d.BytesR, labels},
|
{u.Device.BytesR, prometheus.GaugeValue, d.BytesR, labels},
|
||||||
{u.Device.NumSta, prometheus.GaugeValue, d.UserNumSta, append(labels, "user")},
|
{u.Device.Counter, prometheus.GaugeValue, d.UserNumSta, append(labels, "user")},
|
||||||
{u.Device.NumSta, prometheus.GaugeValue, d.GuestNumSta, append(labels, "guest")},
|
{u.Device.Counter, prometheus.GaugeValue, d.GuestNumSta, append(labels, "guest")},
|
||||||
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
||||||
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
||||||
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
||||||
{u.Device.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
{u.Device.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
||||||
{u.Device.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
{u.Device.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
||||||
{u.Device.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
{u.Device.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
||||||
{u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU, labels},
|
{u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU.Val / 100.0, labels},
|
||||||
{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels},
|
{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem.Val / 100.0, labels},
|
||||||
})
|
})
|
||||||
|
|
||||||
u.exportUAPstats(r, labels, d.Stat.Ap)
|
u.exportUAPstats(r, labels, d.Stat.Ap)
|
||||||
|
|
@ -190,8 +191,8 @@ func (u *promUnifi) exportUAP(r report, d *unifi.UAP) {
|
||||||
|
|
||||||
func (u *promUnifi) exportUAPstats(r report, labels []string, ap *unifi.Ap) {
|
func (u *promUnifi) exportUAPstats(r report, labels []string, ap *unifi.Ap) {
|
||||||
// labelA := append([]string{"all"}, labels[2:]...)
|
// labelA := append([]string{"all"}, labels[2:]...)
|
||||||
labelU := append([]string{"user"}, labels[6:]...)
|
labelU := []string{"user", labels[1], labels[2]}
|
||||||
labelG := append([]string{"guest"}, labels[6:]...)
|
labelG := []string{"guest", labels[1], labels[2]}
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
/* // all
|
/* // all
|
||||||
{u.UAP.ApWifiTxDropped, prometheus.CounterValue, ap.WifiTxDropped, labelA},
|
{u.UAP.ApWifiTxDropped, prometheus.CounterValue, ap.WifiTxDropped, labelA},
|
||||||
|
|
@ -248,7 +249,7 @@ func (u *promUnifi) exportVAPtable(r report, labels []string, vt unifi.VapTable)
|
||||||
if !v.Up.Val {
|
if !v.Up.Val {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
labelV := append([]string{v.Name, v.Bssid, v.Radio, v.RadioName, v.Essid, v.Usage}, labels[6:]...)
|
labelV := []string{v.Name, v.Bssid, v.Radio, v.RadioName, v.Essid, v.Usage, labels[1], labels[2]}
|
||||||
|
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
{u.UAP.VAPCcq, prometheus.GaugeValue, float64(v.Ccq) / 1000.0, labelV},
|
{u.UAP.VAPCcq, prometheus.GaugeValue, float64(v.Ccq) / 1000.0, labelV},
|
||||||
|
|
@ -295,7 +296,7 @@ func (u *promUnifi) exportVAPtable(r report, labels []string, vt unifi.VapTable)
|
||||||
func (u *promUnifi) exportRadtable(r report, labels []string, rt unifi.RadioTable, rts unifi.RadioTableStats) {
|
func (u *promUnifi) exportRadtable(r report, labels []string, rt unifi.RadioTable, rts unifi.RadioTableStats) {
|
||||||
// radio table
|
// radio table
|
||||||
for _, p := range rt {
|
for _, p := range rt {
|
||||||
labelR := append([]string{p.Name, p.Radio}, labels[6:]...)
|
labelR := []string{p.Name, p.Radio, labels[1], labels[2]}
|
||||||
labelRUser := append(labelR, "user")
|
labelRUser := append(labelR, "user")
|
||||||
labelRGuest := append(labelR, "guest")
|
labelRGuest := append(labelR, "guest")
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
// These are shared by all four device types: UDM, UAP, USG, USW
|
// These are shared by all four device types: UDM, UAP, USG, USW
|
||||||
type unifiDevice struct {
|
type unifiDevice struct {
|
||||||
Uptime *prometheus.Desc
|
Info *prometheus.Desc // uptime
|
||||||
Temperature *prometheus.Desc // sw only
|
Temperature *prometheus.Desc // sw only
|
||||||
TotalMaxPower *prometheus.Desc // sw only
|
TotalMaxPower *prometheus.Desc // sw only
|
||||||
FanLevel *prometheus.Desc // sw only
|
FanLevel *prometheus.Desc // sw only
|
||||||
|
|
@ -19,7 +19,7 @@ type unifiDevice struct {
|
||||||
Bytes *prometheus.Desc // ap only
|
Bytes *prometheus.Desc // ap only
|
||||||
TxBytesD *prometheus.Desc // ap only
|
TxBytesD *prometheus.Desc // ap only
|
||||||
RxBytesD *prometheus.Desc // ap only
|
RxBytesD *prometheus.Desc // ap only
|
||||||
NumSta *prometheus.Desc
|
Counter *prometheus.Desc
|
||||||
NumDesktop *prometheus.Desc // gw only
|
NumDesktop *prometheus.Desc // gw only
|
||||||
NumMobile *prometheus.Desc // gw only
|
NumMobile *prometheus.Desc // gw only
|
||||||
NumHandheld *prometheus.Desc // gw only
|
NumHandheld *prometheus.Desc // gw only
|
||||||
|
|
@ -34,9 +34,10 @@ type unifiDevice struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func descDevice(ns string) *unifiDevice {
|
func descDevice(ns string) *unifiDevice {
|
||||||
labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
|
labels := []string{"type", "site_name", "name"}
|
||||||
|
infoLabels := []string{"version", "model", "serial", "mac", "ip", "id", "bytes"}
|
||||||
return &unifiDevice{
|
return &unifiDevice{
|
||||||
Uptime: prometheus.NewDesc(ns+"uptime", "Uptime", labels, nil),
|
Info: prometheus.NewDesc(ns+"info", "Device Information", append(labels, infoLabels...), nil),
|
||||||
Temperature: prometheus.NewDesc(ns+"temperature_celsius", "Temperature", labels, nil),
|
Temperature: prometheus.NewDesc(ns+"temperature_celsius", "Temperature", labels, nil),
|
||||||
TotalMaxPower: prometheus.NewDesc(ns+"max_power_total", "Total Max Power", labels, nil),
|
TotalMaxPower: prometheus.NewDesc(ns+"max_power_total", "Total Max Power", labels, nil),
|
||||||
FanLevel: prometheus.NewDesc(ns+"fan_level", "Fan Level", labels, nil),
|
FanLevel: prometheus.NewDesc(ns+"fan_level", "Fan Level", labels, nil),
|
||||||
|
|
@ -48,10 +49,7 @@ func descDevice(ns string) *unifiDevice {
|
||||||
Bytes: prometheus.NewDesc(ns+"transferred_bytes_total", "Bytes Transferred", labels, nil),
|
Bytes: prometheus.NewDesc(ns+"transferred_bytes_total", "Bytes Transferred", labels, nil),
|
||||||
TxBytesD: prometheus.NewDesc(ns+"d_tranmsit_bytes", "Transmit Bytes D???", labels, nil),
|
TxBytesD: prometheus.NewDesc(ns+"d_tranmsit_bytes", "Transmit Bytes D???", labels, nil),
|
||||||
RxBytesD: prometheus.NewDesc(ns+"d_receive_bytes", "Receive Bytes D???", labels, nil),
|
RxBytesD: prometheus.NewDesc(ns+"d_receive_bytes", "Receive Bytes D???", labels, nil),
|
||||||
NumSta: prometheus.NewDesc(ns+"stations", "Number of Stations", append(labels, "station_type"), nil),
|
Counter: prometheus.NewDesc(ns+"stations", "Number of Stations", append(labels, "station_type"), nil),
|
||||||
NumDesktop: prometheus.NewDesc(ns+"desktops", "Number of Desktops", labels, nil),
|
|
||||||
NumMobile: prometheus.NewDesc(ns+"mobile", "Number of Mobiles", labels, nil),
|
|
||||||
NumHandheld: prometheus.NewDesc(ns+"handheld", "Number of Handhelds", labels, nil),
|
|
||||||
Loadavg1: prometheus.NewDesc(ns+"load_average_1", "System Load Average 1 Minute", labels, nil),
|
Loadavg1: prometheus.NewDesc(ns+"load_average_1", "System Load Average 1 Minute", labels, nil),
|
||||||
Loadavg5: prometheus.NewDesc(ns+"load_average_5", "System Load Average 5 Minutes", labels, nil),
|
Loadavg5: prometheus.NewDesc(ns+"load_average_5", "System Load Average 5 Minutes", labels, nil),
|
||||||
Loadavg15: prometheus.NewDesc(ns+"load_average_15", "System Load Average 15 Minutes", labels, nil),
|
Loadavg15: prometheus.NewDesc(ns+"load_average_15", "System Load Average 15 Minutes", labels, nil),
|
||||||
|
|
@ -65,20 +63,19 @@ func descDevice(ns string) *unifiDevice {
|
||||||
|
|
||||||
// UDM is a collection of stats from USG, USW and UAP. It has no unique stats.
|
// UDM is a collection of stats from USG, USW and UAP. It has no unique stats.
|
||||||
func (u *promUnifi) exportUDM(r report, d *unifi.UDM) {
|
func (u *promUnifi) exportUDM(r report, d *unifi.UDM) {
|
||||||
labels := []string{d.IP, d.Version, d.Model, d.Serial, d.Type, d.Mac, d.SiteName, d.Name}
|
labels := []string{d.Type, d.SiteName, d.Name}
|
||||||
labelsGuest := append(labels, "guest")
|
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt}
|
||||||
labelsUser := append(labels, "user")
|
|
||||||
// Dream Machine System Data.
|
// Dream Machine System Data.
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
{u.Device.Info, prometheus.GaugeValue, d.Uptime, append(labels, infoLabels...)},
|
||||||
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
||||||
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
||||||
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
||||||
{u.Device.NumSta, prometheus.GaugeValue, d.UserNumSta, labelsUser},
|
{u.Device.Counter, prometheus.GaugeValue, d.UserNumSta, append(labels, "user")},
|
||||||
{u.Device.NumSta, prometheus.GaugeValue, d.GuestNumSta, labelsGuest},
|
{u.Device.Counter, prometheus.GaugeValue, d.GuestNumSta, append(labels, "guest")},
|
||||||
{u.Device.NumDesktop, prometheus.GaugeValue, d.NumDesktop, labels},
|
{u.Device.Counter, prometheus.GaugeValue, d.NumDesktop, append(labels, "desktop")},
|
||||||
{u.Device.NumMobile, prometheus.GaugeValue, d.NumMobile, labels},
|
{u.Device.Counter, prometheus.GaugeValue, d.NumMobile, append(labels, "mobile")},
|
||||||
{u.Device.NumHandheld, prometheus.GaugeValue, d.NumHandheld, labels},
|
{u.Device.Counter, prometheus.GaugeValue, d.NumHandheld, append(labels, "handheld")},
|
||||||
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
||||||
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
||||||
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ type usg struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func descUSG(ns string) *usg {
|
func descUSG(ns string) *usg {
|
||||||
// labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
|
|
||||||
// labelWan := append([]string{"port"}, labels[6:]...)
|
|
||||||
labels := []string{"port", "site_name", "name"}
|
labels := []string{"port", "site_name", "name"}
|
||||||
return &usg{
|
return &usg{
|
||||||
WanRxPackets: prometheus.NewDesc(ns+"wan_receive_packets_total", "WAN Receive Packets Total", labels, nil),
|
WanRxPackets: prometheus.NewDesc(ns+"wan_receive_packets_total", "WAN Receive Packets Total", labels, nil),
|
||||||
|
|
@ -71,36 +69,35 @@ func descUSG(ns string) *usg {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *promUnifi) exportUSG(r report, d *unifi.USG) {
|
func (u *promUnifi) exportUSG(r report, d *unifi.USG) {
|
||||||
labels := []string{d.IP, d.Version, d.Model, d.Serial, d.Type, d.Mac, d.SiteName, d.Name}
|
labels := []string{d.Type, d.SiteName, d.Name}
|
||||||
labelsUser := append(labels, "user")
|
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt}
|
||||||
labelsGuest := append(labels, "guest")
|
|
||||||
// Gateway System Data.
|
// Gateway System Data.
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
{u.Device.Info, prometheus.GaugeValue, d.Uptime, append(labels, infoLabels...)},
|
||||||
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
||||||
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
||||||
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
||||||
{u.Device.NumSta, prometheus.GaugeValue, d.UserNumSta, labelsUser},
|
{u.Device.Counter, prometheus.GaugeValue, d.UserNumSta, append(labels, "user")},
|
||||||
{u.Device.NumSta, prometheus.GaugeValue, d.GuestNumSta, labelsGuest},
|
{u.Device.Counter, prometheus.GaugeValue, d.GuestNumSta, append(labels, "guest")},
|
||||||
{u.Device.NumDesktop, prometheus.GaugeValue, d.NumDesktop, labels},
|
{u.Device.Counter, prometheus.GaugeValue, d.NumDesktop, append(labels, "desktop")},
|
||||||
{u.Device.NumMobile, prometheus.GaugeValue, d.NumMobile, labels},
|
{u.Device.Counter, prometheus.GaugeValue, d.NumMobile, append(labels, "mobile")},
|
||||||
{u.Device.NumHandheld, prometheus.GaugeValue, d.NumHandheld, labels},
|
{u.Device.Counter, prometheus.GaugeValue, d.NumHandheld, append(labels, "handheld")},
|
||||||
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
||||||
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
||||||
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
||||||
{u.Device.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
{u.Device.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
||||||
{u.Device.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
{u.Device.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
||||||
{u.Device.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
{u.Device.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
||||||
{u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU, labels},
|
{u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU.Val / 100.0, labels},
|
||||||
{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels},
|
{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem.Val / 100.0, labels},
|
||||||
})
|
})
|
||||||
u.exportWANPorts(r, labels, d.Wan1, d.Wan2)
|
u.exportWANPorts(r, labels, d.Wan1, d.Wan2)
|
||||||
u.exportUSGstats(r, labels, d.Stat.Gw, d.SpeedtestStatus, d.Uplink)
|
u.exportUSGstats(r, labels, d.Stat.Gw, d.SpeedtestStatus, d.Uplink)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *promUnifi) exportUSGstats(r report, labels []string, gw *unifi.Gw, st unifi.SpeedtestStatus, ul unifi.Uplink) {
|
func (u *promUnifi) exportUSGstats(r report, labels []string, gw *unifi.Gw, st unifi.SpeedtestStatus, ul unifi.Uplink) {
|
||||||
labelLan := []string{"lan", labels[6], labels[7]}
|
labelLan := []string{"lan", labels[1], labels[2]}
|
||||||
labelWan := []string{"all", labels[6], labels[7]}
|
labelWan := []string{"all", labels[1], labels[2]}
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
/* // Combined Port Stats - not really needed. sum() the others instead.
|
/* // Combined Port Stats - not really needed. sum() the others instead.
|
||||||
{u.USG.WanRxPackets, prometheus.CounterValue, gw.WanRxPackets, labelWan},
|
{u.USG.WanRxPackets, prometheus.CounterValue, gw.WanRxPackets, labelWan},
|
||||||
|
|
@ -130,7 +127,7 @@ func (u *promUnifi) exportWANPorts(r report, labels []string, wans ...unifi.Wan)
|
||||||
if !wan.Up.Val {
|
if !wan.Up.Val {
|
||||||
continue // only record UP interfaces.
|
continue // only record UP interfaces.
|
||||||
}
|
}
|
||||||
labelWan := []string{wan.Name, labels[6], labels[7]}
|
labelWan := []string{wan.Name, labels[1], labels[2]}
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
{u.USG.WanRxPackets, prometheus.CounterValue, wan.RxPackets, labelWan},
|
{u.USG.WanRxPackets, prometheus.CounterValue, wan.RxPackets, labelWan},
|
||||||
{u.USG.WanRxBytes, prometheus.CounterValue, wan.RxBytes, labelWan},
|
{u.USG.WanRxBytes, prometheus.CounterValue, wan.RxBytes, labelWan},
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,7 @@ type usw struct {
|
||||||
|
|
||||||
func descUSW(ns string) *usw {
|
func descUSW(ns string) *usw {
|
||||||
pns := ns + "port_"
|
pns := ns + "port_"
|
||||||
// labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
|
labelS := []string{"site_name", "name"}
|
||||||
labelS := []string{"site_name", "name"} // labels[6:]
|
|
||||||
labelP := []string{"port_id", "port_num", "port_name", "port_mac", "port_ip", "site_name", "name"}
|
labelP := []string{"port_id", "port_num", "port_name", "port_mac", "port_ip", "site_name", "name"}
|
||||||
return &usw{
|
return &usw{
|
||||||
SwRxPackets: prometheus.NewDesc(ns+"switch_receive_packets_total", "Switch Packets Received Total", labelS, nil),
|
SwRxPackets: prometheus.NewDesc(ns+"switch_receive_packets_total", "Switch Packets Received Total", labelS, nil),
|
||||||
|
|
@ -91,7 +90,8 @@ func descUSW(ns string) *usw {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *promUnifi) exportUSW(r report, d *unifi.USW) {
|
func (u *promUnifi) exportUSW(r report, d *unifi.USW) {
|
||||||
labels := []string{d.IP, d.Version, d.Model, d.Serial, d.Type, d.Mac, d.SiteName, d.Name}
|
labels := []string{d.Type, d.SiteName, d.Name}
|
||||||
|
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt}
|
||||||
labelsGuest := append(labels, "guest")
|
labelsGuest := append(labels, "guest")
|
||||||
labelsUser := append(labels, "user")
|
labelsUser := append(labels, "user")
|
||||||
if d.HasTemperature.Val {
|
if d.HasTemperature.Val {
|
||||||
|
|
@ -103,28 +103,28 @@ func (u *promUnifi) exportUSW(r report, d *unifi.USW) {
|
||||||
|
|
||||||
// Switch System Data.
|
// Switch System Data.
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
{u.Device.Info, prometheus.GaugeValue, d.Uptime, append(labels, infoLabels...)},
|
||||||
{u.Device.TotalMaxPower, prometheus.GaugeValue, d.TotalMaxPower, labels},
|
{u.Device.TotalMaxPower, prometheus.GaugeValue, d.TotalMaxPower, labels},
|
||||||
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
|
||||||
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
|
||||||
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
|
||||||
{u.Device.NumSta, prometheus.GaugeValue, d.UserNumSta, labelsUser},
|
{u.Device.Counter, prometheus.GaugeValue, d.UserNumSta, labelsUser},
|
||||||
{u.Device.NumSta, prometheus.GaugeValue, d.GuestNumSta, labelsGuest},
|
{u.Device.Counter, prometheus.GaugeValue, d.GuestNumSta, labelsGuest},
|
||||||
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
|
||||||
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
|
||||||
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
|
||||||
{u.Device.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
{u.Device.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels},
|
||||||
{u.Device.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
{u.Device.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels},
|
||||||
{u.Device.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
{u.Device.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels},
|
||||||
{u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU, labels},
|
{u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU.Val / 100.0, labels},
|
||||||
{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels},
|
{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem.Val / 100.0, labels},
|
||||||
})
|
})
|
||||||
u.exportPortTable(r, labels, d.PortTable)
|
u.exportPortTable(r, labels, d.PortTable)
|
||||||
u.exportUSWstats(r, labels, d.Stat.Sw)
|
u.exportUSWstats(r, labels, d.Stat.Sw)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *promUnifi) exportUSWstats(r report, labels []string, sw *unifi.Sw) {
|
func (u *promUnifi) exportUSWstats(r report, labels []string, sw *unifi.Sw) {
|
||||||
labelS := labels[6:]
|
labelS := labels[1:]
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
{u.USW.SwRxPackets, prometheus.CounterValue, sw.RxPackets, labelS},
|
{u.USW.SwRxPackets, prometheus.CounterValue, sw.RxPackets, labelS},
|
||||||
{u.USW.SwRxBytes, prometheus.CounterValue, sw.RxBytes, labelS},
|
{u.USW.SwRxBytes, prometheus.CounterValue, sw.RxBytes, labelS},
|
||||||
|
|
@ -152,7 +152,7 @@ func (u *promUnifi) exportPortTable(r report, labels []string, pt []unifi.Port)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Copy labels, and add four new ones.
|
// Copy labels, and add four new ones.
|
||||||
labelP := []string{labels[7] + " Port " + p.PortIdx.Txt, p.PortIdx.Txt, p.Name, p.Mac, p.IP, labels[6], labels[7]}
|
labelP := []string{labels[2] + " Port " + p.PortIdx.Txt, p.PortIdx.Txt, p.Name, p.Mac, p.IP, labels[1], labels[2]}
|
||||||
if p.PoeEnable.Val && p.PortPoe.Val {
|
if p.PoeEnable.Val && p.PortPoe.Val {
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
{u.USW.PoeCurrent, prometheus.GaugeValue, p.PoeCurrent, labelP},
|
{u.USW.PoeCurrent, prometheus.GaugeValue, p.PoeCurrent, labelP},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue