From cf879d8377d0d62f02cceffef33b099ba24e768c Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 14 Apr 2019 20:34:21 -0700 Subject: [PATCH 1/2] Fix bugs in uap collection. --- core/unifi/uap.go | 42 +++++++++++++++++++++--------------------- core/unifi/unidev.go | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/core/unifi/uap.go b/core/unifi/uap.go index 81039f6e..dec42a5f 100644 --- a/core/unifi/uap.go +++ b/core/unifi/uap.go @@ -222,41 +222,41 @@ func (u UAP) Points() ([]*influx.Point, error) { fields["radio_tx_power"] = s.TxPower fields["radio_tx_retries"] = s.TxRetries fields["user-num_sta"] = s.UserNumSta - continue + break } } for _, s := range u.VapTable { if p.Name == s.RadioName { tags["ap_mac"] = s.ApMac tags["bssid"] = s.Bssid + tags["vap_id"] = s.ID + tags["vap_name"] = s.Name + tags["wlanconf_id"] = s.WlanconfID fields["ccq"] = s.Ccq fields["essid"] = s.Essid fields["extchannel"] = s.Extchannel - tags["vap_id"] = s.ID fields["is_guest"] = s.IsGuest fields["is_wep"] = s.IsWep fields["mac_filter_rejections"] = s.MacFilterRejections fields["map_id"] = s.MapID - tags["vap_name"] = s.Name - fields["rx_bytes"] = s.RxBytes - fields["rx_crypts"] = s.RxCrypts - fields["rx_dropped"] = s.RxDropped - fields["rx_errors"] = s.RxErrors - fields["rx_frags"] = s.RxFrags - fields["rx_nwids"] = s.RxNwids - fields["rx_packets"] = s.RxPackets - fields["tx_bytes"] = s.TxBytes - fields["tx_dropped"] = s.TxDropped - fields["tx_errors"] = s.TxErrors - fields["tx_latency_avg"] = s.TxLatencyAvg - fields["tx_latency_max"] = s.TxLatencyMax - fields["tx_latency_min"] = s.TxLatencyMin - fields["tx_packets"] = s.TxPackets - fields["tx_power"] = s.TxPower - fields["tx_retries"] = s.TxRetries + fields["vap_rx_bytes"] = s.RxBytes + fields["vap_rx_crypts"] = s.RxCrypts + fields["vap_rx_dropped"] = s.RxDropped + fields["vap_rx_errors"] = s.RxErrors + fields["vap_rx_frags"] = s.RxFrags + fields["vap_rx_nwids"] = s.RxNwids + fields["vap_rx_packets"] = s.RxPackets + fields["vap_tx_bytes"] = s.TxBytes + fields["vap_tx_dropped"] = s.TxDropped + fields["vap_tx_errors"] = s.TxErrors + fields["vap_tx_latency_avg"] = s.TxLatencyAvg + fields["vap_tx_latency_max"] = s.TxLatencyMax + fields["vap_tx_latency_min"] = s.TxLatencyMin + fields["vap_tx_packets"] = s.TxPackets + fields["vap_tx_power"] = s.TxPower + fields["vap_tx_retries"] = s.TxRetries fields["usage"] = s.Usage - tags["wlanconf_id"] = s.WlanconfID - continue + break } } pt, err := influx.NewPoint("uap_radios", tags, fields, time.Now()) diff --git a/core/unifi/unidev.go b/core/unifi/unidev.go index cd5d6db4..48d37271 100644 --- a/core/unifi/unidev.go +++ b/core/unifi/unidev.go @@ -82,7 +82,7 @@ type FlexBool struct { String string } -// UnmarshalJSO method converts armed/disarmed, yes/no, active/inactive or 0/1 to true/false. +// UnmarshalJSON method converts armed/disarmed, yes/no, active/inactive or 0/1 to true/false. // Really it converts ready, up, t, armed, yes, active, enabled, 1, true to true. Anything else is false. func (f *FlexBool) UnmarshalJSON(b []byte) error { f.String = strings.Trim(string(b), `"`) From 3a91d5ab65dba8dd5d9c31eaefbb8f96966960fa Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 14 Apr 2019 20:39:44 -0700 Subject: [PATCH 2/2] Convert all tx_powers to floats. --- core/unifi/uap.go | 4 ++-- core/unifi/uap_type.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/unifi/uap.go b/core/unifi/uap.go index dec42a5f..edd1fc54 100644 --- a/core/unifi/uap.go +++ b/core/unifi/uap.go @@ -219,7 +219,7 @@ func (u UAP) Points() ([]*influx.Point, error) { fields["radio"] = s.Radio fields["state"] = s.State fields["radio_tx_packets"] = s.TxPackets - fields["radio_tx_power"] = s.TxPower + fields["radio_tx_power"] = s.TxPower.Number fields["radio_tx_retries"] = s.TxRetries fields["user-num_sta"] = s.UserNumSta break @@ -253,7 +253,7 @@ func (u UAP) Points() ([]*influx.Point, error) { fields["vap_tx_latency_max"] = s.TxLatencyMax fields["vap_tx_latency_min"] = s.TxLatencyMin fields["vap_tx_packets"] = s.TxPackets - fields["vap_tx_power"] = s.TxPower + fields["vap_tx_power"] = s.TxPower.Number fields["vap_tx_retries"] = s.TxRetries fields["usage"] = s.Usage break diff --git a/core/unifi/uap_type.go b/core/unifi/uap_type.go index 2d61b324..cf930920 100644 --- a/core/unifi/uap_type.go +++ b/core/unifi/uap_type.go @@ -152,7 +152,7 @@ type UAP struct { Radio string `json:"radio"` State string `json:"state"` TxPackets float64 `json:"tx_packets"` - TxPower float64 `json:"tx_power"` + TxPower FlexInt `json:"tx_power"` TxRetries float64 `json:"tx_retries"` UserNumSta float64 `json:"user-num_sta"` } `json:"radio_table_stats"` @@ -341,7 +341,7 @@ type UAP struct { TxLatencyMax float64 `json:"tx_latency_max"` TxLatencyMin float64 `json:"tx_latency_min"` TxPackets float64 `json:"tx_packets"` - TxPower int `json:"tx_power"` + TxPower FlexInt `json:"tx_power"` TxRetries int `json:"tx_retries"` Up bool `json:"up"` Usage string `json:"usage"`