Suck more data out of UAPs.
This commit is contained in:
parent
ecc40eb778
commit
648af5dad2
|
|
@ -8,7 +8,8 @@ import (
|
|||
)
|
||||
|
||||
// Points generates a device's datapoints for InfluxDB.
|
||||
func (u UAP) Points() (points []*influx.Point, err error) {
|
||||
func (u UAP) Points() ([]*influx.Point, error) {
|
||||
var points []*influx.Point
|
||||
tags := map[string]string{
|
||||
"id": u.ID,
|
||||
"mac": u.Mac,
|
||||
|
|
@ -35,7 +36,7 @@ func (u UAP) Points() (points []*influx.Point, err error) {
|
|||
"has_speaker": strconv.FormatBool(u.HasSpeaker),
|
||||
"inform_ip": u.InformIP,
|
||||
"isolated": strconv.FormatBool(u.Isolated),
|
||||
"last_seen": strconv.Itoa(u.LastSeen),
|
||||
"last_seen": strconv.FormatFloat(u.LastSeen, 'f', 6, 64),
|
||||
"last_uplink_mac": u.LastUplink.UplinkMac,
|
||||
"last_uplink_remote_port": strconv.Itoa(u.LastUplink.UplinkRemotePort),
|
||||
"known_cfgversion": u.KnownCfgversion,
|
||||
|
|
@ -165,6 +166,98 @@ func (u UAP) Points() (points []*influx.Point, err error) {
|
|||
"stat_wifi1-tx_packets": u.Stat.Wifi1TxPackets,
|
||||
"stat_wifi1-tx_retries": u.Stat.Wifi1TxRetries,
|
||||
}
|
||||
points[0], err = influx.NewPoint("uap", tags, fields, time.Now())
|
||||
return
|
||||
pt, err := influx.NewPoint("uap", tags, fields, time.Now())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
points = append(points, pt)
|
||||
for _, p := range u.RadioTable {
|
||||
tags := map[string]string{
|
||||
"device_name": u.Name,
|
||||
"device_id": u.ID,
|
||||
"device_mac": u.Mac,
|
||||
"name": p.Name,
|
||||
"wlangroup_id": p.WlangroupID,
|
||||
"channel": p.Channel, // not the channel #
|
||||
"radio": p.Radio,
|
||||
}
|
||||
fields := map[string]interface{}{
|
||||
"builtin_ant_gain": p.BuiltinAntGain,
|
||||
"current_antenna_gain": p.CurrentAntennaGain,
|
||||
"has_dfs": p.HasDfs,
|
||||
"has_fccdfs": p.HasFccdfs,
|
||||
"ht": p.Ht,
|
||||
"is_11ac": p.Is11Ac,
|
||||
"max_txpower": p.MaxTxpower,
|
||||
"min_rssi_enabled": p.MinRssiEnabled,
|
||||
"min_txpower": p.MinTxpower,
|
||||
"nss": p.Nss,
|
||||
"radio_caps": p.RadioCaps,
|
||||
"tx_power": p.TxPower,
|
||||
"tx_power_mode": p.TxPowerMode,
|
||||
}
|
||||
|
||||
for _, s := range u.RadioTableStats {
|
||||
// This may be a tad slower but it allows putting
|
||||
// all the radio stats into one table.
|
||||
if p.Name == s.Name {
|
||||
fields["ast_be_xmit"] = s.AstBeXmit
|
||||
fields["ast_cst"] = s.AstCst
|
||||
fields["channel"] = s.Channel
|
||||
fields["ast_txto"] = s.AstTxto
|
||||
fields["cu_self_rx"] = s.CuSelfRx
|
||||
fields["cu_self_tx"] = s.CuSelfTx
|
||||
fields["cu_total"] = s.CuTotal
|
||||
fields["extchannel"] = s.Extchannel
|
||||
fields["gain"] = s.Gain
|
||||
fields["guest-num_sta"] = s.GuestNumSta
|
||||
fields["num_sta"] = s.NumSta
|
||||
fields["radio"] = s.Radio
|
||||
fields["state"] = s.State
|
||||
fields["radio_tx_packets"] = s.TxPackets
|
||||
fields["radio_tx_power"] = s.TxPower
|
||||
fields["radio_tx_retries"] = s.TxRetries
|
||||
fields["user-num_sta"] = s.UserNumSta
|
||||
}
|
||||
}
|
||||
for _, s := range u.VapTable {
|
||||
if p.Name == s.RadioName {
|
||||
tags["ap_mac"] = s.ApMac
|
||||
tags["bssid"] = s.Bssid
|
||||
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["usage"] = s.Usage
|
||||
tags["wlanconf_id"] = s.WlanconfID
|
||||
}
|
||||
}
|
||||
pt, err := influx.NewPoint("uap_radios", tags, fields, time.Now())
|
||||
if err != nil {
|
||||
return points, err
|
||||
}
|
||||
points = append(points, pt)
|
||||
}
|
||||
return points, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,17 +36,17 @@ type UAP struct {
|
|||
Name string `json:"name"`
|
||||
NumPort float64 `json:"num_port"`
|
||||
} `json:"ethernet_table"`
|
||||
FwCaps int `json:"fw_caps"`
|
||||
GuestNumSta int `json:"guest-num_sta"`
|
||||
GuestToken string `json:"guest_token"`
|
||||
HasEth1 bool `json:"has_eth1"`
|
||||
HasSpeaker bool `json:"has_speaker"`
|
||||
InformIP string `json:"inform_ip"`
|
||||
InformURL string `json:"inform_url"`
|
||||
IP string `json:"ip"`
|
||||
Isolated bool `json:"isolated"`
|
||||
KnownCfgversion string `json:"known_cfgversion"`
|
||||
LastSeen int `json:"last_seen"`
|
||||
FwCaps int `json:"fw_caps"`
|
||||
GuestNumSta int `json:"guest-num_sta"`
|
||||
GuestToken string `json:"guest_token"`
|
||||
HasEth1 bool `json:"has_eth1"`
|
||||
HasSpeaker bool `json:"has_speaker"`
|
||||
InformIP string `json:"inform_ip"`
|
||||
InformURL string `json:"inform_url"`
|
||||
IP string `json:"ip"`
|
||||
Isolated bool `json:"isolated"`
|
||||
KnownCfgversion string `json:"known_cfgversion"`
|
||||
LastSeen float64 `json:"last_seen"`
|
||||
LastUplink struct {
|
||||
UplinkMac string `json:"uplink_mac"`
|
||||
UplinkRemotePort int `json:"uplink_remote_port"`
|
||||
|
|
@ -132,28 +132,28 @@ type UAP struct {
|
|||
Is11Ac bool `json:"is_11ac,omitempty"`
|
||||
} `json:"radio_table"`
|
||||
RadioTableStats []struct {
|
||||
AstBeXmit interface{} `json:"ast_be_xmit"`
|
||||
AstCst interface{} `json:"ast_cst"`
|
||||
AstTxto interface{} `json:"ast_txto"`
|
||||
Channel float64 `json:"channel"`
|
||||
CuSelfRx float64 `json:"cu_self_rx"`
|
||||
CuSelfTx float64 `json:"cu_self_tx"`
|
||||
CuTotal float64 `json:"cu_total"`
|
||||
Extchannel float64 `json:"extchannel"`
|
||||
Gain float64 `json:"gain"`
|
||||
GuestNumSta float64 `json:"guest-num_sta"`
|
||||
Name string `json:"name"`
|
||||
NumSta float64 `json:"num_sta"`
|
||||
Radio string `json:"radio"`
|
||||
State string `json:"state"`
|
||||
TxPackets float64 `json:"tx_packets"`
|
||||
TxPower float64 `json:"tx_power"`
|
||||
TxRetries float64 `json:"tx_retries"`
|
||||
UserNumSta float64 `json:"user-num_sta"`
|
||||
AstBeXmit float64 `json:"ast_be_xmit"`
|
||||
AstCst float64 `json:"ast_cst"`
|
||||
AstTxto float64 `json:"ast_txto"`
|
||||
Channel float64 `json:"channel"`
|
||||
CuSelfRx float64 `json:"cu_self_rx"`
|
||||
CuSelfTx float64 `json:"cu_self_tx"`
|
||||
CuTotal float64 `json:"cu_total"`
|
||||
Extchannel float64 `json:"extchannel"`
|
||||
Gain float64 `json:"gain"`
|
||||
GuestNumSta float64 `json:"guest-num_sta"`
|
||||
Name string `json:"name"`
|
||||
NumSta float64 `json:"num_sta"`
|
||||
Radio string `json:"radio"`
|
||||
State string `json:"state"`
|
||||
TxPackets float64 `json:"tx_packets"`
|
||||
TxPower float64 `json:"tx_power"`
|
||||
TxRetries float64 `json:"tx_retries"`
|
||||
UserNumSta float64 `json:"user-num_sta"`
|
||||
} `json:"radio_table_stats"`
|
||||
Rollupgrade bool `json:"rollupgrade"`
|
||||
RxBytes int `json:"rx_bytes"`
|
||||
RxBytesD int `json:"rx_bytes-d"`
|
||||
RxBytes float64 `json:"rx_bytes"`
|
||||
RxBytesD float64 `json:"rx_bytes-d"`
|
||||
ScanRadioTable []interface{} `json:"scan_radio_table"`
|
||||
Scanning bool `json:"scanning"`
|
||||
Serial string `json:"serial"`
|
||||
|
|
@ -257,12 +257,12 @@ type UAP struct {
|
|||
} `json:"stat"`
|
||||
State int `json:"state"`
|
||||
SysStats struct {
|
||||
Loadavg1 string `json:"loadavg_1"`
|
||||
Loadavg15 string `json:"loadavg_15"`
|
||||
Loadavg5 string `json:"loadavg_5"`
|
||||
MemBuffer int `json:"mem_buffer"`
|
||||
MemTotal int `json:"mem_total"`
|
||||
MemUsed int `json:"mem_used"`
|
||||
Loadavg1 string `json:"loadavg_1"`
|
||||
Loadavg15 string `json:"loadavg_15"`
|
||||
Loadavg5 string `json:"loadavg_5"`
|
||||
MemBuffer float64 `json:"mem_buffer"`
|
||||
MemTotal float64 `json:"mem_total"`
|
||||
MemUsed float64 `json:"mem_used"`
|
||||
} `json:"sys_stats"`
|
||||
SystemStats struct {
|
||||
CPU string `json:"cpu"`
|
||||
|
|
@ -270,7 +270,7 @@ type UAP struct {
|
|||
Uptime string `json:"uptime"`
|
||||
} `json:"system-stats"`
|
||||
TxBytes float64 `json:"tx_bytes"`
|
||||
TxBytesD int `json:"tx_bytes-d"`
|
||||
TxBytesD float64 `json:"tx_bytes-d"`
|
||||
Type string `json:"type"`
|
||||
Upgradable bool `json:"upgradable"`
|
||||
Uplink struct {
|
||||
|
|
@ -284,63 +284,63 @@ type UAP struct {
|
|||
Netmask string `json:"netmask"`
|
||||
NumPort int `json:"num_port"`
|
||||
RxBytes float64 `json:"rx_bytes"`
|
||||
RxBytesR int `json:"rx_bytes-r"`
|
||||
RxDropped int `json:"rx_dropped"`
|
||||
RxErrors int `json:"rx_errors"`
|
||||
RxMulticast int `json:"rx_multicast"`
|
||||
RxPackets int `json:"rx_packets"`
|
||||
Speed int `json:"speed"`
|
||||
RxBytesR float64 `json:"rx_bytes-r"`
|
||||
RxDropped float64 `json:"rx_dropped"`
|
||||
RxErrors float64 `json:"rx_errors"`
|
||||
RxMulticast float64 `json:"rx_multicast"`
|
||||
RxPackets float64 `json:"rx_packets"`
|
||||
Speed float64 `json:"speed"`
|
||||
TxBytes float64 `json:"tx_bytes"`
|
||||
TxBytesR int `json:"tx_bytes-r"`
|
||||
TxDropped int `json:"tx_dropped"`
|
||||
TxErrors int `json:"tx_errors"`
|
||||
TxPackets int `json:"tx_packets"`
|
||||
TxBytesR float64 `json:"tx_bytes-r"`
|
||||
TxDropped float64 `json:"tx_dropped"`
|
||||
TxErrors float64 `json:"tx_errors"`
|
||||
TxPackets float64 `json:"tx_packets"`
|
||||
Type string `json:"type"`
|
||||
Up bool `json:"up"`
|
||||
UplinkMac string `json:"uplink_mac"`
|
||||
UplinkRemotePort int `json:"uplink_remote_port"`
|
||||
} `json:"uplink"`
|
||||
UplinkTable []interface{} `json:"uplink_table"`
|
||||
Uptime int `json:"uptime"`
|
||||
Uptime float64 `json:"uptime"`
|
||||
UserNumSta int `json:"user-num_sta"`
|
||||
VapTable []struct {
|
||||
ApMac string `json:"ap_mac"`
|
||||
Bssid string `json:"bssid"`
|
||||
Ccq int `json:"ccq"`
|
||||
Channel int `json:"channel"`
|
||||
Essid string `json:"essid"`
|
||||
Extchannel int `json:"extchannel"`
|
||||
ID string `json:"id"`
|
||||
IsGuest bool `json:"is_guest"`
|
||||
IsWep bool `json:"is_wep"`
|
||||
MacFilterRejections int `json:"mac_filter_rejections"`
|
||||
MapID interface{} `json:"map_id"`
|
||||
Name string `json:"name"`
|
||||
NumSta int `json:"num_sta"`
|
||||
Radio string `json:"radio"`
|
||||
RadioName string `json:"radio_name"`
|
||||
RxBytes int `json:"rx_bytes"`
|
||||
RxCrypts int `json:"rx_crypts"`
|
||||
RxDropped int `json:"rx_dropped"`
|
||||
RxErrors int `json:"rx_errors"`
|
||||
RxFrags int `json:"rx_frags"`
|
||||
RxNwids int `json:"rx_nwids"`
|
||||
RxPackets int `json:"rx_packets"`
|
||||
SiteID string `json:"site_id"`
|
||||
State string `json:"state"`
|
||||
T string `json:"t"`
|
||||
TxBytes int `json:"tx_bytes"`
|
||||
TxDropped int `json:"tx_dropped"`
|
||||
TxErrors int `json:"tx_errors"`
|
||||
TxLatencyAvg float64 `json:"tx_latency_avg"`
|
||||
TxLatencyMax float64 `json:"tx_latency_max"`
|
||||
TxLatencyMin float64 `json:"tx_latency_min"`
|
||||
TxPackets int `json:"tx_packets"`
|
||||
TxPower int `json:"tx_power"`
|
||||
TxRetries int `json:"tx_retries"`
|
||||
Up bool `json:"up"`
|
||||
Usage string `json:"usage"`
|
||||
WlanconfID string `json:"wlanconf_id"`
|
||||
ApMac string `json:"ap_mac"`
|
||||
Bssid string `json:"bssid"`
|
||||
Ccq int `json:"ccq"`
|
||||
Channel int `json:"channel"`
|
||||
Essid string `json:"essid"`
|
||||
Extchannel int `json:"extchannel"`
|
||||
ID string `json:"id"`
|
||||
IsGuest bool `json:"is_guest"`
|
||||
IsWep bool `json:"is_wep"`
|
||||
MacFilterRejections int `json:"mac_filter_rejections"`
|
||||
MapID string `json:"map_id"`
|
||||
Name string `json:"name"`
|
||||
NumSta int `json:"num_sta"`
|
||||
Radio string `json:"radio"`
|
||||
RadioName string `json:"radio_name"`
|
||||
RxBytes float64 `json:"rx_bytes"`
|
||||
RxCrypts float64 `json:"rx_crypts"`
|
||||
RxDropped float64 `json:"rx_dropped"`
|
||||
RxErrors float64 `json:"rx_errors"`
|
||||
RxFrags float64 `json:"rx_frags"`
|
||||
RxNwids float64 `json:"rx_nwids"`
|
||||
RxPackets float64 `json:"rx_packets"`
|
||||
SiteID string `json:"site_id"`
|
||||
State string `json:"state"`
|
||||
T string `json:"t"`
|
||||
TxBytes float64 `json:"tx_bytes"`
|
||||
TxDropped float64 `json:"tx_dropped"`
|
||||
TxErrors float64 `json:"tx_errors"`
|
||||
TxLatencyAvg float64 `json:"tx_latency_avg"`
|
||||
TxLatencyMax float64 `json:"tx_latency_max"`
|
||||
TxLatencyMin float64 `json:"tx_latency_min"`
|
||||
TxPackets float64 `json:"tx_packets"`
|
||||
TxPower int `json:"tx_power"`
|
||||
TxRetries int `json:"tx_retries"`
|
||||
Up bool `json:"up"`
|
||||
Usage string `json:"usage"`
|
||||
WlanconfID string `json:"wlanconf_id"`
|
||||
} `json:"vap_table"`
|
||||
Version string `json:"version"`
|
||||
VersionIncompatible bool `json:"version_incompatible"`
|
||||
|
|
|
|||
Loading…
Reference in New Issue