From aaf062d4747bb7f76464807c897e59c52f716be3 Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Thu, 9 Dec 2021 16:45:06 -0600 Subject: [PATCH] fix syntax issues --- integrations/datadogunifi/alarms.go | 72 +++++------ integrations/datadogunifi/clients.go | 68 +++++----- integrations/datadogunifi/events.go | 184 +++++++++++++-------------- integrations/datadogunifi/ids.go | 12 +- integrations/datadogunifi/logger.go | 6 +- integrations/datadogunifi/site.go | 4 +- integrations/datadogunifi/uap.go | 2 +- integrations/datadogunifi/udm.go | 10 +- integrations/datadogunifi/usg.go | 32 ++--- integrations/datadogunifi/usw.go | 47 ++++--- integrations/datadogunifi/uxg.go | 4 +- 11 files changed, 220 insertions(+), 221 deletions(-) diff --git a/integrations/datadogunifi/alarms.go b/integrations/datadogunifi/alarms.go index dbbacd9b..9808f1d3 100644 --- a/integrations/datadogunifi/alarms.go +++ b/integrations/datadogunifi/alarms.go @@ -20,42 +20,42 @@ func (u *DatadogUnifi) batchAlarms(r report, event *unifi.Alarm) { // nolint:dup } tagMap := map[string]string{ - "dest_port": strconv.Itoa(event.DestPort), - "src_port": strconv.Itoa(event.SrcPort), - "dest_ip": event.DestIP, - "dst_mac": event.DstMAC, - "host": event.Host, - "msg": event.Msg, - "src_ip": event.SrcIP, - "src_mac": event.SrcMAC, - "dstip_asn": fmt.Sprintf("%d", event.DestIPGeo.Asn), - "dstip_latitude": fmt.Sprintf("%0.6f", event.DestIPGeo.Latitude), - "dstip_longitude": fmt.Sprintf("%0.6f", event.DestIPGeo.Longitude), - "dstip_city": event.DestIPGeo.City, - "dstip_continent_code": event.DestIPGeo.ContinentCode, - "dstip_country_code": event.DestIPGeo.CountryCode, - "dstip_country_name": event.DestIPGeo.CountryName, - "dstip_organization": event.DestIPGeo.Organization, - "srcip_asn": fmt.Sprintf("%d", event.SourceIPGeo.Asn), - "srcip_latitude": fmt.Sprintf("%0.6f", event.SourceIPGeo.Latitude), - "srcip_longitude": fmt.Sprintf("%0.6f", event.SourceIPGeo.Longitude), - "srcip_city": event.SourceIPGeo.City, - "srcip_continent_code": event.SourceIPGeo.ContinentCode, - "srcip_country_code": event.SourceIPGeo.CountryCode, - "srcip_country_name": event.SourceIPGeo.CountryName, - "srcip_organization": event.SourceIPGeo.Organization, - "site_name": event.SiteName, - "source": event.SourceName, - "in_iface": event.InIface, - "event_type": event.EventType, - "subsystem": event.Subsystem, - "archived": event.Archived.Txt, - "usgip": event.USGIP, - "proto": event.Proto, - "key": event.Key, - "catname": event.Catname, - "app_proto": event.AppProto, - "action": event.InnerAlertAction, + "dst_port": strconv.Itoa(event.DestPort), + "src_port": strconv.Itoa(event.SrcPort), + "dest_ip": event.DestIP, + "dst_mac": event.DstMAC, + "host": event.Host, + "msg": event.Msg, + "src_ip": event.SrcIP, + "src_mac": event.SrcMAC, + "dst_ip_asn": fmt.Sprintf("%d", event.DestIPGeo.Asn), + "dst_ip_latitude": fmt.Sprintf("%0.6f", event.DestIPGeo.Latitude), + "dst_ip_longitude": fmt.Sprintf("%0.6f", event.DestIPGeo.Longitude), + "dst_ip_city": event.DestIPGeo.City, + "dst_ip_continent_code": event.DestIPGeo.ContinentCode, + "dst_ip_country_code": event.DestIPGeo.CountryCode, + "dst_ip_country_name": event.DestIPGeo.CountryName, + "dst_ip_organization": event.DestIPGeo.Organization, + "src_ip_asn": fmt.Sprintf("%d", event.SourceIPGeo.Asn), + "src_ip_latitude": fmt.Sprintf("%0.6f", event.SourceIPGeo.Latitude), + "src_ip_longitude": fmt.Sprintf("%0.6f", event.SourceIPGeo.Longitude), + "src_ip_city": event.SourceIPGeo.City, + "src_ip_continent_code": event.SourceIPGeo.ContinentCode, + "src_ip_country_code": event.SourceIPGeo.CountryCode, + "src_ip_country_name": event.SourceIPGeo.CountryName, + "src_ip_organization": event.SourceIPGeo.Organization, + "site_name": event.SiteName, + "source": event.SourceName, + "in_iface": event.InIface, + "event_type": event.EventType, + "subsystem": event.Subsystem, + "archived": event.Archived.Txt, + "usg_ip": event.USGIP, + "proto": event.Proto, + "key": event.Key, + "catname": event.Catname, + "app_proto": event.AppProto, + "action": event.InnerAlertAction, } r.addCount(alarmT) diff --git a/integrations/datadogunifi/clients.go b/integrations/datadogunifi/clients.go index a8422fee..8c2ef504 100644 --- a/integrations/datadogunifi/clients.go +++ b/integrations/datadogunifi/clients.go @@ -8,34 +8,34 @@ import ( // These points can be passed directly to Datadog. func (u *DatadogUnifi) batchClient(r report, s *unifi.Client) { // nolint: funlen tags := map[string]string{ - "mac": s.Mac, - "site_name": s.SiteName, - "source": s.SourceName, - "ap_name": s.ApName, - "gw_name": s.GwName, - "sw_name": s.SwName, - "oui": s.Oui, - "radio_name": s.RadioName, - "radio": s.Radio, - "radio_proto": s.RadioProto, - "name": s.Name, - "fixed_ip": s.FixedIP, - "sw_port": s.SwPort.Txt, - "os_class": s.OsClass.Txt, - "os_name": s.OsName.Txt, - "dev_cat": s.DevCat.Txt, - "dev_id": s.DevID.Txt, - "dev_vendor": s.DevVendor.Txt, - "dev_family": s.DevFamily.Txt, - "is_wired": s.IsWired.Txt, - "is_guest": s.IsGuest.Txt, - "use_fixedip": s.UseFixedIP.Txt, - "channel": s.Channel.Txt, - "vlan": s.Vlan.Txt, - "hostname": s.Name, - "essid": s.Essid, - "bssid": s.Bssid, - "ip": s.IP, + "mac": s.Mac, + "site_name": s.SiteName, + "source": s.SourceName, + "ap_name": s.ApName, + "gw_name": s.GwName, + "sw_name": s.SwName, + "oui": s.Oui, + "radio_name": s.RadioName, + "radio": s.Radio, + "radio_proto": s.RadioProto, + "name": s.Name, + "fixed_ip": s.FixedIP, + "sw_port": s.SwPort.Txt, + "os_class": s.OsClass.Txt, + "os_name": s.OsName.Txt, + "dev_cat": s.DevCat.Txt, + "dev_id": s.DevID.Txt, + "dev_vendor": s.DevVendor.Txt, + "dev_family": s.DevFamily.Txt, + "is_wired": s.IsWired.Txt, + "is_guest": s.IsGuest.Txt, + "use_fixed_ip": s.UseFixedIP.Txt, + "channel": s.Channel.Txt, + "vlan": s.Vlan.Txt, + "hostname": s.Name, + "essid": s.Essid, + "bssid": s.Bssid, + "ip": s.IP, } powerSaveEnabled := 0.0 if s.PowersaveEnabled.Val { @@ -64,12 +64,12 @@ func (u *DatadogUnifi) batchClient(r report, s *unifi.Client) { // nolint: funle "tx_rate": float64(s.TxRate), "uptime": float64(s.Uptime), "wifi_tx_attempts": float64(s.WifiTxAttempts), - "wired-rx_bytes": float64(s.WiredRxBytes), - "wired-rx_bytes-r": float64(s.WiredRxBytesR), - "wired-rx_packets": float64(s.WiredRxPackets), - "wired-tx_bytes": float64(s.WiredTxBytes), - "wired-tx_bytes-r": float64(s.WiredTxBytesR), - "wired-tx_packets": float64(s.WiredTxPackets), + "wired_rx_bytes": float64(s.WiredRxBytes), + "wired_rx_bytes-r": float64(s.WiredRxBytesR), + "wired_rx_packets": float64(s.WiredRxPackets), + "wired_tx_bytes": float64(s.WiredTxBytes), + "wired_tx_bytes-r": float64(s.WiredTxBytesR), + "wired_tx_packets": float64(s.WiredTxPackets), } metricName := metricNamespace("clients") diff --git a/integrations/datadogunifi/events.go b/integrations/datadogunifi/events.go index a95f3e25..76ffb164 100644 --- a/integrations/datadogunifi/events.go +++ b/integrations/datadogunifi/events.go @@ -21,42 +21,42 @@ func (u *DatadogUnifi) batchIDS(r report, i *unifi.IDS) { // nolint:dupl } tagMap := map[string]string{ - "dest_port": strconv.Itoa(i.DestPort), - "src_port": strconv.Itoa(i.SrcPort), - "dest_ip": i.DestIP, - "dst_mac": i.DstMAC, - "host": i.Host, - "msg": i.Msg, - "src_ip": i.SrcIP, - "src_mac": i.SrcMAC, - "dstip_asn": fmt.Sprintf("%d", i.DestIPGeo.Asn), - "dstip_latitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Latitude), - "dstip_longitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Longitude), - "dstip_city": i.DestIPGeo.City, - "dstip_continent_code": i.DestIPGeo.ContinentCode, - "dstip_country_code": i.DestIPGeo.CountryCode, - "dstip_country_name": i.DestIPGeo.CountryName, - "dstip_organization": i.DestIPGeo.Organization, - "srcip_asn": fmt.Sprintf("%d", i.SourceIPGeo.Asn), - "srcip_latitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Latitude), - "srcip_longitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Longitude), - "srcip_city": i.SourceIPGeo.City, - "srcip_continent_code": i.SourceIPGeo.ContinentCode, - "srcip_country_code": i.SourceIPGeo.CountryCode, - "srcip_country_name": i.SourceIPGeo.CountryName, - "srcip_organization": i.SourceIPGeo.Organization, - "site_name": i.SiteName, - "source": i.SourceName, - "in_iface": i.InIface, - "event_type": i.EventType, - "subsystem": i.Subsystem, - "archived": i.Archived.Txt, - "usgip": i.USGIP, - "proto": i.Proto, - "key": i.Key, - "catname": i.Catname, - "app_proto": i.AppProto, - "action": i.InnerAlertAction, + "dest_port": strconv.Itoa(i.DestPort), + "src_port": strconv.Itoa(i.SrcPort), + "dest_ip": i.DestIP, + "dst_mac": i.DstMAC, + "host": i.Host, + "msg": i.Msg, + "src_ip": i.SrcIP, + "src_mac": i.SrcMAC, + "dst_ip_asn": fmt.Sprintf("%d", i.DestIPGeo.Asn), + "dst_ip_latitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Latitude), + "dst_ip_longitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Longitude), + "dst_ip_city": i.DestIPGeo.City, + "dst_ip_continent_code": i.DestIPGeo.ContinentCode, + "dst_ip_country_code": i.DestIPGeo.CountryCode, + "dst_ip_country_name": i.DestIPGeo.CountryName, + "dst_ip_organization": i.DestIPGeo.Organization, + "src_ip_asn": fmt.Sprintf("%d", i.SourceIPGeo.Asn), + "src_ip_latitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Latitude), + "src_ip_longitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Longitude), + "src_ip_city": i.SourceIPGeo.City, + "src_ip_continent_code": i.SourceIPGeo.ContinentCode, + "src_ip_country_code": i.SourceIPGeo.CountryCode, + "src_ip_country_name": i.SourceIPGeo.CountryName, + "src_ip_organization": i.SourceIPGeo.Organization, + "site_name": i.SiteName, + "source": i.SourceName, + "in_iface": i.InIface, + "event_type": i.EventType, + "subsystem": i.Subsystem, + "archived": i.Archived.Txt, + "usg_ip": i.USGIP, + "proto": i.Proto, + "key": i.Key, + "catname": i.Catname, + "app_proto": i.AppProto, + "action": i.InnerAlertAction, } r.addCount(idsT) @@ -75,62 +75,62 @@ func (u *DatadogUnifi) batchEvent(r report, i *unifi.Event) { // nolint: funlen } tagMap := map[string]string{ - "guest": i.Guest, // mac address - "user": i.User, // mac address - "host": i.Host, // usg device? - "hostname": i.Hostname, // client name - "dest_port": strconv.Itoa(i.DestPort), - "src_port": strconv.Itoa(i.SrcPort), - "dest_ip": i.DestIP, - "dst_mac": i.DstMAC, - "ip": i.IP, - "src_ip": i.SrcIP, - "src_mac": i.SrcMAC, - "dstip_asn": fmt.Sprintf("%d", i.DestIPGeo.Asn), - "dstip_latitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Latitude), - "dstip_longitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Longitude), - "dstip_city": i.DestIPGeo.City, - "dstip_continent_code": i.DestIPGeo.ContinentCode, - "dstip_country_code": i.DestIPGeo.CountryCode, - "dstip_country_name": i.DestIPGeo.CountryName, - "dstip_organization": i.DestIPGeo.Organization, - "srcip_asn": fmt.Sprintf("%d", i.SourceIPGeo.Asn), - "srcip_latitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Latitude), - "srcip_longitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Longitude), - "srcip_city": i.SourceIPGeo.City, - "srcip_continent_code": i.SourceIPGeo.ContinentCode, - "srcip_country_code": i.SourceIPGeo.CountryCode, - "srcip_country_name": i.SourceIPGeo.CountryName, - "srcip_organization": i.SourceIPGeo.Organization, - "admin": i.Admin, // username - "site_name": i.SiteName, - "source": i.SourceName, - "ap_from": i.ApFrom, - "ap_to": i.ApTo, - "ap": i.Ap, - "ap_name": i.ApName, - "gw": i.Gw, - "gw_name": i.GwName, - "sw": i.Sw, - "sw_name": i.SwName, - "catname": i.Catname, - "radio": i.Radio, - "radio_from": i.RadioFrom, - "radio_to": i.RadioTo, - "key": i.Key, - "in_iface": i.InIface, - "event_type": i.EventType, - "subsystem": i.Subsystem, - "ssid": i.SSID, - "is_admin": i.IsAdmin.Txt, - "channel": i.Channel.Txt, - "channel_from": i.ChannelFrom.Txt, - "channel_to": i.ChannelTo.Txt, - "usgip": i.USGIP, - "network": i.Network, - "app_proto": i.AppProto, - "proto": i.Proto, - "action": i.InnerAlertAction, + "guest": i.Guest, // mac address + "user": i.User, // mac address + "host": i.Host, // usg device? + "hostname": i.Hostname, // client name + "dest_port": strconv.Itoa(i.DestPort), + "src_port": strconv.Itoa(i.SrcPort), + "dst_ip": i.DestIP, + "dst_mac": i.DstMAC, + "ip": i.IP, + "src_ip": i.SrcIP, + "src_mac": i.SrcMAC, + "dst_ip_asn": fmt.Sprintf("%d", i.DestIPGeo.Asn), + "dst_ip_latitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Latitude), + "dst_ip_longitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Longitude), + "dst_ip_city": i.DestIPGeo.City, + "dst_ip_continent_code": i.DestIPGeo.ContinentCode, + "dst_ip_country_code": i.DestIPGeo.CountryCode, + "dst_ip_country_name": i.DestIPGeo.CountryName, + "dst_ip_organization": i.DestIPGeo.Organization, + "src_ip_asn": fmt.Sprintf("%d", i.SourceIPGeo.Asn), + "src_ip_latitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Latitude), + "src_ip_longitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Longitude), + "src_ip_city": i.SourceIPGeo.City, + "src_ip_continent_code": i.SourceIPGeo.ContinentCode, + "src_ip_country_code": i.SourceIPGeo.CountryCode, + "src_ip_country_name": i.SourceIPGeo.CountryName, + "src_ip_organization": i.SourceIPGeo.Organization, + "admin": i.Admin, // username + "site_name": i.SiteName, + "source": i.SourceName, + "ap_from": i.ApFrom, + "ap_to": i.ApTo, + "ap": i.Ap, + "ap_name": i.ApName, + "gw": i.Gw, + "gw_name": i.GwName, + "sw": i.Sw, + "sw_name": i.SwName, + "catname": i.Catname, + "radio": i.Radio, + "radio_from": i.RadioFrom, + "radio_to": i.RadioTo, + "key": i.Key, + "in_iface": i.InIface, + "event_type": i.EventType, + "subsystem": i.Subsystem, + "ssid": i.SSID, + "is_admin": i.IsAdmin.Txt, + "channel": i.Channel.Txt, + "channel_from": i.ChannelFrom.Txt, + "channel_to": i.ChannelTo.Txt, + "usg_ip": i.USGIP, + "network": i.Network, + "app_proto": i.AppProto, + "proto": i.Proto, + "action": i.InnerAlertAction, } r.addCount(eventT) diff --git a/integrations/datadogunifi/ids.go b/integrations/datadogunifi/ids.go index a79b7bb8..90bdaef7 100644 --- a/integrations/datadogunifi/ids.go +++ b/integrations/datadogunifi/ids.go @@ -14,12 +14,12 @@ func (u *DatadogUnifi) reportIDS(r report, i *unifi.IDS) { tag("event_type", i.EventType), tag("proto", i.Proto), tag("app_proto", i.AppProto), - tag("usgip", i.Usgip), - tag("country_code", i.SrcipGeo.CountryCode), - tag("country_name", i.SrcipGeo.CountryName), - tag("city", i.SrcipGeo.City), - tag("srcipASN", i.SrcipASN), - tag("usgipASN", i.UsgipASN), + tag("usg_ip", i.USGIP), + tag("country_code", i.SourceIPGeo.CountryCode), + tag("country_name", i.SourceIPGeo.CountryName), + tag("city", i.SourceIPGeo.City), + tag("src_ip_ASN", i.SrcIPASN), + tag("usg_ip_ASN", i.USGIPASN), tag("alert_category", i.InnerAlertCategory), tag("subsystem", i.Subsystem), tag("catname", i.Catname), diff --git a/integrations/datadogunifi/logger.go b/integrations/datadogunifi/logger.go index eed2685e..c223fb7c 100644 --- a/integrations/datadogunifi/logger.go +++ b/integrations/datadogunifi/logger.go @@ -9,7 +9,7 @@ import ( // Logf logs a message. func (u *DatadogUnifi) Logf(msg string, v ...interface{}) { - webserver.NewOutputEvent(PluginName, PluginName, &webserver.Event{ + webserver.NewOutputEvent(webserver.PluginName, webserver.PluginName, &webserver.Event{ Ts: time.Now(), Msg: fmt.Sprintf(msg, v...), Tags: map[string]string{"type": "info"}, @@ -19,7 +19,7 @@ func (u *DatadogUnifi) Logf(msg string, v ...interface{}) { // LogErrorf logs an error message. func (u *DatadogUnifi) LogErrorf(msg string, v ...interface{}) { - webserver.NewOutputEvent(PluginName, PluginName, &webserver.Event{ + webserver.NewOutputEvent(webserver.PluginName, webserver.PluginName, &webserver.Event{ Ts: time.Now(), Msg: fmt.Sprintf(msg, v...), Tags: map[string]string{"type": "error"}, @@ -29,7 +29,7 @@ func (u *DatadogUnifi) LogErrorf(msg string, v ...interface{}) { // LogDebugf logs a debug message. func (u *DatadogUnifi) LogDebugf(msg string, v ...interface{}) { - webserver.NewOutputEvent(PluginName, PluginName, &webserver.Event{ + webserver.NewOutputEvent(webserver.PluginName, webserver.PluginName, &webserver.Event{ Ts: time.Now(), Msg: fmt.Sprintf(msg, v...), Tags: map[string]string{"type": "debug"}, diff --git a/integrations/datadogunifi/site.go b/integrations/datadogunifi/site.go index 38c6e7c5..f21dbc8a 100644 --- a/integrations/datadogunifi/site.go +++ b/integrations/datadogunifi/site.go @@ -26,8 +26,8 @@ func (u *DatadogUnifi) reportSite(r report, s *unifi.Site) { "num_user": h.NumUser.Val, "num_guest": h.NumGuest.Val, "num_iot": h.NumIot.Val, - "tx_bytes-r": h.TxBytesR.Val, - "rx_bytes-r": h.RxBytesR.Val, + "tx_bytes_r": h.TxBytesR.Val, + "rx_bytes_r": h.RxBytesR.Val, "num_ap": h.NumAp.Val, "num_adopted": h.NumAdopted.Val, "num_disabled": h.NumDisabled.Val, diff --git a/integrations/datadogunifi/uap.go b/integrations/datadogunifi/uap.go index 37729fba..62ebe3ae 100644 --- a/integrations/datadogunifi/uap.go +++ b/integrations/datadogunifi/uap.go @@ -215,7 +215,7 @@ func (u *DatadogUnifi) processRadTable(r report, t map[string]string, rt unifi.R data["cu_self_rx"] = t.CuSelfRx.Val data["cu_self_tx"] = t.CuSelfTx.Val data["cu_total"] = t.CuTotal.Val - data["extchannel"] = t.Extchannel.Val + data["ext_channel"] = t.Extchannel.Val data["gain"] = t.Gain.Val data["guest_num_sta"] = t.GuestNumSta.Val data["num_sta"] = t.NumSta.Val diff --git a/integrations/datadogunifi/udm.go b/integrations/datadogunifi/udm.go index 4529086c..796beb95 100644 --- a/integrations/datadogunifi/udm.go +++ b/integrations/datadogunifi/udm.go @@ -116,12 +116,12 @@ func (u *DatadogUnifi) batchUDM(r report, s *unifi.UDM) { // nolint: funlen map[string]float64{ "bytes": s.Bytes.Val, "last_seen": s.LastSeen.Val, - "guest-num_sta": s.GuestNumSta.Val, + "guest_num_sta": s.GuestNumSta.Val, "rx_bytes": s.RxBytes.Val, "tx_bytes": s.TxBytes.Val, "uptime": s.Uptime.Val, "state": s.State.Val, - "user-num_sta": s.UserNumSta.Val, + "user_num_sta": s.UserNumSta.Val, "num_desktop": s.NumDesktop.Val, "num_handheld": s.NumHandheld.Val, "num_mobile": s.NumMobile.Val, @@ -149,7 +149,7 @@ func (u *DatadogUnifi) batchUDM(r report, s *unifi.UDM) { // nolint: funlen data = CombineFloat64( u.batchUSWstat(s.Stat.Sw), map[string]float64{ - "guest-num_sta": s.GuestNumSta.Val, + "guest_num_sta": s.GuestNumSta.Val, "bytes": s.Bytes.Val, "last_seen": s.LastSeen.Val, "rx_bytes": s.RxBytes.Val, @@ -184,8 +184,8 @@ func (u *DatadogUnifi) batchUDM(r report, s *unifi.UDM) { // nolint: funlen data["tx_bytes"] = s.TxBytes.Val data["uptime"] = s.Uptime.Val data["state"] = s.State.Val - data["user-num_sta"] = s.UserNumSta.Val - data["guest-num_sta"] = s.GuestNumSta.Val + data["user_num_sta"] = s.UserNumSta.Val + data["guest_num_sta"] = s.GuestNumSta.Val data["num_sta"] = s.NumSta.Val metricName = metricNamespace("uap") diff --git a/integrations/datadogunifi/usg.go b/integrations/datadogunifi/usg.go index 269793c7..95065e27 100644 --- a/integrations/datadogunifi/usg.go +++ b/integrations/datadogunifi/usg.go @@ -33,12 +33,12 @@ func (u *DatadogUnifi) batchUSG(r report, s *unifi.USG) { map[string]float64{ "bytes": s.Bytes.Val, "last_seen": s.LastSeen.Val, - "guest-num_sta": s.GuestNumSta.Val, + "guest_num_sta": s.GuestNumSta.Val, "rx_bytes": s.RxBytes.Val, "tx_bytes": s.TxBytes.Val, "uptime": s.Uptime.Val, "state": s.State.Val, - "user-num_sta": s.UserNumSta.Val, + "user_num_sta": s.UserNumSta.Val, "num_desktop": s.NumDesktop.Val, "num_handheld": s.NumHandheld.Val, "num_mobile": s.NumMobile.Val, @@ -62,17 +62,17 @@ func (u *DatadogUnifi) batchUSGstats(ss unifi.SpeedtestStatus, gw *unifi.Gw, ul return map[string]float64{ "uplink_latency": ul.Latency.Val, "uplink_speed": ul.Speed.Val, - "speedtest-status_latency": ss.Latency.Val, - "speedtest-status_runtime": ss.Runtime.Val, - "speedtest-status_rundate": ss.Rundate.Val, - "speedtest-status_ping": ss.StatusPing.Val, - "speedtest-status_xput_download": ss.XputDownload.Val, - "speedtest-status_xput_upload": ss.XputUpload.Val, - "lan-rx_bytes": gw.LanRxBytes.Val, - "lan-rx_packets": gw.LanRxPackets.Val, - "lan-tx_bytes": gw.LanTxBytes.Val, - "lan-tx_packets": gw.LanTxPackets.Val, - "lan-rx_dropped": gw.LanRxDropped.Val, + "speedtest_status_latency": ss.Latency.Val, + "speedtest_status_runtime": ss.Runtime.Val, + "speedtest_status_rundate": ss.Rundate.Val, + "speedtest_status_ping": ss.StatusPing.Val, + "speedtest_status_xput_download": ss.XputDownload.Val, + "speedtest_status_xput_upload": ss.XputUpload.Val, + "lan_rx_bytes": gw.LanRxBytes.Val, + "lan_rx_packets": gw.LanRxPackets.Val, + "lan_tx_bytes": gw.LanTxBytes.Val, + "lan_tx_packets": gw.LanTxPackets.Val, + "lan_rx_dropped": gw.LanRxDropped.Val, } } @@ -101,11 +101,11 @@ func (u *DatadogUnifi) batchUSGwans(r report, tags map[string]string, wans ...un fullDuplex = 1.0 } data := map[string]float64{ - "bytes-r": wan.BytesR.Val, + "bytes_r": wan.BytesR.Val, "full_duplex": fullDuplex, "max_speed": wan.MaxSpeed.Val, "rx_bytes": wan.RxBytes.Val, - "rx_bytes-r": wan.RxBytesR.Val, + "rx_bytes_r": wan.RxBytesR.Val, "rx_dropped": wan.RxDropped.Val, "rx_errors": wan.RxErrors.Val, "rx_broadcast": wan.RxBroadcast.Val, @@ -113,7 +113,7 @@ func (u *DatadogUnifi) batchUSGwans(r report, tags map[string]string, wans ...un "rx_packets": wan.RxPackets.Val, "speed": wan.Speed.Val, "tx_bytes": wan.TxBytes.Val, - "tx_bytes-r": wan.TxBytesR.Val, + "tx_bytes_r": wan.TxBytesR.Val, "tx_dropped": wan.TxDropped.Val, "tx_errors": wan.TxErrors.Val, "tx_packets": wan.TxPackets.Val, diff --git a/integrations/datadogunifi/usw.go b/integrations/datadogunifi/usw.go index 9d0f7948..aac3ae0b 100644 --- a/integrations/datadogunifi/usw.go +++ b/integrations/datadogunifi/usw.go @@ -29,8 +29,7 @@ func (u *DatadogUnifi) batchUSW(r report, s *unifi.USW) { u.batchUSWstat(s.Stat.Sw), u.batchSysStats(s.SysStats, s.SystemStats), map[string]float64{ - "guest-num_sta": s.GuestNumSta.Val, - + "guest_num_sta": s.GuestNumSta.Val, "bytes": s.Bytes.Val, "fan_level": s.FanLevel.Val, "general_temperature": s.GeneralTemperature.Val, @@ -39,7 +38,7 @@ func (u *DatadogUnifi) batchUSW(r report, s *unifi.USW) { "tx_bytes": s.TxBytes.Val, "uptime": s.Uptime.Val, "state": s.State.Val, - "user-num_sta": s.UserNumSta.Val, + "user_num_sta": s.UserNumSta.Val, }) r.addCount(uswT) @@ -88,8 +87,8 @@ func (u *DatadogUnifi) batchPortTable(r report, t map[string]string, pt []unifi. "port_idx": p.PortIdx.Txt, "port_id": t["name"] + " Port " + p.PortIdx.Txt, "poe_enable": p.PoeEnable.Txt, - "flowctrl_rx": p.FlowctrlRx.Txt, - "flowctrl_tx": p.FlowctrlTx.Txt, + "flow_ctrl_rx": p.FlowctrlRx.Txt, + "flow_ctrl_tx": p.FlowctrlTx.Txt, "media": p.Media, "has_sfp": p.SFPFound.Txt, "sfp_compliance": p.SFPCompliance, @@ -98,23 +97,23 @@ func (u *DatadogUnifi) batchPortTable(r report, t map[string]string, pt []unifi. "sfp_part": p.SFPPart, }) data := map[string]float64{ - "dbytes_r": p.BytesR.Val, - "rx_broadcast": p.RxBroadcast.Val, - "rx_bytes": p.RxBytes.Val, - "rx_bytes-r": p.RxBytesR.Val, - "rx_dropped": p.RxDropped.Val, - "rx_errors": p.RxErrors.Val, - "rx_multicast": p.RxMulticast.Val, - "rx_packets": p.RxPackets.Val, - "speed": p.Speed.Val, - "stp_pathcost": p.StpPathcost.Val, - "tx_broadcast": p.TxBroadcast.Val, - "tx_bytes": p.TxBytes.Val, - "tx_bytes-r": p.TxBytesR.Val, - "tx_dropped": p.TxDropped.Val, - "tx_errors": p.TxErrors.Val, - "tx_multicast": p.TxMulticast.Val, - "tx_packets": p.TxPackets.Val, + "bytes_r": p.BytesR.Val, + "rx_broadcast": p.RxBroadcast.Val, + "rx_bytes": p.RxBytes.Val, + "rx_bytes_r": p.RxBytesR.Val, + "rx_dropped": p.RxDropped.Val, + "rx_errors": p.RxErrors.Val, + "rx_multicast": p.RxMulticast.Val, + "rx_packets": p.RxPackets.Val, + "speed": p.Speed.Val, + "stp_path_cost": p.StpPathcost.Val, + "tx_broadcast": p.TxBroadcast.Val, + "tx_bytes": p.TxBytes.Val, + "tx_bytes_r": p.TxBytesR.Val, + "tx_dropped": p.TxDropped.Val, + "tx_errors": p.TxErrors.Val, + "tx_multicast": p.TxMulticast.Val, + "tx_packets": p.TxPackets.Val, } if p.PoeEnable.Val && p.PortPoe.Val { @@ -127,8 +126,8 @@ func (u *DatadogUnifi) batchPortTable(r report, t map[string]string, pt []unifi. data["sfp_current"] = p.SFPCurrent.Val data["sfp_voltage"] = p.SFPVoltage.Val data["sfp_temperature"] = p.SFPTemperature.Val - data["sfp_txpower"] = p.SFPTxpower.Val - data["sfp_rxpower"] = p.SFPRxpower.Val + data["sfp_tx_power"] = p.SFPTxpower.Val + data["sfp_rx_power"] = p.SFPRxpower.Val } metricName := metricNamespace("usw.ports") diff --git a/integrations/datadogunifi/uxg.go b/integrations/datadogunifi/uxg.go index df92d9d8..c79f5e05 100644 --- a/integrations/datadogunifi/uxg.go +++ b/integrations/datadogunifi/uxg.go @@ -34,12 +34,12 @@ func (u *DatadogUnifi) batchUXG(r report, s *unifi.UXG) { // nolint: funlen map[string]float64{ "bytes": s.Bytes.Val, "last_seen": s.LastSeen.Val, - "guest-num_sta": s.GuestNumSta.Val, + "guest_num_sta": s.GuestNumSta.Val, "rx_bytes": s.RxBytes.Val, "tx_bytes": s.TxBytes.Val, "uptime": s.Uptime.Val, "state": s.State.Val, - "user-num_sta": s.UserNumSta.Val, + "user_num_sta": s.UserNumSta.Val, "num_desktop": s.NumDesktop.Val, "num_handheld": s.NumHandheld.Val, "num_mobile": s.NumMobile.Val,