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"` UplinkRemotePort int `json:"uplink_remote_port"`
} `json:"uplink"` } `json:"uplink"`
VapTable []struct { VapTable []struct {
SiteName string `json:"-"`
AnomaliesBarChart struct { AnomaliesBarChart struct {
HighTCPLatency FlexInt `json:"high_tcp_latency"` HighTCPLatency FlexInt `json:"high_tcp_latency"`
HighTCPPacketLoss FlexInt `json:"high_tcp_packet_loss"` 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. // Add SiteName to each device asset.
for i := range loopDevices.UAPs { for i := range loopDevices.UAPs {
loopDevices.UAPs[i].SiteName = site.Desc + " (" + site.Name + ")" 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 { for i := range loopDevices.USGs {
loopDevices.USGs[i].SiteName = site.Desc + " (" + site.Name + ")" 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 { for i := range loopDevices.USWs {
loopDevices.USWs[i].SiteName = site.Desc + " (" + site.Name + ")" loopDevices.USWs[i].SiteName = site.Desc + " (" + site.Name + ")"

View File

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

View File

@ -1,262 +1,261 @@
package unifi package unifi
import "encoding/json" import "time"
// USG represents all the data from the Ubiquiti Controller for a Unifi Security Gateway. // USG represents all the data from the Ubiquiti Controller for a Unifi Security Gateway.
type USG struct { type USG struct {
ID string `json:"_id"` ID string `json:"_id"`
UUptime float64 `json:"_uptime"`
AdoptIP string `json:"adopt_ip"`
AdoptURL string `json:"adopt_url"`
Adopted FlexBool `json:"adopted"` Adopted FlexBool `json:"adopted"`
Bytes float64 `json:"bytes"`
Cfgversion string `json:"cfgversion"` Cfgversion string `json:"cfgversion"`
ConfigNetwork struct { ConfigNetwork struct {
Type string `json:"type"`
IP string `json:"ip"` IP string `json:"ip"`
Type string `json:"type"`
} `json:"config_network"` } `json:"config_network"`
ConfigNetworkWan struct { EthernetTable []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 {
Mac string `json:"mac"` Mac string `json:"mac"`
NumPort FlexInt `json:"num_port"`
Name string `json:"name"` Name string `json:"name"`
NumPort float64 `json:"num_port"`
} `json:"ethernet_table"` } `json:"ethernet_table"`
FwCaps float64 `json:"fw_caps"` FwCaps FlexInt `json:"fw_caps"`
GuestNumSta float64 `json:"guest-num_sta"` InformIP string `json:"inform_ip"`
GuestToken string `json:"guest_token"` InformURL string `json:"inform_url"`
InformIP string `json:"inform_ip"` IP string `json:"ip"`
InformURL string `json:"inform_url"` LedOverride string `json:"led_override"`
IP string `json:"ip"` LicenseState string `json:"license_state"`
KnownCfgversion string `json:"known_cfgversion"` Mac string `json:"mac"`
LastSeen float64 `json:"last_seen"` Model string `json:"model"`
LedOverride string `json:"led_override"` Name string `json:"name"`
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"`
OutdoorModeOverride string `json:"outdoor_mode_override"` OutdoorModeOverride string `json:"outdoor_mode_override"`
PortTable []struct { Serial string `json:"serial"`
DNS []string `json:"dns,omitempty"` SiteID string `json:"site_id"`
Enable FlexBool `json:"enable"` SiteName string `json:"-"`
FullDuplex FlexBool `json:"full_duplex"` Type string `json:"type"`
Gateway string `json:"gateway,omitempty"` UsgCaps FlexInt `json:"usg_caps"`
Ifname string `json:"ifname"` Version string `json:"version"`
IP string `json:"ip"` RequiredVersion string `json:"required_version"`
Mac string `json:"mac"` EthernetOverrides []struct {
Name string `json:"name"` Ifname string `json:"ifname"`
Netmask string `json:"netmask"` Networkgroup string `json:"networkgroup"`
RxBytes FlexInt `json:"rx_bytes"` } `json:"ethernet_overrides"`
RxDropped float64 `json:"rx_dropped"` HwCaps FlexInt `json:"hw_caps"`
RxErrors float64 `json:"rx_errors"` BoardRev FlexInt `json:"board_rev"`
RxMulticast float64 `json:"rx_multicast"` Unsupported FlexBool `json:"unsupported"`
RxPackets float64 `json:"rx_packets"` UnsupportedReason FlexInt `json:"unsupported_reason"`
Speed float64 `json:"speed"` DeviceID string `json:"device_id"`
TxBytes FlexInt `json:"tx_bytes"` State FlexInt `json:"state"`
TxDropped float64 `json:"tx_dropped"` LastSeen FlexInt `json:"last_seen"`
TxErrors float64 `json:"tx_errors"` Upgradable FlexBool `json:"upgradable"`
TxPackets float64 `json:"tx_packets"` AdoptableWhenUpgraded FlexBool `json:"adoptable_when_upgraded"`
Up FlexBool `json:"up"` Rollupgrade FlexBool `json:"rollupgrade"`
} `json:"port_table"` KnownCfgversion string `json:"known_cfgversion"`
Rollupgrade FlexBool `json:"rollupgrade"` Uptime FlexInt `json:"uptime"`
RxBytes FlexInt `json:"rx_bytes"` Locating FlexBool `json:"locating"`
Serial string `json:"serial"` ConnectRequestIP string `json:"connect_request_ip"`
SiteID string `json:"site_id"` ConnectRequestPort string `json:"connect_request_port"`
SiteName string `json:"-"` SysStats struct {
SpeedtestStatus struct { Loadavg1 FlexInt `json:"loadavg_1"`
Latency float64 `json:"latency"` Loadavg15 FlexInt `json:"loadavg_15"`
Rundate float64 `json:"rundate"` Loadavg5 FlexInt `json:"loadavg_5"`
Runtime float64 `json:"runtime"` MemBuffer FlexInt `json:"mem_buffer"`
StatusDownload float64 `json:"status_download"` MemTotal FlexInt `json:"mem_total"`
StatusPing float64 `json:"status_ping"` MemUsed FlexInt `json:"mem_used"`
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"`
} `json:"sys_stats"` } `json:"sys_stats"`
SystemStats struct { SystemStats struct {
CPU float64 `json:"cpu,string"` CPU FlexInt `json:"cpu"`
Mem float64 `json:"mem,string"` Mem FlexInt `json:"mem"`
Uptime float64 `json:"uptime,string"` Uptime FlexInt `json:"uptime"`
} `json:"system-stats"` } `json:"system-stats"`
TxBytes FlexInt `json:"tx_bytes"` GuestToken string `json:"guest_token"`
Type string `json:"type"` SpeedtestStatus struct {
Upgradable FlexBool `json:"upgradable"` Latency FlexInt `json:"latency"`
Uplink struct { Rundate FlexInt `json:"rundate"`
BytesR float64 `json:"bytes-r"` Runtime FlexInt `json:"runtime"`
Drops float64 `json:"drops"` 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"` Enable FlexBool `json:"enable"`
FullDuplex FlexBool `json:"full_duplex"` FullDuplex FlexBool `json:"full_duplex"`
Gateways []string `json:"gateways"` Gateways []string `json:"gateways"`
IP string `json:"ip"` IP string `json:"ip"`
Latency float64 `json:"latency"` Latency FlexInt `json:"latency"`
Mac string `json:"mac"` Mac string `json:"mac"`
MaxSpeed float64 `json:"max_speed"`
Name string `json:"name"` Name string `json:"name"`
Nameservers []string `json:"nameservers"` Nameservers []string `json:"nameservers"`
Netmask string `json:"netmask"` Netmask string `json:"netmask"`
NumPort float64 `json:"num_port"` NumPort FlexInt `json:"num_port"`
RxBytes FlexInt `json:"rx_bytes"` RxBytes FlexInt `json:"rx_bytes"`
RxBytesR float64 `json:"rx_bytes-r"` RxDropped FlexInt `json:"rx_dropped"`
RxDropped float64 `json:"rx_dropped"` RxErrors FlexInt `json:"rx_errors"`
RxErrors float64 `json:"rx_errors"` RxMulticast FlexInt `json:"rx_multicast"`
RxMulticast float64 `json:"rx_multicast"` RxPackets FlexInt `json:"rx_packets"`
RxPackets float64 `json:"rx_packets"` Speed FlexInt `json:"speed"`
Speed float64 `json:"speed"` SpeedtestLastrun FlexInt `json:"speedtest_lastrun"`
SpeedtestLastrun float64 `json:"speedtest_lastrun"` SpeedtestPing FlexInt `json:"speedtest_ping"`
SpeedtestPing float64 `json:"speedtest_ping"`
SpeedtestStatus string `json:"speedtest_status"` SpeedtestStatus string `json:"speedtest_status"`
TxBytes FlexInt `json:"tx_bytes"` TxBytes FlexInt `json:"tx_bytes"`
TxBytesR float64 `json:"tx_bytes-r"` TxDropped FlexInt `json:"tx_dropped"`
TxDropped float64 `json:"tx_dropped"` TxErrors FlexInt `json:"tx_errors"`
TxErrors float64 `json:"tx_errors"` TxPackets FlexInt `json:"tx_packets"`
TxPackets float64 `json:"tx_packets"`
Type string `json:"type"`
Up FlexBool `json:"up"` Up FlexBool `json:"up"`
Uptime float64 `json:"uptime"` Uptime FlexInt `json:"uptime"`
XputDown float64 `json:"xput_down"` XputDown FlexInt `json:"xput_down"`
XputUp float64 `json:"xput_up"` 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"` } `json:"uplink"`
Uptime float64 `json:"uptime"` Stat struct {
UserNumSta float64 `json:"user-num_sta"` SiteID string `json:"site_id"`
UsgCaps float64 `json:"usg_caps"` O string `json:"o"`
Version string `json:"version"` Oid string `json:"oid"`
VersionIncompatible FlexBool `json:"version_incompatible"` Gw string `json:"gw"`
Wan1 struct { Time FlexInt `json:"time"`
BytesR FlexInt `json:"bytes-r"` Datetime time.Time `json:"datetime"`
DNS []string `json:"dns"` Duration FlexInt `json:"duration"`
Enable FlexBool `json:"enable"` WanRxPackets FlexInt `json:"wan-rx_packets"`
FullDuplex FlexBool `json:"full_duplex"` WanRxBytes FlexInt `json:"wan-rx_bytes"`
Gateway string `json:"gateway"` WanTxPackets FlexInt `json:"wan-tx_packets"`
Ifname string `json:"ifname"` WanTxBytes FlexInt `json:"wan-tx_bytes"`
IP string `json:"ip"` LanRxPackets FlexInt `json:"lan-rx_packets"`
Mac string `json:"mac"` LanRxBytes FlexInt `json:"lan-rx_bytes"`
MaxSpeed FlexInt `json:"max_speed"` LanTxPackets FlexInt `json:"lan-tx_packets"`
Name string `json:"name"` LanTxBytes FlexInt `json:"lan-tx_bytes"`
Netmask string `json:"netmask"` WanRxDropped FlexInt `json:"wan-rx_dropped"`
RxBytes FlexInt `json:"rx_bytes"` LanRxDropped FlexInt `json:"lan-rx_dropped"`
RxBytesR FlexInt `json:"rx_bytes-r"` } `json:"stat"`
RxDropped FlexInt `json:"rx_dropped"` TxBytes FlexInt `json:"tx_bytes"`
RxErrors FlexInt `json:"rx_errors"` RxBytes FlexInt `json:"rx_bytes"`
RxMulticast FlexInt `json:"rx_multicast"` Bytes FlexInt `json:"bytes"`
RxPackets FlexInt `json:"rx_packets"` NumSta FlexInt `json:"num_sta"`
Speed FlexInt `json:"speed"` UserNumSta FlexInt `json:"user-num_sta"`
TxBytes FlexInt `json:"tx_bytes"` GuestNumSta FlexInt `json:"guest-num_sta"`
TxBytesR FlexInt `json:"tx_bytes-r"` NumDesktop FlexInt `json:"num_desktop"`
TxDropped FlexInt `json:"tx_dropped"` NumMobile FlexInt `json:"num_mobile"`
TxErrors FlexInt `json:"tx_errors"` NumHandheld FlexInt `json:"num_handheld"`
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"`
} }