fixes
This commit is contained in:
parent
21de375c80
commit
bf74687f42
|
|
@ -80,8 +80,8 @@ type uap struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func descUAP(ns string) *uap {
|
func descUAP(ns string) *uap {
|
||||||
// labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
|
// labels := []string{"type", "site_name", "name"}
|
||||||
labelA := []string{"stat", "site_name", "name"} // stat + labels[6:]
|
labelA := []string{"stat", "site_name", "name"} // stat + labels[1:]
|
||||||
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,9 +160,11 @@ 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}
|
||||||
// Wireless System Data.
|
// Wireless System Data.
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
|
{u.Device.Info, prometheus.GaugeValue, d.Uptime, append(labels, infoLabels...)},
|
||||||
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, 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},
|
||||||
|
|
@ -190,8 +192,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 +250,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 +297,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,6 +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 {
|
||||||
|
Info *prometheus.Desc
|
||||||
Uptime *prometheus.Desc
|
Uptime *prometheus.Desc
|
||||||
Temperature *prometheus.Desc // sw only
|
Temperature *prometheus.Desc // sw only
|
||||||
TotalMaxPower *prometheus.Desc // sw only
|
TotalMaxPower *prometheus.Desc // sw only
|
||||||
|
|
@ -34,8 +35,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"}
|
||||||
return &unifiDevice{
|
return &unifiDevice{
|
||||||
|
Info: prometheus.NewDesc(ns+"info", "Device Information", append(labels, infoLabels...), nil),
|
||||||
Uptime: prometheus.NewDesc(ns+"uptime", "Uptime", labels, nil),
|
Uptime: prometheus.NewDesc(ns+"uptime", "Uptime", labels, 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),
|
||||||
|
|
@ -65,11 +68,13 @@ 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}
|
||||||
|
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac}
|
||||||
labelsGuest := append(labels, "guest")
|
labelsGuest := append(labels, "guest")
|
||||||
labelsUser := append(labels, "user")
|
labelsUser := append(labels, "user")
|
||||||
// Dream Machine System Data.
|
// Dream Machine System Data.
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
|
{u.Device.Info, prometheus.GaugeValue, d.Uptime, append(labels, infoLabels...)},
|
||||||
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, 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},
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ type usg struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func descUSG(ns string) *usg {
|
func descUSG(ns string) *usg {
|
||||||
// labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
|
// labels := []string{"version", "model", "serial", "type", "mac", "site_name", "name"}
|
||||||
// labelWan := append([]string{"port"}, labels[6:]...)
|
// labelWan := append([]string{"port"}, labels[6:]...)
|
||||||
labels := []string{"port", "site_name", "name"}
|
labels := []string{"port", "site_name", "name"}
|
||||||
return &usg{
|
return &usg{
|
||||||
|
|
@ -71,11 +71,13 @@ 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}
|
||||||
|
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac}
|
||||||
labelsUser := append(labels, "user")
|
labelsUser := append(labels, "user")
|
||||||
labelsGuest := append(labels, "guest")
|
labelsGuest := append(labels, "guest")
|
||||||
// Gateway System Data.
|
// Gateway System Data.
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
|
{u.Device.Info, prometheus.GaugeValue, d.Uptime, append(labels, infoLabels...)},
|
||||||
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, 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},
|
||||||
|
|
@ -99,8 +101,8 @@ func (u *promUnifi) exportUSG(r report, d *unifi.USG) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +132,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,8 @@ 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{"type", "site_name", "name"}
|
||||||
labelS := []string{"site_name", "name"} // labels[6:]
|
labelS := []string{"site_name", "name"} // labels[1:]
|
||||||
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 +91,9 @@ 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}
|
||||||
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,6 +105,7 @@ func (u *promUnifi) exportUSW(r report, d *unifi.USW) {
|
||||||
|
|
||||||
// Switch System Data.
|
// Switch System Data.
|
||||||
r.send([]*metric{
|
r.send([]*metric{
|
||||||
|
{u.Device.Info, prometheus.GaugeValue, d.Uptime, append(labels, infoLabels...)},
|
||||||
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
|
||||||
{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},
|
||||||
|
|
@ -124,7 +127,7 @@ func (u *promUnifi) exportUSW(r report, d *unifi.USW) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +155,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