Merge pull request #147 from davidnewhall/superq/duplicate_metrics

Cleanup duplicate station metrics
This commit is contained in:
David Newhall II 2019-12-02 20:45:10 -08:00 committed by GitHub
commit a2ebdac926
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 25 deletions

View File

@ -74,9 +74,7 @@ type uap struct {
RadioCuSelfTx *prometheus.Desc
RadioExtchannel *prometheus.Desc
RadioGain *prometheus.Desc
RadioGuestNumSta *prometheus.Desc
RadioNumSta *prometheus.Desc
RadioUserNumSta *prometheus.Desc
RadioTxPackets *prometheus.Desc
RadioTxRetries *prometheus.Desc
}
@ -155,9 +153,7 @@ func descUAP(ns string) *uap {
RadioCuSelfTx: prometheus.NewDesc(ns+"radio_channel_utilization_transmit_ratio", "Radio Channel Utilization Transmit", labelR, nil),
RadioExtchannel: prometheus.NewDesc(ns+"radio_ext_channel", "Radio Ext Channel", labelR, nil),
RadioGain: prometheus.NewDesc(ns+"radio_gain", "Radio Gain", labelR, nil),
RadioGuestNumSta: prometheus.NewDesc(ns+"radio_guest_stations", "Radio Guest Station Count", labelR, nil),
RadioNumSta: prometheus.NewDesc(ns+"radio_stations", "Radio Total Station Count", labelR, nil),
RadioUserNumSta: prometheus.NewDesc(ns+"radio_user_stations", "Radio User Station Count", labelR, nil),
RadioNumSta: prometheus.NewDesc(ns+"radio_stations", "Radio Total Station Count", append(labelR, "station_type"), nil),
RadioTxPackets: prometheus.NewDesc(ns+"radio_transmit_packets", "Radio Transmitted Packets", labelR, nil),
RadioTxRetries: prometheus.NewDesc(ns+"radio_transmit_retries", "Radio Transmit Retries", labelR, nil),
}
@ -175,9 +171,8 @@ 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.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.NumSta, prometheus.GaugeValue, d.NumSta, labels},
{u.Device.UserNumSta, prometheus.GaugeValue, d.UserNumSta, labels},
{u.Device.GuestNumSta, prometheus.GaugeValue, d.GuestNumSta, labels},
{u.Device.NumSta, prometheus.GaugeValue, d.UserNumSta, append(labels, "user")},
{u.Device.NumSta, prometheus.GaugeValue, d.GuestNumSta, append(labels, "guest")},
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},
@ -301,6 +296,8 @@ func (u *promUnifi) exportRadtable(r report, labels []string, rt unifi.RadioTabl
// radio table
for _, p := range rt {
labelR := append([]string{p.Name, p.Radio}, labels[6:]...)
labelRUser := append(labelR, "user")
labelRGuest := append(labelR, "guest")
r.send([]*metric{
{u.UAP.RadioCurrentAntennaGain, prometheus.GaugeValue, p.CurrentAntennaGain, labelR},
{u.UAP.RadioHt, prometheus.GaugeValue, p.Ht, labelR},
@ -323,9 +320,8 @@ func (u *promUnifi) exportRadtable(r report, labels []string, rt unifi.RadioTabl
{u.UAP.RadioCuSelfTx, prometheus.GaugeValue, t.CuSelfTx.Val / 100.0, labelR},
{u.UAP.RadioExtchannel, prometheus.GaugeValue, t.Extchannel, labelR},
{u.UAP.RadioGain, prometheus.GaugeValue, t.Gain, labelR},
{u.UAP.RadioGuestNumSta, prometheus.GaugeValue, t.GuestNumSta, labelR},
{u.UAP.RadioNumSta, prometheus.GaugeValue, t.NumSta, labelR},
{u.UAP.RadioUserNumSta, prometheus.GaugeValue, t.UserNumSta, labelR},
{u.UAP.RadioNumSta, prometheus.GaugeValue, t.GuestNumSta, labelRGuest},
{u.UAP.RadioNumSta, prometheus.GaugeValue, t.UserNumSta, labelRUser},
{u.UAP.RadioTxPackets, prometheus.GaugeValue, t.TxPackets, labelR},
{u.UAP.RadioTxRetries, prometheus.GaugeValue, t.TxRetries, labelR},
})

View File

@ -20,8 +20,6 @@ type unifiDevice struct {
TxBytesD *prometheus.Desc // ap only
RxBytesD *prometheus.Desc // ap only
NumSta *prometheus.Desc
UserNumSta *prometheus.Desc
GuestNumSta *prometheus.Desc
NumDesktop *prometheus.Desc // gw only
NumMobile *prometheus.Desc // gw only
NumHandheld *prometheus.Desc // gw only
@ -50,9 +48,7 @@ func descDevice(ns string) *unifiDevice {
Bytes: prometheus.NewDesc(ns+"transferred_bytes_total", "Bytes Transferred", 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),
NumSta: prometheus.NewDesc(ns+"stations", "Number of Stations", labels, nil),
UserNumSta: prometheus.NewDesc(ns+"user_stations", "Number of User Stations", labels, nil),
GuestNumSta: prometheus.NewDesc(ns+"guest_stations", "Number of Guest Stations", labels, nil),
NumSta: 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),
@ -70,15 +66,16 @@ func descDevice(ns string) *unifiDevice {
// 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) {
labels := []string{d.IP, d.Version, d.Model, d.Serial, d.Type, d.Mac, d.SiteName, d.Name}
labelsGuest := append(labels, "guest")
labelsUser := append(labels, "user")
// Dream Machine System Data.
r.send([]*metric{
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
{u.Device.NumSta, prometheus.GaugeValue, d.NumSta, labels},
{u.Device.UserNumSta, prometheus.GaugeValue, d.UserNumSta, labels},
{u.Device.GuestNumSta, prometheus.GaugeValue, d.GuestNumSta, labels},
{u.Device.NumSta, prometheus.GaugeValue, d.UserNumSta, labelsUser},
{u.Device.NumSta, prometheus.GaugeValue, d.GuestNumSta, labelsGuest},
{u.Device.NumDesktop, prometheus.GaugeValue, d.NumDesktop, labels},
{u.Device.NumMobile, prometheus.GaugeValue, d.NumMobile, labels},
{u.Device.NumHandheld, prometheus.GaugeValue, d.NumHandheld, labels},

View File

@ -72,15 +72,16 @@ func descUSG(ns string) *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}
labelsUser := append(labels, "user")
labelsGuest := append(labels, "guest")
// Gateway System Data.
r.send([]*metric{
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
{u.Device.NumSta, prometheus.GaugeValue, d.NumSta, labels},
{u.Device.UserNumSta, prometheus.GaugeValue, d.UserNumSta, labels},
{u.Device.GuestNumSta, prometheus.GaugeValue, d.GuestNumSta, labels},
{u.Device.NumSta, prometheus.GaugeValue, d.UserNumSta, labelsUser},
{u.Device.NumSta, prometheus.GaugeValue, d.GuestNumSta, labelsGuest},
{u.Device.NumDesktop, prometheus.GaugeValue, d.NumDesktop, labels},
{u.Device.NumMobile, prometheus.GaugeValue, d.NumMobile, labels},
{u.Device.NumHandheld, prometheus.GaugeValue, d.NumHandheld, labels},

View File

@ -92,6 +92,8 @@ func descUSW(ns string) *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}
labelsGuest := append(labels, "guest")
labelsUser := append(labels, "user")
if d.HasTemperature.Val {
r.send([]*metric{{u.Device.Temperature, prometheus.GaugeValue, d.GeneralTemperature, labels}})
}
@ -106,9 +108,8 @@ func (u *promUnifi) exportUSW(r report, d *unifi.USW) {
{u.Device.TotalTxBytes, prometheus.CounterValue, d.TxBytes, labels},
{u.Device.TotalRxBytes, prometheus.CounterValue, d.RxBytes, labels},
{u.Device.TotalBytes, prometheus.CounterValue, d.Bytes, labels},
{u.Device.NumSta, prometheus.GaugeValue, d.NumSta, labels},
{u.Device.UserNumSta, prometheus.GaugeValue, d.UserNumSta, labels},
{u.Device.GuestNumSta, prometheus.GaugeValue, d.GuestNumSta, labels},
{u.Device.NumSta, prometheus.GaugeValue, d.UserNumSta, labelsUser},
{u.Device.NumSta, prometheus.GaugeValue, d.GuestNumSta, labelsGuest},
{u.Device.Loadavg1, prometheus.GaugeValue, d.SysStats.Loadavg1, labels},
{u.Device.Loadavg5, prometheus.GaugeValue, d.SysStats.Loadavg5, labels},
{u.Device.Loadavg15, prometheus.GaugeValue, d.SysStats.Loadavg15, labels},