Documentation ¶
Overview ¶
Package unifi provides a set of types to unload (unmarshal) Ubiquiti UniFi controller data. Also provided are methods to easily get data for devices - things like access points and switches, and for clients - the things connected to those access points and switches. As a bonus, each device and client type provided has an attached method to create InfluxDB datapoints.
Index ¶
- Constants
- func DiscardLogs(msg string, v ...interface{})
- type Client
- type Clients
- type Devices
- type FlexBool
- type FlexInt
- type IDS
- type IDSList
- type Logger
- type Site
- type Sites
- type UAP
- type UAPStat
- type USG
- type USGStat
- type USW
- type USWStat
- type Unifi
- func (u *Unifi) GetClients(sites Sites) (Clients, error)
- func (u *Unifi) GetData(methodPath string, v interface{}) error
- func (u *Unifi) GetDevices(sites Sites) (*Devices, error)
- func (u *Unifi) GetIDS(sites Sites, from, to time.Time) ([]*IDS, error)
- func (u *Unifi) GetJSON(apiPath string) ([]byte, error)
- func (u *Unifi) GetSiteIDS(site *Site, from, to time.Time) ([]*IDS, error)
- func (u *Unifi) GetSites() (Sites, error)
- func (u *Unifi) UniReq(apiPath string, params string) (req *http.Request, err error)
Constants ¶
const ( // StatusPath shows Controller version. StatusPath string = "/status" // SiteList is the path to the api site list. SiteList string = "/api/stat/sites" // ClientPath is Unifi Clients API Path ClientPath string = "/api/s/%s/stat/sta" // DevicePath is where we get data about Unifi devices. DevicePath string = "/api/s/%s/stat/device" // NetworkPath contains network-configuration data. Not really graphable. NetworkPath string = "/api/s/%s/rest/networkconf" // UserGroupPath contains usergroup configurations. UserGroupPath string = "/api/s/%s/rest/usergroup" // LoginPath is Unifi Controller Login API Path LoginPath string = "/api/login" // IPSEvents returns Intrusion Detection Systems Events IPSEvents string = "/api/s/%s/stat/ips/event" )
This is a list of unifi API paths. The %s in each string must be replaced with a Site.Name.
Variables ¶
This section is empty.
Functions ¶
func DiscardLogs ¶
func DiscardLogs(msg string, v ...interface{})
DiscardLogs is the default debug logger.
Types ¶
type Client ¶
type Client struct { Anomalies int64 `json:"anomalies,omitempty"` ApMac string `json:"ap_mac"` ApName string `json:"-"` AssocTime int64 `json:"assoc_time"` Blocked bool `json:"blocked,omitempty"` Bssid string `json:"bssid"` BytesR int64 `json:"bytes-r"` Ccq int64 `json:"ccq"` Channel FlexInt `json:"channel"` DevCat FlexInt `json:"dev_cat"` DevFamily FlexInt `json:"dev_family"` DevID FlexInt `json:"dev_id"` DevVendor FlexInt `json:"dev_vendor,omitempty"` DhcpendTime int `json:"dhcpend_time,omitempty"` DpiStats struct { App FlexInt Cat FlexInt RxBytes FlexInt RxPackets FlexInt TxBytes FlexInt TxPackets FlexInt } `json:"dpi_stats"` DpiStatsLastUpdated int64 `json:"dpi_stats_last_updated"` Essid string `json:"essid"` FirstSeen int64 `json:"first_seen"` FixedIP string `json:"fixed_ip"` GwMac string `json:"gw_mac"` GwName string `json:"-"` Hostname string `json:"hostname"` ID string `json:"_id"` IP string `json:"ip"` IdleTime int64 `json:"idle_time"` Is11R FlexBool `json:"is_11r"` IsGuest FlexBool `json:"is_guest"` IsGuestByUAP FlexBool `json:"_is_guest_by_uap"` IsGuestByUGW FlexBool `json:"_is_guest_by_ugw"` IsGuestByUSW FlexBool `json:"_is_guest_by_usw"` IsWired FlexBool `json:"is_wired"` LastSeen int64 `json:"last_seen"` LastSeenByUAP int64 `json:"_last_seen_by_uap"` LastSeenByUGW int64 `json:"_last_seen_by_ugw"` LastSeenByUSW int64 `json:"_last_seen_by_usw"` LatestAssocTime int64 `json:"latest_assoc_time"` Mac string `json:"mac"` Name string `json:"name"` Network string `json:"network"` NetworkID string `json:"network_id"` Noise int64 `json:"noise"` Note string `json:"note"` Noted FlexBool `json:"noted"` OsClass FlexInt `json:"os_class"` OsName FlexInt `json:"os_name"` Oui string `json:"oui"` PowersaveEnabled FlexBool `json:"powersave_enabled"` QosPolicyApplied FlexBool `json:"qos_policy_applied"` Radio string `json:"radio"` RadioName string `json:"radio_name"` RadioProto string `json:"radio_proto"` RoamCount int64 `json:"roam_count"` Rssi int64 `json:"rssi"` RxBytes int64 `json:"rx_bytes"` RxBytesR int64 `json:"rx_bytes-r"` RxPackets int64 `json:"rx_packets"` RxRate int64 `json:"rx_rate"` Signal int64 `json:"signal"` SiteID string `json:"site_id"` SiteName string `json:"-"` SwDepth int `json:"sw_depth"` SwMac string `json:"sw_mac"` SwName string `json:"-"` SwPort FlexInt `json:"sw_port"` TxBytes int64 `json:"tx_bytes"` TxBytesR int64 `json:"tx_bytes-r"` TxPackets int64 `json:"tx_packets"` TxPower int64 `json:"tx_power"` TxRate int64 `json:"tx_rate"` Uptime int64 `json:"uptime"` UptimeByUAP int64 `json:"_uptime_by_uap"` UptimeByUGW int64 `json:"_uptime_by_ugw"` UptimeByUSW int64 `json:"_uptime_by_usw"` UseFixedIP FlexBool `json:"use_fixedip"` UserGroupID string `json:"usergroup_id"` UserID string `json:"user_id"` Vlan FlexInt `json:"vlan"` WifiTxAttempts int64 `json:"wifi_tx_attempts"` WiredRxBytes int64 `json:"wired-rx_bytes"` WiredRxBytesR int64 `json:"wired-rx_bytes-r"` WiredRxPackets int64 `json:"wired-rx_packets"` WiredTxBytes int64 `json:"wired-tx_bytes"` WiredTxBytesR int64 `json:"wired-tx_bytes-r"` WiredTxPackets int64 `json:"wired-tx_packets"` }
Client defines all the data a connected-network client contains.
type Clients ¶
type Clients []*Client
Clients contains a list that contains all of the unifi clients from a controller.
type Devices ¶
Devices contains a list of all the unifi devices from a controller. Contains Access points, security gateways and switches.
type FlexBool ¶ added in v1.0.1
FlexBool provides a container and unmarshalling for fields that may be boolean or strings in the Unifi API.
func (*FlexBool) UnmarshalJSON ¶ added in v1.0.1
UnmarshalJSON method converts armed/disarmed, yes/no, active/inactive or 0/1 to true/false. Really it converts ready, ok, up, t, armed, yes, active, enabled, 1, true to true. Anything else is false.
type FlexInt ¶
FlexInt provides a container and unmarshalling for fields that may be numbers or strings in the Unifi API.
func (*FlexInt) UnmarshalJSON ¶
UnmarshalJSON converts a string or number to an integer. Generally, do call this directly, it's used in the json interface.
type IDS ¶
type IDS struct { ID string `json:"_id"` Archived FlexBool `json:"archived"` Timestamp int64 `json:"timestamp"` FlowID int64 `json:"flow_id"` InIface string `json:"in_iface"` EventType string `json:"event_type"` SrcIP string `json:"src_ip"` SrcMac string `json:"src_mac"` SrcPort int `json:"src_port,omitempty"` DestIP string `json:"dest_ip"` DstMac string `json:"dst_mac"` DestPort int `json:"dest_port,omitempty"` Proto string `json:"proto"` AppProto string `json:"app_proto,omitempty"` Host string `json:"host"` Usgip string `json:"usgip"` UniqueAlertid string `json:"unique_alertid"` SrcipCountry string `json:"srcipCountry"` DstipCountry FlexBool `json:"dstipCountry"` UsgipCountry string `json:"usgipCountry"` SrcipGeo struct { ContinentCode string `json:"continent_code"` CountryCode string `json:"country_code"` CountryCode3 string `json:"country_code3"` CountryName string `json:"country_name"` Region string `json:"region"` City string `json:"city"` PostalCode string `json:"postal_code"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` DmaCode int64 `json:"dma_code"` AreaCode int64 `json:"area_code"` } `json:"srcipGeo"` DstipGeo bool `json:"dstipGeo"` UsgipGeo struct { ContinentCode string `json:"continent_code"` CountryCode string `json:"country_code"` CountryCode3 string `json:"country_code3"` CountryName string `json:"country_name"` Region string `json:"region"` City string `json:"city"` PostalCode string `json:"postal_code"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` DmaCode int64 `json:"dma_code"` AreaCode int64 `json:"area_code"` } `json:"usgipGeo"` SrcipASN string `json:"srcipASN"` DstipASN string `json:"dstipASN"` UsgipASN string `json:"usgipASN"` Catname string `json:"catname"` InnerAlertAction string `json:"inner_alert_action"` InnerAlertGid int64 `json:"inner_alert_gid"` InnerAlertSignatureID int64 `json:"inner_alert_signature_id"` InnerAlertRev int64 `json:"inner_alert_rev"` InnerAlertSignature string `json:"inner_alert_signature"` InnerAlertCategory string `json:"inner_alert_category"` InnerAlertSeverity int64 `json:"inner_alert_severity"` Key string `json:"key"` Subsystem string `json:"subsystem"` SiteID string `json:"site_id"` SiteName string `json:"-"` Time int64 `json:"time"` Datetime time.Time `json:"datetime"` Msg string `json:"msg"` IcmpType int64 `json:"icmp_type,omitempty"` IcmpCode int64 `json:"icmp_code,omitempty"` }
IDS holds an Intrusion Prevention System Event.
func (*IDS) Points ¶
Points generates intrusion detection datapoints for InfluxDB. These points can be passed directly to influx.
type IDSList ¶
type IDSList []*IDS
IDSList contains a list that contains all of the IDS Events on a controller.
type Logger ¶
type Logger func(msg string, fmt ...interface{})
Logger is a base type to deal with changing log outputs. Create a logger that matches this interface to capture debug and error logs.
type Site ¶
type Site struct { ID string `json:"_id"` Name string `json:"name"` Desc string `json:"desc"` SiteName string `json:"-"` AttrHiddenID string `json:"attr_hidden_id"` AttrNoDelete FlexBool `json:"attr_no_delete"` Health []struct { Subsystem string `json:"subsystem"` NumUser FlexInt `json:"num_user,omitempty"` NumGuest FlexInt `json:"num_guest,omitempty"` NumIot FlexInt `json:"num_iot,omitempty"` TxBytesR FlexInt `json:"tx_bytes-r,omitempty"` RxBytesR FlexInt `json:"rx_bytes-r,omitempty"` Status string `json:"status"` NumAp FlexInt `json:"num_ap,omitempty"` NumAdopted FlexInt `json:"num_adopted,omitempty"` NumDisabled FlexInt `json:"num_disabled,omitempty"` NumDisconnected FlexInt `json:"num_disconnected,omitempty"` NumPending FlexInt `json:"num_pending,omitempty"` NumGw FlexInt `json:"num_gw,omitempty"` WanIP string `json:"wan_ip,omitempty"` Gateways []string `json:"gateways,omitempty"` Netmask string `json:"netmask,omitempty"` Nameservers []string `json:"nameservers,omitempty"` NumSta FlexInt `json:"num_sta,omitempty"` GwMac string `json:"gw_mac,omitempty"` GwName string `json:"gw_name,omitempty"` GwSystemStats struct { CPU FlexInt `json:"cpu"` Mem FlexInt `json:"mem"` Uptime FlexInt `json:"uptime"` } `json:"gw_system-stats,omitempty"` GwVersion string `json:"gw_version,omitempty"` Latency FlexInt `json:"latency,omitempty"` Uptime FlexInt `json:"uptime,omitempty"` Drops FlexInt `json:"drops,omitempty"` XputUp FlexInt `json:"xput_up,omitempty"` XputDown FlexInt `json:"xput_down,omitempty"` SpeedtestStatus string `json:"speedtest_status,omitempty"` SpeedtestLastrun FlexInt `json:"speedtest_lastrun,omitempty"` SpeedtestPing FlexInt `json:"speedtest_ping,omitempty"` LanIP string `json:"lan_ip,omitempty"` NumSw FlexInt `json:"num_sw,omitempty"` RemoteUserEnabled FlexBool `json:"remote_user_enabled,omitempty"` RemoteUserNumActive FlexInt `json:"remote_user_num_active,omitempty"` RemoteUserNumInactive FlexInt `json:"remote_user_num_inactive,omitempty"` RemoteUserRxBytes FlexInt `json:"remote_user_rx_bytes,omitempty"` RemoteUserTxBytes FlexInt `json:"remote_user_tx_bytes,omitempty"` RemoteUserRxPackets FlexInt `json:"remote_user_rx_packets,omitempty"` RemoteUserTxPackets FlexInt `json:"remote_user_tx_packets,omitempty"` SiteToSiteEnabled FlexBool `json:"site_to_site_enabled,omitempty"` } `json:"health"` NumNewAlarms FlexInt `json:"num_new_alarms"` }
Site represents a site's data.
type UAP ¶
type UAP struct { /* This was auto generated and then slowly edited by hand to get all the data types right and graphable. */ ID string `json:"_id"` Adopted FlexBool `json:"adopted"` AntennaTable []struct { Default FlexBool `json:"default"` ID FlexInt `json:"id"` Name string `json:"name"` Wifi0Gain FlexInt `json:"wifi0_gain"` Wifi1Gain FlexInt `json:"wifi1_gain"` } `json:"antenna_table"` BandsteeringMode string `json:"bandsteering_mode,omitempty"` BoardRev int `json:"board_rev"` Cfgversion string `json:"cfgversion"` ConfigNetwork struct { Type string `json:"type"` IP string `json:"ip"` } `json:"config_network"` CountrycodeTable []int `json:"countrycode_table"` EthernetTable []struct { Mac string `json:"mac"` NumPort FlexInt `json:"num_port"` Name string `json:"name"` } `json:"ethernet_table"` FwCaps int `json:"fw_caps"` HasEth1 FlexBool `json:"has_eth1"` HasSpeaker FlexBool `json:"has_speaker"` InformIP string `json:"inform_ip"` InformURL string `json:"inform_url"` IP string `json:"ip"` LedOverride string `json:"led_override"` Mac string `json:"mac"` MeshStaVapEnabled FlexBool `json:"mesh_sta_vap_enabled"` Model string `json:"model"` Name string `json:"name"` OutdoorModeOverride string `json:"outdoor_mode_override"` PortTable []struct { PortIdx FlexInt `json:"port_idx"` OpMode string `json:"op_mode"` PortconfID string `json:"portconf_id"` AttrNoEdit FlexBool `json:"attr_no_edit,omitempty"` Media string `json:"media"` Name string `json:"name"` PoeCaps FlexInt `json:"poe_caps"` PortPoe FlexBool `json:"port_poe"` TxBytesR FlexInt `json:"tx_bytes-r"` RxBytesR FlexInt `json:"rx_bytes-r"` BytesR FlexInt `json:"bytes-r"` PortDelta struct { TimeDelta FlexInt `json:"time_delta"` } `json:"port_delta"` Enable FlexBool `json:"enable"` Masked FlexBool `json:"masked"` AggregatedBy FlexBool `json:"aggregated_by"` } `json:"port_table"` RadioTable []struct { Radio string `json:"radio"` Name string `json:"name"` Channel FlexInt `json:"channel"` Ht string `json:"ht"` TxPowerMode string `json:"tx_power_mode"` TxPower FlexInt `json:"tx_power"` MaxTxpower FlexInt `json:"max_txpower"` MinTxpower FlexInt `json:"min_txpower"` Nss FlexInt `json:"nss"` MinRssiEnabled FlexBool `json:"min_rssi_enabled"` BuiltinAntenna FlexBool `json:"builtin_antenna"` BuiltinAntGain FlexInt `json:"builtin_ant_gain"` CurrentAntennaGain FlexInt `json:"current_antenna_gain"` RadioCaps FlexInt `json:"radio_caps"` WlangroupID string `json:"wlangroup_id"` Is11Ac FlexBool `json:"is_11ac,omitempty"` HasDfs FlexBool `json:"has_dfs,omitempty"` HasFccdfs FlexBool `json:"has_fccdfs,omitempty"` } `json:"radio_table"` ScanRadioTable []interface{} `json:"scan_radio_table"` Serial string `json:"serial"` SiteID string `json:"site_id"` SiteName string `json:"-"` Type string `json:"type"` Version string `json:"version"` VwireTable []interface{} `json:"vwire_table"` WifiCaps int `json:"wifi_caps"` WlangroupIDNa string `json:"wlangroup_id_na"` WlangroupIDNg string `json:"wlangroup_id_ng"` RequiredVersion string `json:"required_version"` HwCaps int `json:"hw_caps"` Unsupported FlexBool `json:"unsupported"` UnsupportedReason FlexInt `json:"unsupported_reason"` SysErrorCaps int `json:"sys_error_caps"` HasFan FlexBool `json:"has_fan"` HasTemperature FlexBool `json:"has_temperature"` DeviceID string `json:"device_id"` State int `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"` UUptime FlexInt `json:"_uptime"` Locating FlexBool `json:"locating"` ConnectRequestIP string `json:"connect_request_ip"` ConnectRequestPort string `json:"connect_request_port"` SysStats struct { Loadavg1 float64 `json:"loadavg_1,string"` Loadavg15 float64 `json:"loadavg_15,string"` Loadavg5 float64 `json:"loadavg_5,string"` 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"` } `json:"system-stats"` SSHSessionTable []interface{} `json:"ssh_session_table"` Scanning FlexBool `json:"scanning"` SpectrumScanning FlexBool `json:"spectrum_scanning"` GuestToken string `json:"guest_token"` Meshv3PeerMac string `json:"meshv3_peer_mac"` Satisfaction FlexInt `json:"satisfaction"` Isolated FlexBool `json:"isolated"` RadioTableStats []struct { Name string `json:"name"` Channel FlexInt `json:"channel"` Radio string `json:"radio"` AstTxto interface{} `json:"ast_txto"` AstCst interface{} `json:"ast_cst"` AstBeXmit FlexInt `json:"ast_be_xmit"` CuTotal FlexInt `json:"cu_total"` CuSelfRx FlexInt `json:"cu_self_rx"` CuSelfTx FlexInt `json:"cu_self_tx"` Gain FlexInt `json:"gain"` State string `json:"state"` Extchannel FlexInt `json:"extchannel"` TxPower FlexInt `json:"tx_power"` TxPackets FlexInt `json:"tx_packets"` TxRetries FlexInt `json:"tx_retries"` NumSta FlexInt `json:"num_sta"` GuestNumSta FlexInt `json:"guest-num_sta"` UserNumSta FlexInt `json:"user-num_sta"` } `json:"radio_table_stats"` Uplink struct { FullDuplex FlexBool `json:"full_duplex"` IP string `json:"ip"` Mac string `json:"mac"` MaxVlan int `json:"max_vlan"` Name string `json:"name"` Netmask string `json:"netmask"` NumPort int `json:"num_port"` RxBytes FlexInt `json:"rx_bytes"` 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"` TxDropped FlexInt `json:"tx_dropped"` TxErrors FlexInt `json:"tx_errors"` TxPackets FlexInt `json:"tx_packets"` Up FlexBool `json:"up"` MaxSpeed FlexInt `json:"max_speed"` Type string `json:"type"` TxBytesR FlexInt `json:"tx_bytes-r"` RxBytesR FlexInt `json:"rx_bytes-r"` UplinkMac string `json:"uplink_mac"` UplinkRemotePort int `json:"uplink_remote_port"` } `json:"uplink"` VapTable []struct { AnomaliesBarChart struct { HighTCPLatency FlexInt `json:"high_tcp_latency"` HighTCPPacketLoss FlexInt `json:"high_tcp_packet_loss"` HighWifiLatency FlexInt `json:"high_wifi_latency"` HighWifiRetries FlexInt `json:"high_wifi_retries"` LowPhyRate FlexInt `json:"low_phy_rate"` PoorStreamEff FlexInt `json:"poor_stream_eff"` SleepyClient FlexInt `json:"sleepy_client"` StaArpTimeout FlexInt `json:"sta_arp_timeout"` StaDNSTimeout FlexInt `json:"sta_dns_timeout"` StaIPTimeout FlexInt `json:"sta_ip_timeout"` WeakSignal FlexInt `json:"weak_signal"` } `json:"anomalies_bar_chart"` AnomaliesBarChartNow struct { HighTCPLatency FlexInt `json:"high_tcp_latency"` HighTCPPacketLoss FlexInt `json:"high_tcp_packet_loss"` HighWifiLatency FlexInt `json:"high_wifi_latency"` HighWifiRetries FlexInt `json:"high_wifi_retries"` LowPhyRate FlexInt `json:"low_phy_rate"` PoorStreamEff FlexInt `json:"poor_stream_eff"` SleepyClient FlexInt `json:"sleepy_client"` StaArpTimeout FlexInt `json:"sta_arp_timeout"` StaDNSTimeout FlexInt `json:"sta_dns_timeout"` StaIPTimeout FlexInt `json:"sta_ip_timeout"` WeakSignal FlexInt `json:"weak_signal"` } `json:"anomalies_bar_chart_now"` AvgClientSignal FlexInt `json:"avg_client_signal"` Bssid string `json:"bssid"` Ccq int `json:"ccq"` Channel int `json:"channel"` Essid string `json:"essid"` Extchannel int `json:"extchannel"` ID string `json:"id"` MacFilterRejections int `json:"mac_filter_rejections"` Name string `json:"name"` NumSatisfactionSta FlexInt `json:"num_satisfaction_sta"` NumSta int `json:"num_sta"` Radio string `json:"radio"` RadioName string `json:"radio_name"` ReasonsBarChart struct { PhyRate FlexInt `json:"phy_rate"` Signal FlexInt `json:"signal"` SleepyClient FlexInt `json:"sleepy_client"` StaArpTimeout FlexInt `json:"sta_arp_timeout"` StaDNSTimeout FlexInt `json:"sta_dns_timeout"` StaIPTimeout FlexInt `json:"sta_ip_timeout"` StreamEff FlexInt `json:"stream_eff"` TCPLatency FlexInt `json:"tcp_latency"` TCPPacketLoss FlexInt `json:"tcp_packet_loss"` WifiLatency FlexInt `json:"wifi_latency"` WifiRetries FlexInt `json:"wifi_retries"` } `json:"reasons_bar_chart"` ReasonsBarChartNow struct { PhyRate FlexInt `json:"phy_rate"` Signal FlexInt `json:"signal"` SleepyClient FlexInt `json:"sleepy_client"` StaArpTimeout FlexInt `json:"sta_arp_timeout"` StaDNSTimeout FlexInt `json:"sta_dns_timeout"` StaIPTimeout FlexInt `json:"sta_ip_timeout"` StreamEff FlexInt `json:"stream_eff"` TCPLatency FlexInt `json:"tcp_latency"` TCPPacketLoss FlexInt `json:"tcp_packet_loss"` WifiLatency FlexInt `json:"wifi_latency"` WifiRetries FlexInt `json:"wifi_retries"` } `json:"reasons_bar_chart_now"` RxBytes FlexInt `json:"rx_bytes"` RxCrypts FlexInt `json:"rx_crypts"` RxDropped FlexInt `json:"rx_dropped"` RxErrors FlexInt `json:"rx_errors"` RxFrags FlexInt `json:"rx_frags"` RxNwids FlexInt `json:"rx_nwids"` RxPackets FlexInt `json:"rx_packets"` RxTCPStats struct { Goodbytes FlexInt `json:"goodbytes"` LatAvg FlexInt `json:"lat_avg"` LatMax FlexInt `json:"lat_max"` LatMin FlexInt `json:"lat_min"` Stalls FlexInt `json:"stalls"` } `json:"rx_tcp_stats"` Satisfaction FlexInt `json:"satisfaction"` SatisfactionNow FlexInt `json:"satisfaction_now"` State string `json:"state"` TxBytes FlexInt `json:"tx_bytes"` TxCombinedRetries FlexInt `json:"tx_combined_retries"` TxDataMpduBytes FlexInt `json:"tx_data_mpdu_bytes"` TxDropped FlexInt `json:"tx_dropped"` TxErrors FlexInt `json:"tx_errors"` TxPackets FlexInt `json:"tx_packets"` TxPower FlexInt `json:"tx_power"` TxRetries FlexInt `json:"tx_retries"` TxRtsRetries FlexInt `json:"tx_rts_retries"` TxSuccess FlexInt `json:"tx_success"` TxTCPStats struct { Goodbytes FlexInt `json:"goodbytes"` LatAvg FlexInt `json:"lat_avg"` LatMax FlexInt `json:"lat_max"` LatMin FlexInt `json:"lat_min"` Stalls FlexInt `json:"stalls"` } `json:"tx_tcp_stats"` TxTotal FlexInt `json:"tx_total"` Up FlexBool `json:"up"` Usage string `json:"usage"` WifiTxAttempts FlexInt `json:"wifi_tx_attempts"` WifiTxDropped FlexInt `json:"wifi_tx_dropped"` WifiTxLatencyMov struct { Avg FlexInt `json:"avg"` Max FlexInt `json:"max"` Min FlexInt `json:"min"` Total FlexInt `json:"total"` TotalCount FlexInt `json:"total_count"` } `json:"wifi_tx_latency_mov"` T string `json:"t"` WlanconfID string `json:"wlanconf_id"` IsGuest FlexBool `json:"is_guest"` IsWep FlexBool `json:"is_wep"` ApMac string `json:"ap_mac"` MapID interface{} `json:"map_id"` SiteID string `json:"site_id"` } `json:"vap_table"` DownlinkTable []interface{} `json:"downlink_table"` VwireVapTable []interface{} `json:"vwire_vap_table"` BytesD FlexInt `json:"bytes-d"` TxBytesD FlexInt `json:"tx_bytes-d"` RxBytesD FlexInt `json:"rx_bytes-d"` BytesR FlexInt `json:"bytes-r"` LastUplink struct { UplinkMac string `json:"uplink_mac"` UplinkRemotePort int `json:"uplink_remote_port"` } `json:"last_uplink"` Stat UAPStat `json:"stat"` TxBytes FlexInt `json:"tx_bytes"` RxBytes FlexInt `json:"rx_bytes"` Bytes FlexInt `json:"bytes"` VwireEnabled FlexBool `json:"vwireEnabled"` UplinkTable []interface{} `json:"uplink_table"` NumSta int `json:"num_sta"` UserNumSta int `json:"user-num_sta"` GuestNumSta int `json:"guest-num_sta"` TwoPhaseAdopt FlexBool `json:"two_phase_adopt,omitempty"` }
UAP represents all the data from the Ubiquiti Controller for a Unifi Access Point.
type UAPStat ¶
type UAPStat struct {
// contains filtered or unexported fields
}
UAPStat holds the "stat" data for an access point. This is split out because of a JSON data format change from 5.10 to 5.11.
func (*UAPStat) UnmarshalJSON ¶
UnmarshalJSON unmarshalls 5.10 or 5.11 formatted Access Point Stat data.
type USG ¶
type USG struct { ID string `json:"_id"` Adopted FlexBool `json:"adopted"` Cfgversion string `json:"cfgversion"` ConfigNetwork struct { Type string `json:"type"` IP string `json:"ip"` } `json:"config_network"` EthernetTable []struct { Mac string `json:"mac"` NumPort FlexInt `json:"num_port"` Name string `json:"name"` } `json:"ethernet_table"` 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"` 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 FlexInt `json:"cpu"` Mem FlexInt `json:"mem"` Uptime FlexInt `json:"uptime"` } `json:"system-stats"` 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 FlexBool `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 FlexInt `json:"latency"` Mac string `json:"mac"` Name string `json:"name"` Nameservers []string `json:"nameservers"` Netmask string `json:"netmask"` NumPort FlexInt `json:"num_port"` RxBytes FlexInt `json:"rx_bytes"` 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"` TxDropped FlexInt `json:"tx_dropped"` TxErrors FlexInt `json:"tx_errors"` TxPackets FlexInt `json:"tx_packets"` Up FlexBool `json:"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"` Stat *USGStat `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"` }
USG represents all the data from the Ubiquiti Controller for a Unifi Security Gateway.
type USGStat ¶
type USGStat struct {
// contains filtered or unexported fields
}
USGStat holds the "stat" data for a gateway. This is split out because of a JSON data format change from 5.10 to 5.11.
func (*USGStat) UnmarshalJSON ¶
UnmarshalJSON unmarshalls 5.10 or 5.11 formatted Gateway Stat data.
type USW ¶
type USW struct { SiteName string `json:"-"` ID string `json:"_id"` Adopted FlexBool `json:"adopted"` BoardRev FlexInt `json:"board_rev"` Cfgversion string `json:"cfgversion"` ConfigNetwork struct { Type string `json:"type"` IP string `json:"ip"` } `json:"config_network"` Dot1XPortctrlEnabled FlexBool `json:"dot1x_portctrl_enabled"` EthernetTable []struct { Mac string `json:"mac"` NumPort FlexInt `json:"num_port,omitempty"` Name string `json:"name"` } `json:"ethernet_table"` FlowctrlEnabled FlexBool `json:"flowctrl_enabled"` FwCaps FlexInt `json:"fw_caps"` HasFan FlexBool `json:"has_fan"` HasTemperature FlexBool `json:"has_temperature"` InformIP string `json:"inform_ip"` InformURL string `json:"inform_url"` IP string `json:"ip"` JumboframeEnabled FlexBool `json:"jumboframe_enabled"` 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"` PortOverrides []struct { Name string `json:"name,omitempty"` PoeMode string `json:"poe_mode,omitempty"` PortIdx FlexInt `json:"port_idx"` PortconfID string `json:"portconf_id"` } `json:"port_overrides"` PortTable []struct { PortIdx FlexInt `json:"port_idx"` Media string `json:"media"` PortPoe FlexBool `json:"port_poe"` PoeCaps FlexInt `json:"poe_caps"` SpeedCaps FlexInt `json:"speed_caps"` OpMode string `json:"op_mode"` PortconfID string `json:"portconf_id"` PoeMode string `json:"poe_mode,omitempty"` Autoneg FlexBool `json:"autoneg"` Dot1XMode string `json:"dot1x_mode"` Dot1XStatus string `json:"dot1x_status"` Enable FlexBool `json:"enable"` FlowctrlRx FlexBool `json:"flowctrl_rx"` FlowctrlTx FlexBool `json:"flowctrl_tx"` FullDuplex FlexBool `json:"full_duplex"` IsUplink FlexBool `json:"is_uplink"` Jumbo FlexBool `json:"jumbo"` PoeClass string `json:"poe_class,omitempty"` PoeCurrent FlexInt `json:"poe_current,omitempty"` PoeEnable FlexBool `json:"poe_enable,omitempty"` PoeGood FlexBool `json:"poe_good,omitempty"` PoePower FlexInt `json:"poe_power,omitempty"` PoeVoltage FlexInt `json:"poe_voltage,omitempty"` RxBroadcast FlexInt `json:"rx_broadcast"` RxBytes FlexInt `json:"rx_bytes"` RxDropped FlexInt `json:"rx_dropped"` RxErrors FlexInt `json:"rx_errors"` RxMulticast FlexInt `json:"rx_multicast"` RxPackets FlexInt `json:"rx_packets"` Satisfaction FlexInt `json:"satisfaction"` Speed FlexInt `json:"speed"` StpPathcost FlexInt `json:"stp_pathcost"` StpState string `json:"stp_state"` TxBroadcast FlexInt `json:"tx_broadcast"` TxBytes FlexInt `json:"tx_bytes"` TxDropped FlexInt `json:"tx_dropped"` TxErrors FlexInt `json:"tx_errors"` TxMulticast FlexInt `json:"tx_multicast"` TxPackets FlexInt `json:"tx_packets"` Up FlexBool `json:"up"` TxBytesR FlexInt `json:"tx_bytes-r"` RxBytesR FlexInt `json:"rx_bytes-r"` BytesR FlexInt `json:"bytes-r"` Name string `json:"name"` Masked FlexBool `json:"masked"` AggregatedBy FlexBool `json:"aggregated_by"` SfpFound FlexBool `json:"sfp_found,omitempty"` } `json:"port_table"` Serial string `json:"serial"` SiteID string `json:"site_id"` StpPriority string `json:"stp_priority"` StpVersion string `json:"stp_version"` Type string `json:"type"` Version string `json:"version"` RequiredVersion string `json:"required_version"` SwitchCaps struct { FeatureCaps FlexInt `json:"feature_caps"` MaxMirrorSessions FlexInt `json:"max_mirror_sessions"` MaxAggregateSessions FlexInt `json:"max_aggregate_sessions"` } `json:"switch_caps"` HwCaps FlexInt `json:"hw_caps"` Unsupported FlexBool `json:"unsupported"` UnsupportedReason FlexInt `json:"unsupported_reason"` SysErrorCaps FlexInt `json:"sys_error_caps"` 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 FlexInt `json:"cpu"` Mem FlexInt `json:"mem"` Uptime FlexInt `json:"uptime"` } `json:"system-stats"` FanLevel FlexInt `json:"fan_level"` GeneralTemperature FlexInt `json:"general_temperature"` Overheating FlexBool `json:"overheating"` TotalMaxPower FlexInt `json:"total_max_power"` DownlinkTable []struct { PortIdx FlexInt `json:"port_idx"` Speed FlexInt `json:"speed"` FullDuplex FlexBool `json:"full_duplex"` Mac string `json:"mac"` } `json:"downlink_table"` Uplink struct { FullDuplex FlexBool `json:"full_duplex"` IP string `json:"ip"` Mac string `json:"mac"` Name string `json:"name"` Netmask string `json:"netmask"` NumPort FlexInt `json:"num_port"` RxBytes FlexInt `json:"rx_bytes"` 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"` TxDropped FlexInt `json:"tx_dropped"` TxErrors FlexInt `json:"tx_errors"` TxPackets FlexInt `json:"tx_packets"` Up FlexBool `json:"up"` PortIdx FlexInt `json:"port_idx"` Media string `json:"media"` MaxSpeed FlexInt `json:"max_speed"` UplinkMac string `json:"uplink_mac"` Type string `json:"type"` TxBytesR FlexInt `json:"tx_bytes-r"` RxBytesR FlexInt `json:"rx_bytes-r"` } `json:"uplink"` LastUplink struct { UplinkMac string `json:"uplink_mac"` } `json:"last_uplink"` UplinkDepth FlexInt `json:"uplink_depth"` Stat *USWStat `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"` }
USW represents all the data from the Ubiquiti Controller for a Unifi Switch.
type USWStat ¶
type USWStat struct {
// contains filtered or unexported fields
}
USWStat holds the "stat" data for a switch. This is split out because of a JSON data format change from 5.10 to 5.11.
func (*USWStat) UnmarshalJSON ¶
UnmarshalJSON unmarshalls 5.10 or 5.11 formatted Switch Stat data.
type Unifi ¶
type Unifi struct { *http.Client ErrorLog Logger DebugLog Logger // contains filtered or unexported fields }
Unifi is what you get in return for providing a password! Unifi represents a controller that you can make authenticated requests to. Use this to make additional requests for devices, clients or other custom data. Do not set the loggers to nil. Set them to DiscardLogs if you want no logs.
func NewUnifi ¶
NewUnifi creates a http.Client with authenticated cookies. Used to make additional, authenticated requests to the APIs. Start here.
func (*Unifi) GetClients ¶
GetClients returns a response full of clients' data from the UniFi Controller.
func (*Unifi) GetData ¶
GetData makes a unifi request and unmarshal the response into a provided pointer.
func (*Unifi) GetDevices ¶
GetDevices returns a response full of devices' data from the UniFi Controller.
func (*Unifi) GetIDS ¶
GetIDS returns Intrusion Detection Systems events. Returns all events that happened in site between from and to.
func (*Unifi) GetSiteIDS ¶
GetSiteIDS is a helper to offload the for-loop work. This method retreives the Intrusion Detection System Data for 1 Site.