remove a bunch of unused things from influx code

This commit is contained in:
davidnewhall2 2019-11-30 02:47:11 -08:00
parent 25e5f1c4b6
commit f9a4963b23
6 changed files with 211 additions and 364 deletions

View File

@ -16,8 +16,6 @@ func ClientPoints(c *unifi.Client, now time.Time) ([]*influx.Point, error) {
"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,
"usergroup_id": c.UserGroupID,
"ap_mac": c.ApMac, "ap_mac": c.ApMac,
"gw_mac": c.GwMac, "gw_mac": c.GwMac,
"sw_mac": c.SwMac, "sw_mac": c.SwMac,
@ -37,15 +35,8 @@ func ClientPoints(c *unifi.Client, now time.Time) ([]*influx.Point, error) {
"dev_id": c.DevID.Txt, "dev_id": c.DevID.Txt,
"dev_vendor": c.DevVendor.Txt, "dev_vendor": c.DevVendor.Txt,
"dev_family": c.DevFamily.Txt, "dev_family": c.DevFamily.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,
"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, "use_fixedip": c.UseFixedIP.Txt,
"channel": c.Channel.Txt, "channel": c.Channel.Txt,
"vlan": c.Vlan.Txt, "vlan": c.Vlan.Txt,
@ -58,20 +49,11 @@ func ClientPoints(c *unifi.Client, now time.Time) ([]*influx.Point, error) {
"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,
"last_seen_by_uap": c.LastSeenByUAP,
"last_seen_by_ugw": c.LastSeenByUGW,
"last_seen_by_usw": c.LastSeenByUSW,
"uptime_by_uap": c.UptimeByUAP,
"uptime_by_ugw": c.UptimeByUGW,
"uptime_by_usw": c.UptimeByUSW,
"assoc_time": c.AssocTime,
"bytes_r": c.BytesR, "bytes_r": c.BytesR,
"ccq": c.Ccq, "ccq": c.Ccq,
"first_seen": c.FirstSeen, "first_seen": c.FirstSeen,
"idle_time": c.IdleTime, "idle_time": c.IdleTime,
"last_seen": c.LastSeen, "last_seen": c.LastSeen,
"latest_assoc_time": c.LatestAssocTime,
"network": c.Network, "network": c.Network,
"noise": c.Noise, "noise": c.Noise,
"note": c.Note, "note": c.Note,

View File

@ -14,7 +14,6 @@ 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,
@ -25,25 +24,17 @@ func SitePoints(u *unifi.Site, now time.Time) ([]*influx.Point, error) {
"gw_name": s.GwName, "gw_name": s.GwName,
"gw_mac": s.GwMac, "gw_mac": s.GwMac,
"gw_version": s.GwVersion, "gw_version": s.GwVersion,
"speedtest_status": s.SpeedtestStatus,
"lan_ip": s.LanIP, "lan_ip": s.LanIP,
"remote_user_enabled": s.RemoteUserEnabled.Txt,
"site_to_site_enabled": s.SiteToSiteEnabled.Txt,
"nameservers": strings.Join(s.Nameservers, ","), "nameservers": strings.Join(s.Nameservers, ","),
"gateways": strings.Join(s.Gateways, ","), "gateways": strings.Join(s.Gateways, ","),
"num_new_alarms": u.NumNewAlarms.Txt, "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,

View File

@ -14,24 +14,12 @@ 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,
"device_type": u.Stat.Ap.O,
"device_oid": u.Stat.Ap.Oid,
"device_ap": u.Stat.Ap.Ap,
"site_id": u.SiteID, "site_id": u.SiteID,
"site_name": u.SiteName, "site_name": u.SiteName,
"name": u.Name, "name": u.Name,
"adopted": u.Adopted.Txt,
"cfgversion": u.Cfgversion, "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, "model": u.Model,
"serial": u.Serial, "serial": u.Serial,
"type": u.Type, "type": u.Type,
@ -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

View File

@ -19,25 +19,16 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
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,
"adopted": u.Adopted.Txt,
"name": u.Name, "name": u.Name,
"cfgversion": u.Cfgversion, "cfgversion": u.Cfgversion,
"config_network_ip": u.ConfigNetwork.IP,
"config_network_type": u.ConfigNetwork.Type,
"connect_request_ip": u.ConnectRequestIP,
"connect_request_port": u.ConnectRequestPort,
"device_id": u.DeviceID, "device_id": u.DeviceID,
"guest_token": u.GuestToken,
"inform_ip": u.InformIP,
"known_cfgversion": u.KnownCfgversion, "known_cfgversion": u.KnownCfgversion,
"model": u.Model, "model": u.Model,
"serial": u.Serial, "serial": u.Serial,
"type": u.Type, "type": u.Type,
"usg_caps": u.UsgCaps.Txt, "usg_caps": u.UsgCaps.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,
} }
@ -149,27 +140,14 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
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,
"adopted": u.Adopted.Txt,
"cfgversion": u.Cfgversion,
"config_network_ip": u.ConfigNetwork.IP,
"config_network_type": u.ConfigNetwork.Type,
"device_id": u.DeviceID,
"inform_ip": u.InformIP,
"known_cfgversion": u.KnownCfgversion,
"locating": u.Locating.Txt,
"model": u.Model, "model": u.Model,
"serial": u.Serial, "serial": u.Serial,
"type": u.Type, "type": u.Type,
"dot1x_portctrl_enabled": u.Dot1XPortctrlEnabled.Txt,
"flowctrl_enabled": u.FlowctrlEnabled.Txt,
"has_fan": u.HasFan.Txt, "has_fan": u.HasFan.Txt,
"has_temperature": u.HasTemperature.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,
@ -224,18 +202,14 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
"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,
"dhcpd_enabled": p.DhcpdEnabled.Txt,
"dhcpd_time_offset_enabled": p.DhcpdTimeOffsetEnabled.Txt,
"dhcp_relay_enabledy": p.DhcpRelayEnabled.Txt,
"dhcpd_gateway_enabled": p.DhcpdGatewayEnabled.Txt,
"enabled": p.Enabled.Txt, "enabled": p.Enabled.Txt,
"vlan_enabled": p.VlanEnabled.Txt,
"attr_no_delete": p.AttrNoDelete.Txt,
"is_guest": p.IsGuest.Txt,
"is_nat": p.IsNat.Txt,
"networkgroup": p.Networkgroup,
"site_id": p.SiteID, "site_id": p.SiteID,
"ip": p.IP,
"ip_subnet": p.IPSubnet,
"mac": p.Mac,
"name": p.Name,
"domain_name": p.DomainName,
"purpose": p.Purpose,
} }
fields := map[string]interface{}{ fields := map[string]interface{}{
"domain_name": p.DomainName, "domain_name": p.DomainName,
@ -268,14 +242,7 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
"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,
"portconf_id": p.PortconfID,
"dot1x_mode": p.Dot1XMode,
"dot1x_status": p.Dot1XStatus,
"stp_state": p.StpState,
"sfp_found": p.SfpFound.Txt,
"op_mode": p.OpMode,
"poe_mode": p.PoeMode, "poe_mode": p.PoeMode,
"port_poe": p.PortPoe.Txt, "port_poe": p.PortPoe.Txt,
"port_idx": p.PortIdx.Txt, "port_idx": p.PortIdx.Txt,
@ -283,15 +250,8 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
"poe_enable": p.PoeEnable.Txt, "poe_enable": p.PoeEnable.Txt,
"flowctrl_rx": p.FlowctrlRx.Txt, "flowctrl_rx": p.FlowctrlRx.Txt,
"flowctrl_tx": p.FlowctrlTx.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, "media": p.Media,
"poe_class": p.PoeClass, "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,24 +286,12 @@ 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,
"device_type": u.Stat.Ap.O,
"device_oid": u.Stat.Ap.Oid,
"device_ap": u.Stat.Ap.Ap,
"site_id": u.SiteID, "site_id": u.SiteID,
"site_name": u.SiteName, "site_name": u.SiteName,
"name": u.Name, "name": u.Name,
"adopted": u.Adopted.Txt,
"cfgversion": u.Cfgversion, "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, "model": u.Model,
"serial": u.Serial, "serial": u.Serial,
"type": u.Type, "type": u.Type,
@ -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
} }

View File

@ -18,28 +18,16 @@ func USGPoints(u *unifi.USG, now time.Time) ([]*influx.Point, error) {
"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,
"adopted": u.Adopted.Txt,
"name": u.Name, "name": u.Name,
"cfgversion": u.Cfgversion, "cfgversion": u.Cfgversion,
"config_network_ip": u.ConfigNetwork.IP,
"config_network_type": u.ConfigNetwork.Type,
"connect_request_ip": u.ConnectRequestIP,
"connect_request_port": u.ConnectRequestPort,
"device_id": u.DeviceID, "device_id": u.DeviceID,
"guest_token": u.GuestToken,
"inform_ip": u.InformIP,
"known_cfgversion": u.KnownCfgversion, "known_cfgversion": u.KnownCfgversion,
"led_override": u.LedOverride,
"locating": u.Locating.Txt,
"model": u.Model, "model": u.Model,
"outdoor_mode_override": u.OutdoorModeOverride,
"serial": u.Serial, "serial": u.Serial,
"type": u.Type, "type": u.Type,
"usg_caps": u.UsgCaps.Txt, "usg_caps": u.UsgCaps.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,
} }
@ -158,27 +146,13 @@ func USGPoints(u *unifi.USG, now time.Time) ([]*influx.Point, error) {
"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,
"dhcpd_enabled": p.DhcpdEnabled.Txt,
"dhcpd_time_offset_enabled": p.DhcpdTimeOffsetEnabled.Txt,
"dhcp_relay_enabledy": p.DhcpRelayEnabled.Txt,
"dhcpd_gateway_enabled": p.DhcpdGatewayEnabled.Txt,
"enabled": p.Enabled.Txt, "enabled": p.Enabled.Txt,
"vlan_enabled": p.VlanEnabled.Txt,
"attr_no_delete": p.AttrNoDelete.Txt,
"is_guest": p.IsGuest.Txt,
"is_nat": p.IsNat.Txt,
"networkgroup": p.Networkgroup,
"site_id": p.SiteID, "site_id": p.SiteID,
"ip": p.IP, "ip": p.IP,
"ip_subnet": p.IPSubnet, "ip_subnet": p.IPSubnet,
"mac": p.Mac, "mac": p.Mac,
"name": p.Name, "name": p.Name,
"domain_name": p.DomainName, "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, "purpose": p.Purpose,
} }
fields := map[string]interface{}{ fields := map[string]interface{}{

View File

@ -16,27 +16,14 @@ func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
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,
"adopted": u.Adopted.Txt,
"cfgversion": u.Cfgversion,
"config_network_ip": u.ConfigNetwork.IP,
"config_network_type": u.ConfigNetwork.Type,
"device_id": u.DeviceID,
"inform_ip": u.InformIP,
"known_cfgversion": u.KnownCfgversion,
"locating": u.Locating.Txt,
"model": u.Model, "model": u.Model,
"serial": u.Serial, "serial": u.Serial,
"type": u.Type, "type": u.Type,
"dot1x_portctrl_enabled": u.Dot1XPortctrlEnabled.Txt,
"flowctrl_enabled": u.FlowctrlEnabled.Txt,
"has_fan": u.HasFan.Txt, "has_fan": u.HasFan.Txt,
"has_temperature": u.HasTemperature.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,
@ -90,14 +77,7 @@ func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
"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,
"portconf_id": p.PortconfID,
"dot1x_mode": p.Dot1XMode,
"dot1x_status": p.Dot1XStatus,
"stp_state": p.StpState,
"sfp_found": p.SfpFound.Txt,
"op_mode": p.OpMode,
"poe_mode": p.PoeMode, "poe_mode": p.PoeMode,
"port_poe": p.PortPoe.Txt, "port_poe": p.PortPoe.Txt,
"port_idx": p.PortIdx.Txt, "port_idx": p.PortIdx.Txt,
@ -105,15 +85,8 @@ func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
"poe_enable": p.PoeEnable.Txt, "poe_enable": p.PoeEnable.Txt,
"flowctrl_rx": p.FlowctrlRx.Txt, "flowctrl_rx": p.FlowctrlRx.Txt,
"flowctrl_tx": p.FlowctrlTx.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, "media": p.Media,
"poe_class": p.PoeClass, "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 {