remove a bunch of unused things from influx code
This commit is contained in:
parent
25e5f1c4b6
commit
f9a4963b23
|
|
@ -11,97 +11,79 @@ import (
|
||||||
// These points can be passed directly to influx.
|
// These points can be passed directly to influx.
|
||||||
func ClientPoints(c *unifi.Client, now time.Time) ([]*influx.Point, error) {
|
func ClientPoints(c *unifi.Client, now time.Time) ([]*influx.Point, error) {
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": c.ID,
|
"id": c.ID,
|
||||||
"mac": c.Mac,
|
"mac": c.Mac,
|
||||||
"user_id": c.UserID,
|
"user_id": c.UserID,
|
||||||
"site_id": c.SiteID,
|
"site_id": c.SiteID,
|
||||||
"site_name": c.SiteName,
|
"site_name": c.SiteName,
|
||||||
"network_id": c.NetworkID,
|
"ap_mac": c.ApMac,
|
||||||
"usergroup_id": c.UserGroupID,
|
"gw_mac": c.GwMac,
|
||||||
"ap_mac": c.ApMac,
|
"sw_mac": c.SwMac,
|
||||||
"gw_mac": c.GwMac,
|
"ap_name": c.ApName,
|
||||||
"sw_mac": c.SwMac,
|
"gw_name": c.GwName,
|
||||||
"ap_name": c.ApName,
|
"sw_name": c.SwName,
|
||||||
"gw_name": c.GwName,
|
"oui": c.Oui,
|
||||||
"sw_name": c.SwName,
|
"radio_name": c.RadioName,
|
||||||
"oui": c.Oui,
|
"radio": c.Radio,
|
||||||
"radio_name": c.RadioName,
|
"radio_proto": c.RadioProto,
|
||||||
"radio": c.Radio,
|
"name": c.Name,
|
||||||
"radio_proto": c.RadioProto,
|
"fixed_ip": c.FixedIP,
|
||||||
"name": c.Name,
|
"sw_port": c.SwPort.Txt,
|
||||||
"fixed_ip": c.FixedIP,
|
"os_class": c.OsClass.Txt,
|
||||||
"sw_port": c.SwPort.Txt,
|
"os_name": c.OsName.Txt,
|
||||||
"os_class": c.OsClass.Txt,
|
"dev_cat": c.DevCat.Txt,
|
||||||
"os_name": c.OsName.Txt,
|
"dev_id": c.DevID.Txt,
|
||||||
"dev_cat": c.DevCat.Txt,
|
"dev_vendor": c.DevVendor.Txt,
|
||||||
"dev_id": c.DevID.Txt,
|
"dev_family": c.DevFamily.Txt,
|
||||||
"dev_vendor": c.DevVendor.Txt,
|
"is_wired": c.IsWired.Txt,
|
||||||
"dev_family": c.DevFamily.Txt,
|
"is_guest": c.IsGuest.Txt,
|
||||||
"is_11r": c.Is11R.Txt,
|
"use_fixedip": c.UseFixedIP.Txt,
|
||||||
"is_wired": c.IsWired.Txt,
|
"channel": c.Channel.Txt,
|
||||||
"is_guest": c.IsGuest.Txt,
|
"vlan": c.Vlan.Txt,
|
||||||
"is_guest_by_uap": c.IsGuestByUAP.Txt,
|
|
||||||
"is_guest_by_ugw": c.IsGuestByUGW.Txt,
|
|
||||||
"is_guest_by_usw": c.IsGuestByUSW.Txt,
|
|
||||||
"noted": c.Noted.Txt,
|
|
||||||
"powersave_enabled": c.PowersaveEnabled.Txt,
|
|
||||||
"qos_policy_applied": c.QosPolicyApplied.Txt,
|
|
||||||
"use_fixedip": c.UseFixedIP.Txt,
|
|
||||||
"channel": c.Channel.Txt,
|
|
||||||
"vlan": c.Vlan.Txt,
|
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"anomalies": c.Anomalies,
|
"anomalies": c.Anomalies,
|
||||||
"ip": c.IP,
|
"ip": c.IP,
|
||||||
"essid": c.Essid,
|
"essid": c.Essid,
|
||||||
"bssid": c.Bssid,
|
"bssid": c.Bssid,
|
||||||
"radio_desc": c.RadioDescription,
|
"radio_desc": c.RadioDescription,
|
||||||
"satisfaction": c.Satisfaction.Val,
|
"satisfaction": c.Satisfaction.Val,
|
||||||
"hostname": c.Hostname,
|
"hostname": c.Hostname,
|
||||||
"dpi_stats_last_updated": c.DpiStatsLastUpdated,
|
"bytes_r": c.BytesR,
|
||||||
"last_seen_by_uap": c.LastSeenByUAP,
|
"ccq": c.Ccq,
|
||||||
"last_seen_by_ugw": c.LastSeenByUGW,
|
"first_seen": c.FirstSeen,
|
||||||
"last_seen_by_usw": c.LastSeenByUSW,
|
"idle_time": c.IdleTime,
|
||||||
"uptime_by_uap": c.UptimeByUAP,
|
"last_seen": c.LastSeen,
|
||||||
"uptime_by_ugw": c.UptimeByUGW,
|
"network": c.Network,
|
||||||
"uptime_by_usw": c.UptimeByUSW,
|
"noise": c.Noise,
|
||||||
"assoc_time": c.AssocTime,
|
"note": c.Note,
|
||||||
"bytes_r": c.BytesR,
|
"roam_count": c.RoamCount,
|
||||||
"ccq": c.Ccq,
|
"rssi": c.Rssi,
|
||||||
"first_seen": c.FirstSeen,
|
"rx_bytes": c.RxBytes,
|
||||||
"idle_time": c.IdleTime,
|
"rx_bytes_r": c.RxBytesR,
|
||||||
"last_seen": c.LastSeen,
|
"rx_packets": c.RxPackets,
|
||||||
"latest_assoc_time": c.LatestAssocTime,
|
"rx_rate": c.RxRate,
|
||||||
"network": c.Network,
|
"signal": c.Signal,
|
||||||
"noise": c.Noise,
|
"tx_bytes": c.TxBytes,
|
||||||
"note": c.Note,
|
"tx_bytes_r": c.TxBytesR,
|
||||||
"roam_count": c.RoamCount,
|
"tx_packets": c.TxPackets,
|
||||||
"rssi": c.Rssi,
|
"tx_retries": c.TxRetries,
|
||||||
"rx_bytes": c.RxBytes,
|
"tx_power": c.TxPower,
|
||||||
"rx_bytes_r": c.RxBytesR,
|
"tx_rate": c.TxRate,
|
||||||
"rx_packets": c.RxPackets,
|
"uptime": c.Uptime,
|
||||||
"rx_rate": c.RxRate,
|
"wifi_tx_attempts": c.WifiTxAttempts,
|
||||||
"signal": c.Signal,
|
"wired-rx_bytes": c.WiredRxBytes,
|
||||||
"tx_bytes": c.TxBytes,
|
"wired-rx_bytes-r": c.WiredRxBytesR,
|
||||||
"tx_bytes_r": c.TxBytesR,
|
"wired-rx_packets": c.WiredRxPackets,
|
||||||
"tx_packets": c.TxPackets,
|
"wired-tx_bytes": c.WiredTxBytes,
|
||||||
"tx_retries": c.TxRetries,
|
"wired-tx_bytes-r": c.WiredTxBytesR,
|
||||||
"tx_power": c.TxPower,
|
"wired-tx_packets": c.WiredTxPackets,
|
||||||
"tx_rate": c.TxRate,
|
"dpi_app": c.DpiStats.App.Val,
|
||||||
"uptime": c.Uptime,
|
"dpi_cat": c.DpiStats.Cat.Val,
|
||||||
"wifi_tx_attempts": c.WifiTxAttempts,
|
"dpi_rx_bytes": c.DpiStats.RxBytes.Val,
|
||||||
"wired-rx_bytes": c.WiredRxBytes,
|
"dpi_rx_packets": c.DpiStats.RxPackets.Val,
|
||||||
"wired-rx_bytes-r": c.WiredRxBytesR,
|
"dpi_tx_bytes": c.DpiStats.TxBytes.Val,
|
||||||
"wired-rx_packets": c.WiredRxPackets,
|
"dpi_tx_packets": c.DpiStats.TxPackets.Val,
|
||||||
"wired-tx_bytes": c.WiredTxBytes,
|
|
||||||
"wired-tx_bytes-r": c.WiredTxBytesR,
|
|
||||||
"wired-tx_packets": c.WiredTxPackets,
|
|
||||||
"dpi_app": c.DpiStats.App.Val,
|
|
||||||
"dpi_cat": c.DpiStats.Cat.Val,
|
|
||||||
"dpi_rx_bytes": c.DpiStats.RxBytes.Val,
|
|
||||||
"dpi_rx_packets": c.DpiStats.RxPackets.Val,
|
|
||||||
"dpi_tx_bytes": c.DpiStats.TxBytes.Val,
|
|
||||||
"dpi_tx_packets": c.DpiStats.TxPackets.Val,
|
|
||||||
}
|
}
|
||||||
pt, err := influx.NewPoint("clients", tags, fields, now)
|
pt, err := influx.NewPoint("clients", tags, fields, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -14,36 +14,27 @@ func SitePoints(u *unifi.Site, now time.Time) ([]*influx.Point, error) {
|
||||||
points := []*influx.Point{}
|
points := []*influx.Point{}
|
||||||
for _, s := range u.Health {
|
for _, s := range u.Health {
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": u.ID,
|
"name": u.Name,
|
||||||
"name": u.Name,
|
"site_name": u.SiteName,
|
||||||
"site_name": u.SiteName,
|
"desc": u.Desc,
|
||||||
"desc": u.Desc,
|
"status": s.Status,
|
||||||
"status": s.Status,
|
"subsystem": s.Subsystem,
|
||||||
"subsystem": s.Subsystem,
|
"wan_ip": s.WanIP,
|
||||||
"wan_ip": s.WanIP,
|
"netmask": s.Netmask,
|
||||||
"netmask": s.Netmask,
|
"gw_name": s.GwName,
|
||||||
"gw_name": s.GwName,
|
"gw_mac": s.GwMac,
|
||||||
"gw_mac": s.GwMac,
|
"gw_version": s.GwVersion,
|
||||||
"gw_version": s.GwVersion,
|
"lan_ip": s.LanIP,
|
||||||
"speedtest_status": s.SpeedtestStatus,
|
"nameservers": strings.Join(s.Nameservers, ","),
|
||||||
"lan_ip": s.LanIP,
|
"gateways": strings.Join(s.Gateways, ","),
|
||||||
"remote_user_enabled": s.RemoteUserEnabled.Txt,
|
"num_new_alarms": u.NumNewAlarms.Txt,
|
||||||
"site_to_site_enabled": s.SiteToSiteEnabled.Txt,
|
|
||||||
"nameservers": strings.Join(s.Nameservers, ","),
|
|
||||||
"gateways": strings.Join(s.Gateways, ","),
|
|
||||||
"num_new_alarms": u.NumNewAlarms.Txt,
|
|
||||||
"attr_hidden_id": u.AttrHiddenID,
|
|
||||||
"attr_no_delete": u.AttrNoDelete.Txt,
|
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"attr_hidden_id": u.AttrHiddenID,
|
|
||||||
"attr_no_delete": u.AttrNoDelete.Val,
|
|
||||||
"num_user": s.NumUser.Val,
|
"num_user": s.NumUser.Val,
|
||||||
"num_guest": s.NumGuest.Val,
|
"num_guest": s.NumGuest.Val,
|
||||||
"num_iot": s.NumIot.Val,
|
"num_iot": s.NumIot.Val,
|
||||||
"tx_bytes-r": s.TxBytesR.Val,
|
"tx_bytes-r": s.TxBytesR.Val,
|
||||||
"rx_bytes-r": s.RxBytesR.Val,
|
"rx_bytes-r": s.RxBytesR.Val,
|
||||||
"status": s.Status,
|
|
||||||
"num_ap": s.NumAp.Val,
|
"num_ap": s.NumAp.Val,
|
||||||
"num_adopted": s.NumAdopted.Val,
|
"num_adopted": s.NumAdopted.Val,
|
||||||
"num_disabled": s.NumDisabled.Val,
|
"num_disabled": s.NumDisabled.Val,
|
||||||
|
|
|
||||||
|
|
@ -14,27 +14,15 @@ func UAPPoints(u *unifi.UAP, now time.Time) ([]*influx.Point, error) {
|
||||||
u.Stat.Ap = &unifi.Ap{}
|
u.Stat.Ap = &unifi.Ap{}
|
||||||
}
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": u.ID,
|
"ip": u.IP,
|
||||||
"ip": u.IP,
|
"mac": u.Mac,
|
||||||
"mac": u.Mac,
|
"site_id": u.SiteID,
|
||||||
"device_type": u.Stat.Ap.O,
|
"site_name": u.SiteName,
|
||||||
"device_oid": u.Stat.Ap.Oid,
|
"name": u.Name,
|
||||||
"device_ap": u.Stat.Ap.Ap,
|
"cfgversion": u.Cfgversion,
|
||||||
"site_id": u.SiteID,
|
"model": u.Model,
|
||||||
"site_name": u.SiteName,
|
"serial": u.Serial,
|
||||||
"name": u.Name,
|
"type": u.Type,
|
||||||
"adopted": u.Adopted.Txt,
|
|
||||||
"cfgversion": u.Cfgversion,
|
|
||||||
"config_network_ip": u.ConfigNetwork.IP,
|
|
||||||
"config_network_type": u.ConfigNetwork.Type,
|
|
||||||
"connect_request_ip": u.ConnectRequestIP,
|
|
||||||
"device_id": u.DeviceID,
|
|
||||||
"has_eth1": u.HasEth1.Txt,
|
|
||||||
"inform_ip": u.InformIP,
|
|
||||||
"known_cfgversion": u.KnownCfgversion,
|
|
||||||
"model": u.Model,
|
|
||||||
"serial": u.Serial,
|
|
||||||
"type": u.Type,
|
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"ip": u.IP,
|
"ip": u.IP,
|
||||||
|
|
@ -47,7 +35,6 @@ func UAPPoints(u *unifi.UAP, now time.Time) ([]*influx.Point, error) {
|
||||||
"user-num_sta": int(u.UserNumSta.Val),
|
"user-num_sta": int(u.UserNumSta.Val),
|
||||||
"guest-num_sta": int(u.GuestNumSta.Val),
|
"guest-num_sta": int(u.GuestNumSta.Val),
|
||||||
"num_sta": u.NumSta.Val,
|
"num_sta": u.NumSta.Val,
|
||||||
"version": u.Version,
|
|
||||||
"loadavg_1": u.SysStats.Loadavg1.Val,
|
"loadavg_1": u.SysStats.Loadavg1.Val,
|
||||||
"loadavg_5": u.SysStats.Loadavg5.Val,
|
"loadavg_5": u.SysStats.Loadavg5.Val,
|
||||||
"loadavg_15": u.SysStats.Loadavg15.Val,
|
"loadavg_15": u.SysStats.Loadavg15.Val,
|
||||||
|
|
@ -95,7 +82,7 @@ func UAPPoints(u *unifi.UAP, now time.Time) ([]*influx.Point, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
morePoints, err := processVAPs(u.VapTable, u.RadioTable, u.RadioTableStats, u.Name, u.ID, u.Mac, u.SiteName, now)
|
morePoints, err := processVAPs(u.VapTable, u.RadioTable, u.RadioTableStats, u.Name, u.Mac, u.SiteName, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +90,7 @@ func UAPPoints(u *unifi.UAP, now time.Time) ([]*influx.Point, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// processVAPs creates points for Wifi Radios. This works with several types of UAP-capable devices.
|
// processVAPs creates points for Wifi Radios. This works with several types of UAP-capable devices.
|
||||||
func processVAPs(vt unifi.VapTable, rt unifi.RadioTable, rts unifi.RadioTableStats, name, id, mac, sitename string, ts time.Time) ([]*influx.Point, error) {
|
func processVAPs(vt unifi.VapTable, rt unifi.RadioTable, rts unifi.RadioTableStats, name, mac, sitename string, ts time.Time) ([]*influx.Point, error) {
|
||||||
tags := make(map[string]string)
|
tags := make(map[string]string)
|
||||||
fields := make(map[string]interface{})
|
fields := make(map[string]interface{})
|
||||||
points := []*influx.Point{}
|
points := []*influx.Point{}
|
||||||
|
|
@ -112,7 +99,6 @@ func processVAPs(vt unifi.VapTable, rt unifi.RadioTable, rts unifi.RadioTableSta
|
||||||
// from radio_tables and radio_table_stats.
|
// from radio_tables and radio_table_stats.
|
||||||
for _, s := range vt {
|
for _, s := range vt {
|
||||||
tags["device_name"] = name
|
tags["device_name"] = name
|
||||||
tags["device_id"] = id
|
|
||||||
tags["device_mac"] = mac
|
tags["device_mac"] = mac
|
||||||
tags["site_name"] = sitename
|
tags["site_name"] = sitename
|
||||||
tags["ap_mac"] = s.ApMac
|
tags["ap_mac"] = s.ApMac
|
||||||
|
|
@ -120,13 +106,11 @@ func processVAPs(vt unifi.VapTable, rt unifi.RadioTable, rts unifi.RadioTableSta
|
||||||
tags["id"] = s.ID
|
tags["id"] = s.ID
|
||||||
tags["name"] = s.Name
|
tags["name"] = s.Name
|
||||||
tags["radio_name"] = s.RadioName
|
tags["radio_name"] = s.RadioName
|
||||||
tags["wlanconf_id"] = s.WlanconfID
|
|
||||||
tags["essid"] = s.Essid
|
tags["essid"] = s.Essid
|
||||||
tags["site_id"] = s.SiteID
|
tags["site_id"] = s.SiteID
|
||||||
tags["usage"] = s.Usage
|
tags["usage"] = s.Usage
|
||||||
tags["state"] = s.State
|
tags["state"] = s.State
|
||||||
tags["is_guest"] = s.IsGuest.Txt
|
tags["is_guest"] = s.IsGuest.Txt
|
||||||
tags["is_wep"] = s.IsWep.Txt
|
|
||||||
|
|
||||||
fields["ccq"] = s.Ccq
|
fields["ccq"] = s.Ccq
|
||||||
fields["extchannel"] = s.Extchannel
|
fields["extchannel"] = s.Extchannel
|
||||||
|
|
@ -171,13 +155,11 @@ func processVAPs(vt unifi.VapTable, rt unifi.RadioTable, rts unifi.RadioTableSta
|
||||||
if p.Name != s.RadioName {
|
if p.Name != s.RadioName {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tags["wlangroup_id"] = p.WlangroupID
|
|
||||||
tags["channel"] = p.Channel.Txt
|
tags["channel"] = p.Channel.Txt
|
||||||
tags["radio"] = p.Radio
|
tags["radio"] = p.Radio
|
||||||
fields["current_antenna_gain"] = p.CurrentAntennaGain.Val
|
fields["current_antenna_gain"] = p.CurrentAntennaGain.Val
|
||||||
fields["ht"] = p.Ht.Txt
|
fields["ht"] = p.Ht.Txt
|
||||||
fields["max_txpower"] = p.MaxTxpower.Val
|
fields["max_txpower"] = p.MaxTxpower.Val
|
||||||
fields["min_rssi_enabled"] = p.MinRssiEnabled.Val
|
|
||||||
fields["min_txpower"] = p.MinTxpower.Val
|
fields["min_txpower"] = p.MinTxpower.Val
|
||||||
fields["nss"] = p.Nss.Val
|
fields["nss"] = p.Nss.Val
|
||||||
fields["radio_caps"] = p.RadioCaps.Val
|
fields["radio_caps"] = p.RadioCaps.Val
|
||||||
|
|
|
||||||
|
|
@ -17,29 +17,20 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
u.Stat.Gw = &unifi.Gw{}
|
u.Stat.Gw = &unifi.Gw{}
|
||||||
}
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": u.ID,
|
"id": u.ID,
|
||||||
"mac": u.Mac,
|
"mac": u.Mac,
|
||||||
"device_oid": u.Stat.Gw.Oid,
|
"site_id": u.SiteID,
|
||||||
"site_id": u.SiteID,
|
"site_name": u.SiteName,
|
||||||
"site_name": u.SiteName,
|
"name": u.Name,
|
||||||
"adopted": u.Adopted.Txt,
|
"cfgversion": u.Cfgversion,
|
||||||
"name": u.Name,
|
"device_id": u.DeviceID,
|
||||||
"cfgversion": u.Cfgversion,
|
"known_cfgversion": u.KnownCfgversion,
|
||||||
"config_network_ip": u.ConfigNetwork.IP,
|
"model": u.Model,
|
||||||
"config_network_type": u.ConfigNetwork.Type,
|
"serial": u.Serial,
|
||||||
"connect_request_ip": u.ConnectRequestIP,
|
"type": u.Type,
|
||||||
"connect_request_port": u.ConnectRequestPort,
|
"usg_caps": u.UsgCaps.Txt,
|
||||||
"device_id": u.DeviceID,
|
"wan1_up": u.Wan1.Up.Txt,
|
||||||
"guest_token": u.GuestToken,
|
"wan2_up": u.Wan2.Up.Txt,
|
||||||
"inform_ip": u.InformIP,
|
|
||||||
"known_cfgversion": u.KnownCfgversion,
|
|
||||||
"model": u.Model,
|
|
||||||
"serial": u.Serial,
|
|
||||||
"type": u.Type,
|
|
||||||
"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{}{
|
fields := map[string]interface{}{
|
||||||
"ip": u.IP,
|
"ip": u.IP,
|
||||||
|
|
@ -147,29 +138,16 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
}
|
}
|
||||||
points := []*influx.Point{pt}
|
points := []*influx.Point{pt}
|
||||||
tags = map[string]string{
|
tags = map[string]string{
|
||||||
"id": u.ID,
|
"id": u.ID,
|
||||||
"mac": u.Mac,
|
"mac": u.Mac,
|
||||||
"device_oid": u.Stat.Sw.Oid,
|
"site_id": u.SiteID,
|
||||||
"site_id": u.SiteID,
|
"site_name": u.SiteName,
|
||||||
"site_name": u.SiteName,
|
"name": u.Name,
|
||||||
"name": u.Name,
|
"model": u.Model,
|
||||||
"adopted": u.Adopted.Txt,
|
"serial": u.Serial,
|
||||||
"cfgversion": u.Cfgversion,
|
"type": u.Type,
|
||||||
"config_network_ip": u.ConfigNetwork.IP,
|
"has_fan": u.HasFan.Txt,
|
||||||
"config_network_type": u.ConfigNetwork.Type,
|
"has_temperature": u.HasTemperature.Txt,
|
||||||
"device_id": u.DeviceID,
|
|
||||||
"inform_ip": u.InformIP,
|
|
||||||
"known_cfgversion": u.KnownCfgversion,
|
|
||||||
"locating": u.Locating.Txt,
|
|
||||||
"model": u.Model,
|
|
||||||
"serial": u.Serial,
|
|
||||||
"type": u.Type,
|
|
||||||
"dot1x_portctrl_enabled": u.Dot1XPortctrlEnabled.Txt,
|
|
||||||
"flowctrl_enabled": u.FlowctrlEnabled.Txt,
|
|
||||||
"has_fan": u.HasFan.Txt,
|
|
||||||
"has_temperature": u.HasTemperature.Txt,
|
|
||||||
"jumboframe_enabled": u.JumboframeEnabled.Txt,
|
|
||||||
"stp_version": u.StpVersion,
|
|
||||||
}
|
}
|
||||||
fields = map[string]interface{}{
|
fields = map[string]interface{}{
|
||||||
"fw_caps": u.FwCaps.Val,
|
"fw_caps": u.FwCaps.Val,
|
||||||
|
|
@ -219,23 +197,19 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
|
|
||||||
for _, p := range u.NetworkTable {
|
for _, p := range u.NetworkTable {
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"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,
|
"site_name": u.SiteName,
|
||||||
"up": p.Up.Txt,
|
"up": p.Up.Txt,
|
||||||
"dhcpd_dns_enabled": p.DhcpdDNSEnabled.Txt,
|
"enabled": p.Enabled.Txt,
|
||||||
"dhcpd_enabled": p.DhcpdEnabled.Txt,
|
"site_id": p.SiteID,
|
||||||
"dhcpd_time_offset_enabled": p.DhcpdTimeOffsetEnabled.Txt,
|
"ip": p.IP,
|
||||||
"dhcp_relay_enabledy": p.DhcpRelayEnabled.Txt,
|
"ip_subnet": p.IPSubnet,
|
||||||
"dhcpd_gateway_enabled": p.DhcpdGatewayEnabled.Txt,
|
"mac": p.Mac,
|
||||||
"enabled": p.Enabled.Txt,
|
"name": p.Name,
|
||||||
"vlan_enabled": p.VlanEnabled.Txt,
|
"domain_name": p.DomainName,
|
||||||
"attr_no_delete": p.AttrNoDelete.Txt,
|
"purpose": p.Purpose,
|
||||||
"is_guest": p.IsGuest.Txt,
|
|
||||||
"is_nat": p.IsNat.Txt,
|
|
||||||
"networkgroup": p.Networkgroup,
|
|
||||||
"site_id": p.SiteID,
|
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"domain_name": p.DomainName,
|
"domain_name": p.DomainName,
|
||||||
|
|
@ -263,35 +237,21 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
|
|
||||||
for _, p := range u.PortTable {
|
for _, p := range u.PortTable {
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"site_id": u.SiteID,
|
"site_id": u.SiteID,
|
||||||
"site_name": u.SiteName,
|
"site_name": u.SiteName,
|
||||||
"device_name": u.Name,
|
"device_name": u.Name,
|
||||||
"name": p.Name,
|
"name": p.Name,
|
||||||
"enable": p.Enable.Txt,
|
"enable": p.Enable.Txt,
|
||||||
"is_uplink": p.IsUplink.Txt,
|
"up": p.Up.Txt,
|
||||||
"up": p.Up.Txt,
|
"poe_mode": p.PoeMode,
|
||||||
"portconf_id": p.PortconfID,
|
"port_poe": p.PortPoe.Txt,
|
||||||
"dot1x_mode": p.Dot1XMode,
|
"port_idx": p.PortIdx.Txt,
|
||||||
"dot1x_status": p.Dot1XStatus,
|
"port_id": u.Name + " Port " + p.PortIdx.Txt,
|
||||||
"stp_state": p.StpState,
|
"poe_enable": p.PoeEnable.Txt,
|
||||||
"sfp_found": p.SfpFound.Txt,
|
"flowctrl_rx": p.FlowctrlRx.Txt,
|
||||||
"op_mode": p.OpMode,
|
"flowctrl_tx": p.FlowctrlTx.Txt,
|
||||||
"poe_mode": p.PoeMode,
|
"media": p.Media,
|
||||||
"port_poe": p.PortPoe.Txt,
|
"poe_class": p.PoeClass,
|
||||||
"port_idx": p.PortIdx.Txt,
|
|
||||||
"port_id": u.Name + " Port " + p.PortIdx.Txt,
|
|
||||||
"poe_enable": p.PoeEnable.Txt,
|
|
||||||
"flowctrl_rx": p.FlowctrlRx.Txt,
|
|
||||||
"flowctrl_tx": p.FlowctrlTx.Txt,
|
|
||||||
"autoneg": p.Autoneg.Txt,
|
|
||||||
"full_duplex": p.FullDuplex.Txt,
|
|
||||||
"jumbo": p.Jumbo.Txt,
|
|
||||||
"masked": p.Masked.Txt,
|
|
||||||
"poe_good": p.PoeGood.Txt,
|
|
||||||
"media": p.Media,
|
|
||||||
"poe_class": p.PoeClass,
|
|
||||||
"poe_caps": p.PoeCaps.Txt,
|
|
||||||
"aggregated_by": p.AggregatedBy.Txt,
|
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"dbytes_r": p.BytesR.Val,
|
"dbytes_r": p.BytesR.Val,
|
||||||
|
|
@ -314,7 +274,6 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
"poe_current": p.PoeCurrent.Val,
|
"poe_current": p.PoeCurrent.Val,
|
||||||
"poe_power": p.PoePower.Val,
|
"poe_power": p.PoePower.Val,
|
||||||
"poe_voltage": p.PoeVoltage.Val,
|
"poe_voltage": p.PoeVoltage.Val,
|
||||||
"full_duplex": p.FullDuplex.Val,
|
|
||||||
}
|
}
|
||||||
pt, err = influx.NewPoint("usw_ports", tags, fields, now)
|
pt, err = influx.NewPoint("usw_ports", tags, fields, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -327,27 +286,15 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
// we're done now. the following code process UDM (non-pro) UAP data.
|
// we're done now. the following code process UDM (non-pro) UAP data.
|
||||||
}
|
}
|
||||||
tags = map[string]string{
|
tags = map[string]string{
|
||||||
"id": u.ID,
|
"ip": u.IP,
|
||||||
"ip": u.IP,
|
"mac": u.Mac,
|
||||||
"mac": u.Mac,
|
"site_id": u.SiteID,
|
||||||
"device_type": u.Stat.Ap.O,
|
"site_name": u.SiteName,
|
||||||
"device_oid": u.Stat.Ap.Oid,
|
"name": u.Name,
|
||||||
"device_ap": u.Stat.Ap.Ap,
|
"cfgversion": u.Cfgversion,
|
||||||
"site_id": u.SiteID,
|
"model": u.Model,
|
||||||
"site_name": u.SiteName,
|
"serial": u.Serial,
|
||||||
"name": u.Name,
|
"type": u.Type,
|
||||||
"adopted": u.Adopted.Txt,
|
|
||||||
"cfgversion": u.Cfgversion,
|
|
||||||
"config_network_ip": u.ConfigNetwork.IP,
|
|
||||||
"config_network_type": u.ConfigNetwork.Type,
|
|
||||||
"connect_request_ip": u.ConnectRequestIP,
|
|
||||||
"device_id": u.DeviceID,
|
|
||||||
"has_eth1": u.HasEth1.Txt,
|
|
||||||
"inform_ip": u.InformIP,
|
|
||||||
"known_cfgversion": u.KnownCfgversion,
|
|
||||||
"model": u.Model,
|
|
||||||
"serial": u.Serial,
|
|
||||||
"type": u.Type,
|
|
||||||
}
|
}
|
||||||
fields = map[string]interface{}{
|
fields = map[string]interface{}{
|
||||||
"ip": u.IP,
|
"ip": u.IP,
|
||||||
|
|
@ -360,7 +307,6 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
"user-num_sta": int(u.UserWlanNumSta.Val),
|
"user-num_sta": int(u.UserWlanNumSta.Val),
|
||||||
"guest-num_sta": int(u.GuestWlanNumSta.Val),
|
"guest-num_sta": int(u.GuestWlanNumSta.Val),
|
||||||
"num_sta": u.WlanNumSta.Val,
|
"num_sta": u.WlanNumSta.Val,
|
||||||
"version": u.Version,
|
|
||||||
"loadavg_1": u.SysStats.Loadavg1.Val,
|
"loadavg_1": u.SysStats.Loadavg1.Val,
|
||||||
"loadavg_5": u.SysStats.Loadavg5.Val,
|
"loadavg_5": u.SysStats.Loadavg5.Val,
|
||||||
"loadavg_15": u.SysStats.Loadavg15.Val,
|
"loadavg_15": u.SysStats.Loadavg15.Val,
|
||||||
|
|
@ -408,7 +354,7 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uapPoints, err := processVAPs(*u.VapTable, *u.RadioTable, *u.RadioTableStats, u.Name, u.ID, u.Mac, u.SiteName, now)
|
uapPoints, err := processVAPs(*u.VapTable, *u.RadioTable, *u.RadioTableStats, u.Name, u.Mac, u.SiteName, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,33 +15,21 @@ func USGPoints(u *unifi.USG, now time.Time) ([]*influx.Point, error) {
|
||||||
u.Stat.Gw = &unifi.Gw{}
|
u.Stat.Gw = &unifi.Gw{}
|
||||||
}
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": u.ID,
|
"id": u.ID,
|
||||||
"mac": u.Mac,
|
"mac": u.Mac,
|
||||||
"device_type": u.Stat.O,
|
"device_type": u.Stat.O,
|
||||||
"device_oid": u.Stat.Oid,
|
"site_id": u.SiteID,
|
||||||
"site_id": u.SiteID,
|
"site_name": u.SiteName,
|
||||||
"site_name": u.SiteName,
|
"name": u.Name,
|
||||||
"adopted": u.Adopted.Txt,
|
"cfgversion": u.Cfgversion,
|
||||||
"name": u.Name,
|
"device_id": u.DeviceID,
|
||||||
"cfgversion": u.Cfgversion,
|
"known_cfgversion": u.KnownCfgversion,
|
||||||
"config_network_ip": u.ConfigNetwork.IP,
|
"model": u.Model,
|
||||||
"config_network_type": u.ConfigNetwork.Type,
|
"serial": u.Serial,
|
||||||
"connect_request_ip": u.ConnectRequestIP,
|
"type": u.Type,
|
||||||
"connect_request_port": u.ConnectRequestPort,
|
"usg_caps": u.UsgCaps.Txt,
|
||||||
"device_id": u.DeviceID,
|
"wan1_up": u.Wan1.Up.Txt,
|
||||||
"guest_token": u.GuestToken,
|
"wan2_up": u.Wan2.Up.Txt,
|
||||||
"inform_ip": u.InformIP,
|
|
||||||
"known_cfgversion": u.KnownCfgversion,
|
|
||||||
"led_override": u.LedOverride,
|
|
||||||
"locating": u.Locating.Txt,
|
|
||||||
"model": u.Model,
|
|
||||||
"outdoor_mode_override": u.OutdoorModeOverride,
|
|
||||||
"serial": u.Serial,
|
|
||||||
"type": u.Type,
|
|
||||||
"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{}{
|
fields := map[string]interface{}{
|
||||||
"ip": u.IP,
|
"ip": u.IP,
|
||||||
|
|
@ -153,33 +141,19 @@ func USGPoints(u *unifi.USG, now time.Time) ([]*influx.Point, error) {
|
||||||
points := []*influx.Point{pt}
|
points := []*influx.Point{pt}
|
||||||
for _, p := range u.NetworkTable {
|
for _, p := range u.NetworkTable {
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"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,
|
"site_name": u.SiteName,
|
||||||
"up": p.Up.Txt,
|
"up": p.Up.Txt,
|
||||||
"dhcpd_dns_enabled": p.DhcpdDNSEnabled.Txt,
|
"enabled": p.Enabled.Txt,
|
||||||
"dhcpd_enabled": p.DhcpdEnabled.Txt,
|
"site_id": p.SiteID,
|
||||||
"dhcpd_time_offset_enabled": p.DhcpdTimeOffsetEnabled.Txt,
|
"ip": p.IP,
|
||||||
"dhcp_relay_enabledy": p.DhcpRelayEnabled.Txt,
|
"ip_subnet": p.IPSubnet,
|
||||||
"dhcpd_gateway_enabled": p.DhcpdGatewayEnabled.Txt,
|
"mac": p.Mac,
|
||||||
"enabled": p.Enabled.Txt,
|
"name": p.Name,
|
||||||
"vlan_enabled": p.VlanEnabled.Txt,
|
"domain_name": p.DomainName,
|
||||||
"attr_no_delete": p.AttrNoDelete.Txt,
|
"purpose": p.Purpose,
|
||||||
"is_guest": p.IsGuest.Txt,
|
|
||||||
"is_nat": p.IsNat.Txt,
|
|
||||||
"networkgroup": p.Networkgroup,
|
|
||||||
"site_id": p.SiteID,
|
|
||||||
"ip": p.IP,
|
|
||||||
"ip_subnet": p.IPSubnet,
|
|
||||||
"mac": p.Mac,
|
|
||||||
"name": p.Name,
|
|
||||||
"domain_name": p.DomainName,
|
|
||||||
"dhcpd_start": p.DhcpdStart,
|
|
||||||
"dhcpd_stop": p.DhcpdStop,
|
|
||||||
"ipv6_interface_type": p.Ipv6InterfaceType,
|
|
||||||
"attr_hidden_id": p.AttrHiddenID,
|
|
||||||
"purpose": p.Purpose,
|
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"num_sta": p.NumSta.Val,
|
"num_sta": p.NumSta.Val,
|
||||||
|
|
|
||||||
|
|
@ -14,29 +14,16 @@ func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
|
||||||
u.Stat.Sw = &unifi.Sw{}
|
u.Stat.Sw = &unifi.Sw{}
|
||||||
}
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": u.ID,
|
"id": u.ID,
|
||||||
"mac": u.Mac,
|
"mac": u.Mac,
|
||||||
"device_oid": u.Stat.Oid,
|
"site_id": u.SiteID,
|
||||||
"site_id": u.SiteID,
|
"site_name": u.SiteName,
|
||||||
"site_name": u.SiteName,
|
"name": u.Name,
|
||||||
"name": u.Name,
|
"model": u.Model,
|
||||||
"adopted": u.Adopted.Txt,
|
"serial": u.Serial,
|
||||||
"cfgversion": u.Cfgversion,
|
"type": u.Type,
|
||||||
"config_network_ip": u.ConfigNetwork.IP,
|
"has_fan": u.HasFan.Txt,
|
||||||
"config_network_type": u.ConfigNetwork.Type,
|
"has_temperature": u.HasTemperature.Txt,
|
||||||
"device_id": u.DeviceID,
|
|
||||||
"inform_ip": u.InformIP,
|
|
||||||
"known_cfgversion": u.KnownCfgversion,
|
|
||||||
"locating": u.Locating.Txt,
|
|
||||||
"model": u.Model,
|
|
||||||
"serial": u.Serial,
|
|
||||||
"type": u.Type,
|
|
||||||
"dot1x_portctrl_enabled": u.Dot1XPortctrlEnabled.Txt,
|
|
||||||
"flowctrl_enabled": u.FlowctrlEnabled.Txt,
|
|
||||||
"has_fan": u.HasFan.Txt,
|
|
||||||
"has_temperature": u.HasTemperature.Txt,
|
|
||||||
"jumboframe_enabled": u.JumboframeEnabled.Txt,
|
|
||||||
"stp_version": u.StpVersion,
|
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"fw_caps": u.FwCaps.Val,
|
"fw_caps": u.FwCaps.Val,
|
||||||
|
|
@ -85,35 +72,21 @@ func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
|
||||||
points := []*influx.Point{pt}
|
points := []*influx.Point{pt}
|
||||||
for _, p := range u.PortTable {
|
for _, p := range u.PortTable {
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"site_id": u.SiteID,
|
"site_id": u.SiteID,
|
||||||
"site_name": u.SiteName,
|
"site_name": u.SiteName,
|
||||||
"device_name": u.Name,
|
"device_name": u.Name,
|
||||||
"name": p.Name,
|
"name": p.Name,
|
||||||
"enable": p.Enable.Txt,
|
"enable": p.Enable.Txt,
|
||||||
"is_uplink": p.IsUplink.Txt,
|
"up": p.Up.Txt,
|
||||||
"up": p.Up.Txt,
|
"poe_mode": p.PoeMode,
|
||||||
"portconf_id": p.PortconfID,
|
"port_poe": p.PortPoe.Txt,
|
||||||
"dot1x_mode": p.Dot1XMode,
|
"port_idx": p.PortIdx.Txt,
|
||||||
"dot1x_status": p.Dot1XStatus,
|
"port_id": u.Name + " Port " + p.PortIdx.Txt,
|
||||||
"stp_state": p.StpState,
|
"poe_enable": p.PoeEnable.Txt,
|
||||||
"sfp_found": p.SfpFound.Txt,
|
"flowctrl_rx": p.FlowctrlRx.Txt,
|
||||||
"op_mode": p.OpMode,
|
"flowctrl_tx": p.FlowctrlTx.Txt,
|
||||||
"poe_mode": p.PoeMode,
|
"media": p.Media,
|
||||||
"port_poe": p.PortPoe.Txt,
|
"poe_class": p.PoeClass,
|
||||||
"port_idx": p.PortIdx.Txt,
|
|
||||||
"port_id": u.Name + " Port " + p.PortIdx.Txt,
|
|
||||||
"poe_enable": p.PoeEnable.Txt,
|
|
||||||
"flowctrl_rx": p.FlowctrlRx.Txt,
|
|
||||||
"flowctrl_tx": p.FlowctrlTx.Txt,
|
|
||||||
"autoneg": p.Autoneg.Txt,
|
|
||||||
"full_duplex": p.FullDuplex.Txt,
|
|
||||||
"jumbo": p.Jumbo.Txt,
|
|
||||||
"masked": p.Masked.Txt,
|
|
||||||
"poe_good": p.PoeGood.Txt,
|
|
||||||
"media": p.Media,
|
|
||||||
"poe_class": p.PoeClass,
|
|
||||||
"poe_caps": p.PoeCaps.Txt,
|
|
||||||
"aggregated_by": p.AggregatedBy.Txt,
|
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"dbytes_r": p.BytesR.Val,
|
"dbytes_r": p.BytesR.Val,
|
||||||
|
|
@ -136,7 +109,6 @@ func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
|
||||||
"poe_current": p.PoeCurrent.Val,
|
"poe_current": p.PoeCurrent.Val,
|
||||||
"poe_power": p.PoePower.Val,
|
"poe_power": p.PoePower.Val,
|
||||||
"poe_voltage": p.PoeVoltage.Val,
|
"poe_voltage": p.PoeVoltage.Val,
|
||||||
"full_duplex": p.FullDuplex.Val,
|
|
||||||
}
|
}
|
||||||
pt, err = influx.NewPoint("usw_ports", tags, fields, now)
|
pt, err = influx.NewPoint("usw_ports", tags, fields, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue