Merge pull request #22 from golift/dn2_client_update
Update client data.
This commit is contained in:
commit
36a47f5923
|
|
@ -1,7 +1,6 @@
|
|||
package unifi
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
influx "github.com/influxdata/influxdb1-client/v2"
|
||||
|
|
@ -13,8 +12,8 @@ func (c Client) Points() ([]*influx.Point, error) {
|
|||
// Fix name and hostname fields. Sometimes one or the other is blank.
|
||||
switch {
|
||||
case c.Hostname == "" && c.Name == "":
|
||||
c.Hostname = "-no-name-"
|
||||
c.Name = "-no-name-"
|
||||
c.Hostname = c.Mac
|
||||
c.Name = c.Mac
|
||||
case c.Hostname == "" && c.Name != "":
|
||||
c.Hostname = c.Name
|
||||
case c.Name == "" && c.Hostname != "":
|
||||
|
|
@ -40,13 +39,13 @@ func (c Client) Points() ([]*influx.Point, error) {
|
|||
"radio_proto": c.RadioProto,
|
||||
"name": c.Name,
|
||||
"fixed_ip": c.FixedIP,
|
||||
"sw_port": strconv.Itoa(c.SwPort),
|
||||
"os_class": strconv.Itoa(c.OsClass),
|
||||
"os_name": strconv.Itoa(c.OsName),
|
||||
"dev_cat": strconv.Itoa(c.DevCat),
|
||||
"dev_id": strconv.Itoa(c.DevID),
|
||||
"dev_family": strconv.Itoa(c.DevFamily),
|
||||
"authorized": c.Authorized.Txt,
|
||||
"sw_port": c.SwPort.Txt,
|
||||
"os_class": c.OsClass.Txt,
|
||||
"os_name": c.OsName.Txt,
|
||||
"dev_cat": c.DevCat.Txt,
|
||||
"dev_id": c.DevID.Txt,
|
||||
"dev_vendor": c.DevVendor.Txt,
|
||||
"dev_family": c.DevFamily.Txt,
|
||||
"is_11r": c.Is11R.Txt,
|
||||
"is_wired": c.IsWired.Txt,
|
||||
"is_guest": c.IsGuest.Txt,
|
||||
|
|
@ -57,10 +56,11 @@ func (c Client) Points() ([]*influx.Point, error) {
|
|||
"powersave_enabled": c.PowersaveEnabled.Txt,
|
||||
"qos_policy_applied": c.QosPolicyApplied.Txt,
|
||||
"use_fixedip": c.UseFixedIP.Txt,
|
||||
"channel": strconv.Itoa(c.Channel),
|
||||
"vlan": strconv.Itoa(c.Vlan),
|
||||
"channel": c.Channel.Txt,
|
||||
"vlan": c.Vlan.Txt,
|
||||
}
|
||||
fields := map[string]interface{}{
|
||||
"anomalies": c.Anomalies,
|
||||
"ip": c.IP,
|
||||
"essid": c.Essid,
|
||||
"bssid": c.Bssid,
|
||||
|
|
@ -95,6 +95,7 @@ func (c Client) Points() ([]*influx.Point, error) {
|
|||
"tx_power": c.TxPower,
|
||||
"tx_rate": c.TxRate,
|
||||
"uptime": c.Uptime,
|
||||
"wifi_tx_attempts": c.WifiTxAttempts,
|
||||
"wired-rx_bytes": c.WiredRxBytes,
|
||||
"wired-rx_bytes-r": c.WiredRxBytesR,
|
||||
"wired-rx_packets": c.WiredRxPackets,
|
||||
|
|
|
|||
|
|
@ -5,28 +5,21 @@ type Clients []Client
|
|||
|
||||
// Client defines all the data a connected-network client contains.
|
||||
type Client struct {
|
||||
ID string `json:"_id"`
|
||||
IsGuestByUAP FlexBool `json:"_is_guest_by_uap"`
|
||||
IsGuestByUGW FlexBool `json:"_is_guest_by_ugw"`
|
||||
IsGuestByUSW FlexBool `json:"_is_guest_by_usw"`
|
||||
LastSeenByUAP int64 `json:"_last_seen_by_uap"`
|
||||
LastSeenByUGW int64 `json:"_last_seen_by_ugw"`
|
||||
LastSeenByUSW int64 `json:"_last_seen_by_usw"`
|
||||
UptimeByUAP int64 `json:"_uptime_by_uap"`
|
||||
UptimeByUGW int64 `json:"_uptime_by_ugw"`
|
||||
UptimeByUSW int64 `json:"_uptime_by_usw"`
|
||||
ApMac string `json:"ap_mac"`
|
||||
ApName string `json:"-"`
|
||||
AssocTime int64 `json:"assoc_time"`
|
||||
Authorized FlexBool `json:"authorized"`
|
||||
Bssid string `json:"bssid"`
|
||||
BytesR int64 `json:"bytes-r"`
|
||||
Ccq int64 `json:"ccq"`
|
||||
Channel int `json:"channel"`
|
||||
DevCat int `json:"dev_cat"`
|
||||
DevFamily int `json:"dev_family"`
|
||||
DevID int `json:"dev_id"`
|
||||
DpiStats 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
|
||||
|
|
@ -38,15 +31,22 @@ type Client struct {
|
|||
Essid string `json:"essid"`
|
||||
FirstSeen int64 `json:"first_seen"`
|
||||
FixedIP string `json:"fixed_ip"`
|
||||
Hostname string `json:"hostname"`
|
||||
GwMac string `json:"gw_mac"`
|
||||
GwName string `json:"-"`
|
||||
IdleTime int64 `json:"idle_time"`
|
||||
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"`
|
||||
|
|
@ -55,8 +55,8 @@ type Client struct {
|
|||
Noise int64 `json:"noise"`
|
||||
Note string `json:"note"`
|
||||
Noted FlexBool `json:"noted"`
|
||||
OsClass int `json:"os_class"`
|
||||
OsName int `json:"os_name"`
|
||||
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"`
|
||||
|
|
@ -75,17 +75,21 @@ type Client struct {
|
|||
SwDepth int `json:"sw_depth"`
|
||||
SwMac string `json:"sw_mac"`
|
||||
SwName string `json:"-"`
|
||||
SwPort int `json:"sw_port"`
|
||||
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"`
|
||||
UserID string `json:"user_id"`
|
||||
UserGroupID string `json:"usergroup_id"`
|
||||
UptimeByUAP int64 `json:"_uptime_by_uap"`
|
||||
UptimeByUGW int64 `json:"_uptime_by_ugw"`
|
||||
UptimeByUSW int64 `json:"_uptime_by_usw"`
|
||||
UseFixedIP FlexBool `json:"use_fixedip"`
|
||||
Vlan int `json:"vlan"`
|
||||
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"`
|
||||
|
|
|
|||
Loading…
Reference in New Issue