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