Add usg port_table data.

This commit is contained in:
David Newhall II 2019-07-05 01:58:06 -07:00
parent 46683f841d
commit 2f16177afc
4 changed files with 316 additions and 296 deletions

View File

@ -176,7 +176,6 @@ type UAP struct {
UplinkRemotePort int `json:"uplink_remote_port"`
} `json:"uplink"`
VapTable []struct {
SiteName string `json:"-"`
AnomaliesBarChart struct {
HighTCPLatency FlexInt `json:"high_tcp_latency"`
HighTCPPacketLoss FlexInt `json:"high_tcp_packet_loss"`

View File

@ -105,15 +105,9 @@ func (u *Unifi) GetDevices(sites []Site) (*Devices, error) {
// Add SiteName to each device asset.
for i := range loopDevices.UAPs {
loopDevices.UAPs[i].SiteName = site.Desc + " (" + site.Name + ")"
for j := range loopDevices.UAPs[i].VapTable {
loopDevices.UAPs[i].VapTable[j].SiteName = site.Desc + " (" + site.Name + ")"
}
}
for i := range loopDevices.USGs {
loopDevices.USGs[i].SiteName = site.Desc + " (" + site.Name + ")"
for j := range loopDevices.USGs[i].NetworkTable {
loopDevices.USGs[i].NetworkTable[j].SiteName = site.Desc + " (" + site.Name + ")"
}
}
for i := range loopDevices.USWs {
loopDevices.USWs[i].SiteName = site.Desc + " (" + site.Name + ")"

View File

@ -1,7 +1,7 @@
package unifi
import (
"strconv"
"strings"
"time"
influx "github.com/influxdata/influxdb1-client/v2"
@ -10,6 +10,7 @@ import (
// Points generates Unifi Gateway datapoints for InfluxDB.
// These points can be passed directly to influx.
func (u USG) Points() ([]*influx.Point, error) {
now := time.Now()
tags := map[string]string{
"id": u.ID,
"mac": u.Mac,
@ -19,16 +20,12 @@ func (u USG) Points() ([]*influx.Point, error) {
"site_name": u.SiteName,
"adopted": u.Adopted.Txt,
"name": u.Name,
"adopt_ip": u.AdoptIP,
"adopt_url": u.AdoptURL,
"cfgversion": u.Cfgversion,
"config_network_ip": u.ConfigNetwork.IP,
"config_network_type": u.ConfigNetwork.Type,
"connect_request_ip": u.ConnectRequestIP,
"connect_request_port": u.ConnectRequestPort,
"default": u.Default.Txt,
"device_id": u.DeviceID,
"discovered_via": u.DiscoveredVia,
"guest_token": u.GuestToken,
"inform_ip": u.InformIP,
"known_cfgversion": u.KnownCfgversion,
@ -38,42 +35,39 @@ func (u USG) Points() ([]*influx.Point, error) {
"outdoor_mode_override": u.OutdoorModeOverride,
"serial": u.Serial,
"type": u.Type,
"version_incompatible": u.VersionIncompatible.Txt,
"usg_caps": strconv.FormatFloat(u.UsgCaps, 'f', 6, 64),
"usg_caps": u.UsgCaps.Txt,
"speedtest-status-saved": u.SpeedtestStatusSaved.Txt,
"wan1_up": u.Wan1.Up.Txt,
"wan2_up": u.Wan2.Up.Txt,
}
fields := map[string]interface{}{
"ip": u.IP,
"bytes": u.Bytes,
"last_seen": u.LastSeen,
"bytes": u.Bytes.Val,
"last_seen": u.LastSeen.Val,
"license_state": u.LicenseState,
"fw_caps": u.FwCaps,
"guest-num_sta": u.GuestNumSta,
"fw_caps": u.FwCaps.Val,
"guest-num_sta": u.GuestNumSta.Val,
"rx_bytes": u.RxBytes.Val,
"tx_bytes": u.TxBytes.Val,
"uptime": u.Uptime,
"considered_lost_at": u.ConsideredLostAt,
"next_heartbeat_at": u.NextHeartbeatAt,
"uptime": u.Uptime.Val,
"roll_upgrade": u.Rollupgrade.Val,
"state": u.State,
"state": u.State.Val,
"upgradable": u.Upgradable.Val,
"user-num_sta": u.UserNumSta,
"user-num_sta": u.UserNumSta.Val,
"version": u.Version,
"num_desktop": u.NumDesktop,
"num_handheld": u.NumHandheld,
"num_mobile": u.NumMobile,
"speedtest-status_latency": u.SpeedtestStatus.Latency,
"speedtest-status_rundate": u.SpeedtestStatus.Rundate,
"speedtest-status_runtime": u.SpeedtestStatus.Runtime,
"speedtest-status_download": u.SpeedtestStatus.StatusDownload,
"speedtest-status_ping": u.SpeedtestStatus.StatusPing,
"speedtest-status_summary": u.SpeedtestStatus.StatusSummary,
"speedtest-status_upload": u.SpeedtestStatus.StatusUpload,
"speedtest-status_xput_download": u.SpeedtestStatus.XputDownload,
"speedtest-status_xput_upload": u.SpeedtestStatus.XputUpload,
"config_network_wan_type": u.ConfigNetworkWan.Type,
"num_desktop": u.NumDesktop.Val,
"num_handheld": u.NumHandheld.Val,
"num_mobile": u.NumMobile.Val,
"speedtest-status_latency": u.SpeedtestStatus.Latency.Val,
"speedtest-status_rundate": u.SpeedtestStatus.Rundate.Val,
"speedtest-status_runtime": u.SpeedtestStatus.Runtime.Val,
"speedtest-status_download": u.SpeedtestStatus.StatusDownload.Val,
"speedtest-status_ping": u.SpeedtestStatus.StatusPing.Val,
"speedtest-status_summary": u.SpeedtestStatus.StatusSummary.Val,
"speedtest-status_upload": u.SpeedtestStatus.StatusUpload.Val,
"speedtest-status_xput_download": u.SpeedtestStatus.XputDownload.Val,
"speedtest-status_xput_upload": u.SpeedtestStatus.XputUpload.Val,
"config_network_wan_type": u.ConfigNetwork.Type,
"wan1_bytes-r": u.Wan1.BytesR.Val,
"wan1_enable": u.Wan1.Enable.Val,
"wan1_full_duplex": u.Wan1.FullDuplex.Val,
@ -124,35 +118,35 @@ func (u USG) Points() ([]*influx.Point, error) {
"wan2_tx_dropped": u.Wan2.TxDropped.Val,
"wan2_tx_errors": u.Wan2.TxErrors.Val,
"wan2_tx_packets": u.Wan2.TxPackets.Val,
"loadavg_1": u.SysStats.Loadavg1,
"loadavg_5": u.SysStats.Loadavg5,
"loadavg_15": u.SysStats.Loadavg15,
"mem_used": u.SysStats.MemUsed,
"mem_buffer": u.SysStats.MemBuffer,
"mem_total": u.SysStats.MemTotal,
"cpu": u.SystemStats.CPU,
"mem": u.SystemStats.Mem,
"system_uptime": u.SystemStats.Uptime,
"stat_duration": u.Stat.Duration,
"loadavg_1": u.SysStats.Loadavg1.Val,
"loadavg_5": u.SysStats.Loadavg5.Val,
"loadavg_15": u.SysStats.Loadavg15.Val,
"mem_used": u.SysStats.MemUsed.Val,
"mem_buffer": u.SysStats.MemBuffer.Val,
"mem_total": u.SysStats.MemTotal.Val,
"cpu": u.SystemStats.CPU.Val,
"mem": u.SystemStats.Mem.Val,
"system_uptime": u.SystemStats.Uptime.Val,
"stat_duration": u.Stat.Duration.Val,
"stat_datetime": u.Stat.Datetime,
"gw": u.Stat.Gw,
"false": "false", // to fill holes in graphs.
"lan-rx_bytes": u.Stat.LanRxBytes,
"lan-rx_packets": u.Stat.LanRxPackets,
"lan-tx_bytes": u.Stat.LanTxBytes,
"lan-tx_packets": u.Stat.LanTxPackets,
"wan-rx_bytes": u.Stat.WanRxBytes,
"wan-rx_dropped": u.Stat.WanRxDropped,
"wan-rx_packets": u.Stat.WanRxPackets,
"wan-tx_bytes": u.Stat.WanTxBytes,
"wan-tx_packets": u.Stat.WanTxPackets,
"lan-rx_bytes": u.Stat.LanRxBytes.Val,
"lan-rx_packets": u.Stat.LanRxPackets.Val,
"lan-tx_bytes": u.Stat.LanTxBytes.Val,
"lan-tx_packets": u.Stat.LanTxPackets.Val,
"wan-rx_bytes": u.Stat.WanRxBytes.Val,
"wan-rx_dropped": u.Stat.WanRxDropped.Val,
"wan-rx_packets": u.Stat.WanRxPackets.Val,
"wan-tx_bytes": u.Stat.WanTxBytes.Val,
"wan-tx_packets": u.Stat.WanTxPackets.Val,
"uplink_name": u.Uplink.Name,
"uplink_latency": u.Uplink.Latency,
"uplink_speed": u.Uplink.Speed,
"uplink_num_ports": u.Uplink.NumPort,
"uplink_max_speed": u.Uplink.MaxSpeed,
"uplink_latency": u.Uplink.Latency.Val,
"uplink_speed": u.Uplink.Speed.Val,
"uplink_num_ports": u.Uplink.NumPort.Val,
"uplink_max_speed": u.Uplink.MaxSpeed.Val,
}
pt, err := influx.NewPoint("usg", tags, fields, time.Now())
pt, err := influx.NewPoint("usg", tags, fields, now)
if err != nil {
return nil, err
}
@ -162,6 +156,7 @@ func (u USG) Points() ([]*influx.Point, error) {
"device_name": u.Name,
"device_id": u.ID,
"device_mac": u.Mac,
"site_name": u.SiteName,
"name": p.Name,
"dhcpd_dns_enabled": p.DhcpdDNSEnabled.Txt,
"dhcpd_enabled": p.DhcpdEnabled.Txt,
@ -180,7 +175,6 @@ func (u USG) Points() ([]*influx.Point, error) {
"is_nat": p.IsNat.Txt,
"networkgroup": p.Networkgroup,
"site_id": p.SiteID,
"site_name": p.SiteName,
}
fields := map[string]interface{}{
"dhcpd_ip_1": p.DhcpdIP1,
@ -191,20 +185,54 @@ func (u USG) Points() ([]*influx.Point, error) {
"ip_subnet": p.IPSubnet,
"mac": p.Mac,
"name": p.Name,
"num_sta": p.NumSta,
"num_sta": p.NumSta.Val,
"purpose": p.Purpose,
"rx_bytes": p.RxBytes.Val,
"rx_packets": p.RxPackets,
"rx_packets": p.RxPackets.Val,
"tx_bytes": p.TxBytes.Val,
"tx_packets": p.TxPackets,
"up": p.Up.Txt,
"tx_packets": p.TxPackets.Val,
"vlan": p.Vlan.Txt,
"dhcpd_ntp_1": p.DhcpdNtp1,
"dhcpd_unifi_controller": p.DhcpdUnifiController,
"ipv6_interface_type": p.Ipv6InterfaceType,
"attr_hidden_id": p.AttrHiddenID,
}
pt, err = influx.NewPoint("usg_networks", tags, fields, time.Now())
pt, err = influx.NewPoint("usg_networks", tags, fields, now)
if err != nil {
return points, err
}
points = append(points, pt)
}
for _, p := range u.PortTable {
tags := map[string]string{
"device_name": u.Name,
"device_id": u.ID,
"device_mac": u.Mac,
"site_name": u.SiteName,
"name": p.Name,
"ifname": p.Ifname,
"ip": p.IP,
"netmask": p.Netmask,
"mac": p.Mac,
"up": p.Up.Txt,
"speed": p.Speed.Txt,
"full_duplex": p.FullDuplex.Txt,
"enable": p.Enable.Txt,
"gateway": p.Gateway,
}
fields := map[string]interface{}{
"rx_bytes": p.RxBytes.Val,
"rx_dropped": p.RxDropped.Val,
"rx_errors": p.RxErrors.Val,
"rx_packets": p.RxBytes.Val,
"tx_bytes": p.TxBytes.Val,
"tx_dropped": p.TxDropped.Val,
"tx_errors": p.TxErrors.Val,
"tx_packets": p.TxPackets.Val,
"rx_multicast": p.RxMulticast.Val,
"dns_servers": strings.Join(p.DNS, ","),
}
pt, err = influx.NewPoint("usg_ports", tags, fields, now)
if err != nil {
return points, err
}

View File

@ -1,262 +1,261 @@
package unifi
import "encoding/json"
import "time"
// USG represents all the data from the Ubiquiti Controller for a Unifi Security Gateway.
type USG struct {
ID string `json:"_id"`
UUptime float64 `json:"_uptime"`
AdoptIP string `json:"adopt_ip"`
AdoptURL string `json:"adopt_url"`
Adopted FlexBool `json:"adopted"`
Bytes float64 `json:"bytes"`
Cfgversion string `json:"cfgversion"`
ConfigNetwork struct {
Type string `json:"type"`
IP string `json:"ip"`
Type string `json:"type"`
} `json:"config_network"`
ConfigNetworkWan struct {
Type string `json:"type"`
} `json:"config_network_wan"`
ConnectRequestIP string `json:"connect_request_ip"`
ConnectRequestPort string `json:"connect_request_port"`
ConsideredLostAt float64 `json:"considered_lost_at"`
Default FlexBool `json:"default"`
DeviceID string `json:"device_id"`
DiscoveredVia string `json:"discovered_via"`
EthernetTable []struct {
EthernetTable []struct {
Mac string `json:"mac"`
NumPort FlexInt `json:"num_port"`
Name string `json:"name"`
NumPort float64 `json:"num_port"`
} `json:"ethernet_table"`
FwCaps float64 `json:"fw_caps"`
GuestNumSta float64 `json:"guest-num_sta"`
GuestToken string `json:"guest_token"`
InformIP string `json:"inform_ip"`
InformURL string `json:"inform_url"`
IP string `json:"ip"`
KnownCfgversion string `json:"known_cfgversion"`
LastSeen float64 `json:"last_seen"`
LedOverride string `json:"led_override"`
LicenseState string `json:"license_state"`
Locating FlexBool `json:"locating"`
Mac string `json:"mac"`
Model string `json:"model"`
Name string `json:"name"`
NetworkTable []struct {
ID string `json:"_id"`
DhcpdDNSEnabled FlexBool `json:"dhcpd_dns_enabled"`
DhcpdEnabled FlexBool `json:"dhcpd_enabled"`
DhcpdIP1 string `json:"dhcpd_ip_1,omitempty"`
DhcpdLeasetime json.Number `json:"dhcpd_leasetime,Number"`
DhcpdStart string `json:"dhcpd_start"`
DhcpdStop string `json:"dhcpd_stop"`
DhcpdWinsEnabled FlexBool `json:"dhcpd_wins_enabled,omitempty"`
DhcpguardEnabled FlexBool `json:"dhcpguard_enabled,omitempty"`
DomainName string `json:"domain_name"`
Enabled FlexBool `json:"enabled"`
IgmpSnooping FlexBool `json:"igmp_snooping,omitempty"`
IP string `json:"ip"`
IPSubnet string `json:"ip_subnet"`
IsGuest FlexBool `json:"is_guest"`
IsNat FlexBool `json:"is_nat"`
Mac string `json:"mac"`
Name string `json:"name"`
Networkgroup string `json:"networkgroup"`
NumSta float64 `json:"num_sta"`
Purpose string `json:"purpose"`
RxBytes FlexInt `json:"rx_bytes"`
RxPackets float64 `json:"rx_packets"`
SiteID string `json:"site_id"`
SiteName string `json:"-"`
TxBytes FlexInt `json:"tx_bytes"`
TxPackets float64 `json:"tx_packets"`
Up FlexBool `json:"up"`
Vlan FlexInt `json:"vlan,omitempty"`
VlanEnabled FlexBool `json:"vlan_enabled"`
DhcpRelayEnabled FlexBool `json:"dhcp_relay_enabled,omitempty"`
DhcpdGatewayEnabled FlexBool `json:"dhcpd_gateway_enabled,omitempty"`
DhcpdNtp1 string `json:"dhcpd_ntp_1,omitempty"`
DhcpdNtpEnabled FlexBool `json:"dhcpd_ntp_enabled,omitempty"`
DhcpdTimeOffsetEnabled FlexBool `json:"dhcpd_time_offset_enabled,omitempty"`
DhcpdUnifiController string `json:"dhcpd_unifi_controller,omitempty"`
Ipv6InterfaceType string `json:"ipv6_interface_type,omitempty"`
AttrHiddenID string `json:"attr_hidden_id,omitempty"`
AttrNoDelete FlexBool `json:"attr_no_delete,omitempty"`
UpnpLanEnabled FlexBool `json:"upnp_lan_enabled,omitempty"`
} `json:"network_table"`
NextHeartbeatAt float64 `json:"next_heartbeat_at"`
NumDesktop float64 `json:"num_desktop"`
NumHandheld float64 `json:"num_handheld"`
NumMobile float64 `json:"num_mobile"`
NumSta float64 `json:"num_sta"`
FwCaps FlexInt `json:"fw_caps"`
InformIP string `json:"inform_ip"`
InformURL string `json:"inform_url"`
IP string `json:"ip"`
LedOverride string `json:"led_override"`
LicenseState string `json:"license_state"`
Mac string `json:"mac"`
Model string `json:"model"`
Name string `json:"name"`
OutdoorModeOverride string `json:"outdoor_mode_override"`
PortTable []struct {
DNS []string `json:"dns,omitempty"`
Enable FlexBool `json:"enable"`
FullDuplex FlexBool `json:"full_duplex"`
Gateway string `json:"gateway,omitempty"`
Ifname string `json:"ifname"`
IP string `json:"ip"`
Mac string `json:"mac"`
Name string `json:"name"`
Netmask string `json:"netmask"`
RxBytes FlexInt `json:"rx_bytes"`
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 FlexInt `json:"tx_bytes"`
TxDropped float64 `json:"tx_dropped"`
TxErrors float64 `json:"tx_errors"`
TxPackets float64 `json:"tx_packets"`
Up FlexBool `json:"up"`
} `json:"port_table"`
Rollupgrade FlexBool `json:"rollupgrade"`
RxBytes FlexInt `json:"rx_bytes"`
Serial string `json:"serial"`
SiteID string `json:"site_id"`
SiteName string `json:"-"`
SpeedtestStatus struct {
Latency float64 `json:"latency"`
Rundate float64 `json:"rundate"`
Runtime float64 `json:"runtime"`
StatusDownload float64 `json:"status_download"`
StatusPing float64 `json:"status_ping"`
StatusSummary float64 `json:"status_summary"`
StatusUpload float64 `json:"status_upload"`
XputDownload float64 `json:"xput_download"`
XputUpload float64 `json:"xput_upload"`
} `json:"speedtest-status"`
SpeedtestStatusSaved FlexBool `json:"speedtest-status-saved"`
Stat struct {
Datetime string `json:"datetime"`
Duration float64 `json:"duration"`
Gw string `json:"gw"`
LanRxBytes float64 `json:"lan-rx_bytes"`
LanRxPackets float64 `json:"lan-rx_packets"`
LanTxBytes float64 `json:"lan-tx_bytes"`
LanTxPackets float64 `json:"lan-tx_packets"`
O string `json:"o"`
Oid string `json:"oid"`
SiteID string `json:"site_id"`
Time float64 `json:"time"`
WanRxBytes float64 `json:"wan-rx_bytes"`
WanRxDropped float64 `json:"wan-rx_dropped"`
WanRxPackets float64 `json:"wan-rx_packets"`
WanTxBytes float64 `json:"wan-tx_bytes"`
WanTxPackets float64 `json:"wan-tx_packets"`
} `json:"stat"`
State float64 `json:"state"`
SysStats struct {
Loadavg1 float64 `json:"loadavg_1,string"`
Loadavg15 float64 `json:"loadavg_15,string"`
Loadavg5 float64 `json:"loadavg_5,string"`
MemBuffer float64 `json:"mem_buffer"`
MemTotal float64 `json:"mem_total"`
MemUsed float64 `json:"mem_used"`
Serial string `json:"serial"`
SiteID string `json:"site_id"`
SiteName string `json:"-"`
Type string `json:"type"`
UsgCaps FlexInt `json:"usg_caps"`
Version string `json:"version"`
RequiredVersion string `json:"required_version"`
EthernetOverrides []struct {
Ifname string `json:"ifname"`
Networkgroup string `json:"networkgroup"`
} `json:"ethernet_overrides"`
HwCaps FlexInt `json:"hw_caps"`
BoardRev FlexInt `json:"board_rev"`
Unsupported FlexBool `json:"unsupported"`
UnsupportedReason FlexInt `json:"unsupported_reason"`
DeviceID string `json:"device_id"`
State FlexInt `json:"state"`
LastSeen FlexInt `json:"last_seen"`
Upgradable FlexBool `json:"upgradable"`
AdoptableWhenUpgraded FlexBool `json:"adoptable_when_upgraded"`
Rollupgrade FlexBool `json:"rollupgrade"`
KnownCfgversion string `json:"known_cfgversion"`
Uptime FlexInt `json:"uptime"`
Locating FlexBool `json:"locating"`
ConnectRequestIP string `json:"connect_request_ip"`
ConnectRequestPort string `json:"connect_request_port"`
SysStats struct {
Loadavg1 FlexInt `json:"loadavg_1"`
Loadavg15 FlexInt `json:"loadavg_15"`
Loadavg5 FlexInt `json:"loadavg_5"`
MemBuffer FlexInt `json:"mem_buffer"`
MemTotal FlexInt `json:"mem_total"`
MemUsed FlexInt `json:"mem_used"`
} `json:"sys_stats"`
SystemStats struct {
CPU float64 `json:"cpu,string"`
Mem float64 `json:"mem,string"`
Uptime float64 `json:"uptime,string"`
CPU FlexInt `json:"cpu"`
Mem FlexInt `json:"mem"`
Uptime FlexInt `json:"uptime"`
} `json:"system-stats"`
TxBytes FlexInt `json:"tx_bytes"`
Type string `json:"type"`
Upgradable FlexBool `json:"upgradable"`
Uplink struct {
BytesR float64 `json:"bytes-r"`
Drops float64 `json:"drops"`
GuestToken string `json:"guest_token"`
SpeedtestStatus struct {
Latency FlexInt `json:"latency"`
Rundate FlexInt `json:"rundate"`
Runtime FlexInt `json:"runtime"`
StatusDownload FlexInt `json:"status_download"`
StatusPing FlexInt `json:"status_ping"`
StatusSummary FlexInt `json:"status_summary"`
StatusUpload FlexInt `json:"status_upload"`
XputDownload FlexInt `json:"xput_download"`
XputUpload FlexInt `json:"xput_upload"`
} `json:"speedtest-status"`
SpeedtestStatusSaved FlexBool `json:"speedtest-status-saved"`
Wan1 struct {
TxBytesR FlexInt `json:"tx_bytes-r"`
RxBytesR FlexInt `json:"rx_bytes-r"`
BytesR FlexInt `json:"bytes-r"`
MaxSpeed FlexInt `json:"max_speed"`
Type string `json:"type"`
Name string `json:"name"`
Ifname string `json:"ifname"`
IP string `json:"ip"`
Netmask string `json:"netmask"`
Mac string `json:"mac"`
Up FlexBool `json:"up"`
Speed FlexInt `json:"speed"`
FullDuplex FlexBool `json:"full_duplex"`
RxBytes FlexInt `json:"rx_bytes"`
RxDropped FlexInt `json:"rx_dropped"`
RxErrors FlexInt `json:"rx_errors"`
RxPackets FlexInt `json:"rx_packets"`
TxBytes FlexInt `json:"tx_bytes"`
TxDropped FlexInt `json:"tx_dropped"`
TxErrors FlexInt `json:"tx_errors"`
TxPackets FlexInt `json:"tx_packets"`
RxMulticast FlexInt `json:"rx_multicast"`
Enable FlexBool `json:"enable"`
DNS []string `json:"dns"`
Gateway string `json:"gateway"`
} `json:"wan1"`
Wan2 struct {
TxBytesR FlexInt `json:"tx_bytes-r"`
RxBytesR FlexInt `json:"rx_bytes-r"`
BytesR FlexInt `json:"bytes-r"`
MaxSpeed FlexInt `json:"max_speed"`
Type string `json:"type"`
Name string `json:"name"`
Ifname string `json:"ifname"`
IP string `json:"ip"`
Netmask string `json:"netmask"`
Mac string `json:"mac"`
Up FlexBool `json:"up"`
Speed FlexInt `json:"speed"`
FullDuplex FlexBool `json:"full_duplex"`
RxBytes FlexInt `json:"rx_bytes"`
RxDropped FlexInt `json:"rx_dropped"`
RxErrors FlexInt `json:"rx_errors"`
RxPackets FlexInt `json:"rx_packets"`
TxBytes FlexInt `json:"tx_bytes"`
TxDropped FlexInt `json:"tx_dropped"`
TxErrors FlexInt `json:"tx_errors"`
TxPackets FlexInt `json:"tx_packets"`
RxMulticast FlexInt `json:"rx_multicast"`
Enable FlexBool `json:"enable"`
DNS []string `json:"dns"`
Gateway string `json:"gateway"`
} `json:"wan2"`
PortTable []struct {
Name string `json:"name"`
Ifname string `json:"ifname"`
IP string `json:"ip"`
Netmask string `json:"netmask"`
Mac string `json:"mac"`
Up FlexBool `json:"up"`
Speed FlexInt `json:"speed"`
FullDuplex FlexBool `json:"full_duplex"`
RxBytes FlexInt `json:"rx_bytes"`
RxDropped FlexInt `json:"rx_dropped"`
RxErrors FlexInt `json:"rx_errors"`
RxPackets FlexInt `json:"rx_packets"`
TxBytes FlexInt `json:"tx_bytes"`
TxDropped FlexInt `json:"tx_dropped"`
TxErrors FlexInt `json:"tx_errors"`
TxPackets FlexInt `json:"tx_packets"`
RxMulticast FlexInt `json:"rx_multicast"`
Enable FlexBool `json:"enable"`
DNS []string `json:"dns,omitempty"`
Gateway string `json:"gateway,omitempty"`
} `json:"port_table"`
NetworkTable []struct {
ID string `json:"_id"`
IsNat FlexBool `json:"is_nat"`
DhcpdDNSEnabled FlexBool `json:"dhcpd_dns_enabled"`
Purpose string `json:"purpose"`
DhcpdLeasetime FlexInt `json:"dhcpd_leasetime"`
IgmpSnooping FlexBool `json:"igmp_snooping"`
DhcpguardEnabled FlexBool `json:"dhcpguard_enabled,omitempty"`
DhcpdStart string `json:"dhcpd_start"`
Enabled FlexBool `json:"enabled"`
DhcpdStop string `json:"dhcpd_stop"`
DhcpdWinsEnabled FlexBool `json:"dhcpd_wins_enabled,omitempty"`
DomainName string `json:"domain_name"`
DhcpdEnabled FlexBool `json:"dhcpd_enabled"`
IPSubnet string `json:"ip_subnet"`
Vlan FlexInt `json:"vlan,omitempty"`
Networkgroup string `json:"networkgroup"`
Name string `json:"name"`
SiteID string `json:"site_id"`
DhcpdIP1 string `json:"dhcpd_ip_1,omitempty"`
VlanEnabled FlexBool `json:"vlan_enabled"`
DhcpdGatewayEnabled FlexBool `json:"dhcpd_gateway_enabled"`
DhcpdTimeOffsetEnabled FlexBool `json:"dhcpd_time_offset_enabled"`
Ipv6InterfaceType string `json:"ipv6_interface_type"`
DhcpRelayEnabled FlexBool `json:"dhcp_relay_enabled"`
Mac string `json:"mac"`
IsGuest FlexBool `json:"is_guest"`
IP string `json:"ip"`
Up string `json:"up"`
NumSta FlexInt `json:"num_sta"`
RxBytes FlexInt `json:"rx_bytes"`
RxPackets FlexInt `json:"rx_packets"`
TxBytes FlexInt `json:"tx_bytes"`
TxPackets FlexInt `json:"tx_packets"`
DhcpdNtp1 string `json:"dhcpd_ntp_1,omitempty"`
DhcpdNtpEnabled FlexBool `json:"dhcpd_ntp_enabled,omitempty"`
DhcpdUnifiController string `json:"dhcpd_unifi_controller,omitempty"`
UpnpLanEnabled FlexBool `json:"upnp_lan_enabled,omitempty"`
AttrNoDelete FlexBool `json:"attr_no_delete,omitempty"`
AttrHiddenID string `json:"attr_hidden_id,omitempty"`
} `json:"network_table"`
Uplink struct {
Drops FlexInt `json:"drops"`
Enable FlexBool `json:"enable"`
FullDuplex FlexBool `json:"full_duplex"`
Gateways []string `json:"gateways"`
IP string `json:"ip"`
Latency float64 `json:"latency"`
Latency FlexInt `json:"latency"`
Mac string `json:"mac"`
MaxSpeed float64 `json:"max_speed"`
Name string `json:"name"`
Nameservers []string `json:"nameservers"`
Netmask string `json:"netmask"`
NumPort float64 `json:"num_port"`
NumPort FlexInt `json:"num_port"`
RxBytes FlexInt `json:"rx_bytes"`
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"`
SpeedtestLastrun float64 `json:"speedtest_lastrun"`
SpeedtestPing float64 `json:"speedtest_ping"`
RxDropped FlexInt `json:"rx_dropped"`
RxErrors FlexInt `json:"rx_errors"`
RxMulticast FlexInt `json:"rx_multicast"`
RxPackets FlexInt `json:"rx_packets"`
Speed FlexInt `json:"speed"`
SpeedtestLastrun FlexInt `json:"speedtest_lastrun"`
SpeedtestPing FlexInt `json:"speedtest_ping"`
SpeedtestStatus string `json:"speedtest_status"`
TxBytes FlexInt `json:"tx_bytes"`
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"`
TxDropped FlexInt `json:"tx_dropped"`
TxErrors FlexInt `json:"tx_errors"`
TxPackets FlexInt `json:"tx_packets"`
Up FlexBool `json:"up"`
Uptime float64 `json:"uptime"`
XputDown float64 `json:"xput_down"`
XputUp float64 `json:"xput_up"`
Uptime FlexInt `json:"uptime"`
XputDown FlexInt `json:"xput_down"`
XputUp FlexInt `json:"xput_up"`
TxBytesR FlexInt `json:"tx_bytes-r"`
RxBytesR FlexInt `json:"rx_bytes-r"`
BytesR FlexInt `json:"bytes-r"`
MaxSpeed FlexInt `json:"max_speed"`
Type string `json:"type"`
} `json:"uplink"`
Uptime float64 `json:"uptime"`
UserNumSta float64 `json:"user-num_sta"`
UsgCaps float64 `json:"usg_caps"`
Version string `json:"version"`
VersionIncompatible FlexBool `json:"version_incompatible"`
Wan1 struct {
BytesR FlexInt `json:"bytes-r"`
DNS []string `json:"dns"`
Enable FlexBool `json:"enable"`
FullDuplex FlexBool `json:"full_duplex"`
Gateway string `json:"gateway"`
Ifname string `json:"ifname"`
IP string `json:"ip"`
Mac string `json:"mac"`
MaxSpeed FlexInt `json:"max_speed"`
Name string `json:"name"`
Netmask string `json:"netmask"`
RxBytes FlexInt `json:"rx_bytes"`
RxBytesR FlexInt `json:"rx_bytes-r"`
RxDropped FlexInt `json:"rx_dropped"`
RxErrors FlexInt `json:"rx_errors"`
RxMulticast FlexInt `json:"rx_multicast"`
RxPackets FlexInt `json:"rx_packets"`
Speed FlexInt `json:"speed"`
TxBytes FlexInt `json:"tx_bytes"`
TxBytesR FlexInt `json:"tx_bytes-r"`
TxDropped FlexInt `json:"tx_dropped"`
TxErrors FlexInt `json:"tx_errors"`
TxPackets FlexInt `json:"tx_packets"`
Type string `json:"type"`
Up FlexBool `json:"up"`
} `json:"wan1"`
Wan2 struct {
BytesR FlexInt `json:"bytes-r"`
DNS []string `json:"dns"`
Enable FlexBool `json:"enable"`
FullDuplex FlexBool `json:"full_duplex"`
Gateway string `json:"gateway"`
Ifname string `json:"ifname"`
IP string `json:"ip"`
Mac string `json:"mac"`
MaxSpeed FlexInt `json:"max_speed"`
Name string `json:"name"`
Netmask string `json:"netmask"`
RxBytes FlexInt `json:"rx_bytes"`
RxBytesR FlexInt `json:"rx_bytes-r"`
RxDropped FlexInt `json:"rx_dropped"`
RxErrors FlexInt `json:"rx_errors"`
RxMulticast FlexInt `json:"rx_multicast"`
RxPackets FlexInt `json:"rx_packets"`
Speed FlexInt `json:"speed"`
TxBytes FlexInt `json:"tx_bytes"`
TxBytesR FlexInt `json:"tx_bytes-r"`
TxDropped FlexInt `json:"tx_dropped"`
TxErrors FlexInt `json:"tx_errors"`
TxPackets FlexInt `json:"tx_packets"`
Type string `json:"type"`
Up FlexBool `json:"up"`
} `json:"wan2"`
Stat struct {
SiteID string `json:"site_id"`
O string `json:"o"`
Oid string `json:"oid"`
Gw string `json:"gw"`
Time FlexInt `json:"time"`
Datetime time.Time `json:"datetime"`
Duration FlexInt `json:"duration"`
WanRxPackets FlexInt `json:"wan-rx_packets"`
WanRxBytes FlexInt `json:"wan-rx_bytes"`
WanTxPackets FlexInt `json:"wan-tx_packets"`
WanTxBytes FlexInt `json:"wan-tx_bytes"`
LanRxPackets FlexInt `json:"lan-rx_packets"`
LanRxBytes FlexInt `json:"lan-rx_bytes"`
LanTxPackets FlexInt `json:"lan-tx_packets"`
LanTxBytes FlexInt `json:"lan-tx_bytes"`
WanRxDropped FlexInt `json:"wan-rx_dropped"`
LanRxDropped FlexInt `json:"lan-rx_dropped"`
} `json:"stat"`
TxBytes FlexInt `json:"tx_bytes"`
RxBytes FlexInt `json:"rx_bytes"`
Bytes FlexInt `json:"bytes"`
NumSta FlexInt `json:"num_sta"`
UserNumSta FlexInt `json:"user-num_sta"`
GuestNumSta FlexInt `json:"guest-num_sta"`
NumDesktop FlexInt `json:"num_desktop"`
NumMobile FlexInt `json:"num_mobile"`
NumHandheld FlexInt `json:"num_handheld"`
}