fix syntax issues

This commit is contained in:
Cody Lee 2021-12-09 16:45:06 -06:00
parent 16bb468d7d
commit aaf062d474
11 changed files with 220 additions and 221 deletions

View File

@ -20,42 +20,42 @@ func (u *DatadogUnifi) batchAlarms(r report, event *unifi.Alarm) { // nolint:dup
} }
tagMap := map[string]string{ tagMap := map[string]string{
"dest_port": strconv.Itoa(event.DestPort), "dst_port": strconv.Itoa(event.DestPort),
"src_port": strconv.Itoa(event.SrcPort), "src_port": strconv.Itoa(event.SrcPort),
"dest_ip": event.DestIP, "dest_ip": event.DestIP,
"dst_mac": event.DstMAC, "dst_mac": event.DstMAC,
"host": event.Host, "host": event.Host,
"msg": event.Msg, "msg": event.Msg,
"src_ip": event.SrcIP, "src_ip": event.SrcIP,
"src_mac": event.SrcMAC, "src_mac": event.SrcMAC,
"dstip_asn": fmt.Sprintf("%d", event.DestIPGeo.Asn), "dst_ip_asn": fmt.Sprintf("%d", event.DestIPGeo.Asn),
"dstip_latitude": fmt.Sprintf("%0.6f", event.DestIPGeo.Latitude), "dst_ip_latitude": fmt.Sprintf("%0.6f", event.DestIPGeo.Latitude),
"dstip_longitude": fmt.Sprintf("%0.6f", event.DestIPGeo.Longitude), "dst_ip_longitude": fmt.Sprintf("%0.6f", event.DestIPGeo.Longitude),
"dstip_city": event.DestIPGeo.City, "dst_ip_city": event.DestIPGeo.City,
"dstip_continent_code": event.DestIPGeo.ContinentCode, "dst_ip_continent_code": event.DestIPGeo.ContinentCode,
"dstip_country_code": event.DestIPGeo.CountryCode, "dst_ip_country_code": event.DestIPGeo.CountryCode,
"dstip_country_name": event.DestIPGeo.CountryName, "dst_ip_country_name": event.DestIPGeo.CountryName,
"dstip_organization": event.DestIPGeo.Organization, "dst_ip_organization": event.DestIPGeo.Organization,
"srcip_asn": fmt.Sprintf("%d", event.SourceIPGeo.Asn), "src_ip_asn": fmt.Sprintf("%d", event.SourceIPGeo.Asn),
"srcip_latitude": fmt.Sprintf("%0.6f", event.SourceIPGeo.Latitude), "src_ip_latitude": fmt.Sprintf("%0.6f", event.SourceIPGeo.Latitude),
"srcip_longitude": fmt.Sprintf("%0.6f", event.SourceIPGeo.Longitude), "src_ip_longitude": fmt.Sprintf("%0.6f", event.SourceIPGeo.Longitude),
"srcip_city": event.SourceIPGeo.City, "src_ip_city": event.SourceIPGeo.City,
"srcip_continent_code": event.SourceIPGeo.ContinentCode, "src_ip_continent_code": event.SourceIPGeo.ContinentCode,
"srcip_country_code": event.SourceIPGeo.CountryCode, "src_ip_country_code": event.SourceIPGeo.CountryCode,
"srcip_country_name": event.SourceIPGeo.CountryName, "src_ip_country_name": event.SourceIPGeo.CountryName,
"srcip_organization": event.SourceIPGeo.Organization, "src_ip_organization": event.SourceIPGeo.Organization,
"site_name": event.SiteName, "site_name": event.SiteName,
"source": event.SourceName, "source": event.SourceName,
"in_iface": event.InIface, "in_iface": event.InIface,
"event_type": event.EventType, "event_type": event.EventType,
"subsystem": event.Subsystem, "subsystem": event.Subsystem,
"archived": event.Archived.Txt, "archived": event.Archived.Txt,
"usgip": event.USGIP, "usg_ip": event.USGIP,
"proto": event.Proto, "proto": event.Proto,
"key": event.Key, "key": event.Key,
"catname": event.Catname, "catname": event.Catname,
"app_proto": event.AppProto, "app_proto": event.AppProto,
"action": event.InnerAlertAction, "action": event.InnerAlertAction,
} }
r.addCount(alarmT) r.addCount(alarmT)

View File

@ -8,34 +8,34 @@ import (
// These points can be passed directly to Datadog. // These points can be passed directly to Datadog.
func (u *DatadogUnifi) batchClient(r report, s *unifi.Client) { // nolint: funlen func (u *DatadogUnifi) batchClient(r report, s *unifi.Client) { // nolint: funlen
tags := map[string]string{ tags := map[string]string{
"mac": s.Mac, "mac": s.Mac,
"site_name": s.SiteName, "site_name": s.SiteName,
"source": s.SourceName, "source": s.SourceName,
"ap_name": s.ApName, "ap_name": s.ApName,
"gw_name": s.GwName, "gw_name": s.GwName,
"sw_name": s.SwName, "sw_name": s.SwName,
"oui": s.Oui, "oui": s.Oui,
"radio_name": s.RadioName, "radio_name": s.RadioName,
"radio": s.Radio, "radio": s.Radio,
"radio_proto": s.RadioProto, "radio_proto": s.RadioProto,
"name": s.Name, "name": s.Name,
"fixed_ip": s.FixedIP, "fixed_ip": s.FixedIP,
"sw_port": s.SwPort.Txt, "sw_port": s.SwPort.Txt,
"os_class": s.OsClass.Txt, "os_class": s.OsClass.Txt,
"os_name": s.OsName.Txt, "os_name": s.OsName.Txt,
"dev_cat": s.DevCat.Txt, "dev_cat": s.DevCat.Txt,
"dev_id": s.DevID.Txt, "dev_id": s.DevID.Txt,
"dev_vendor": s.DevVendor.Txt, "dev_vendor": s.DevVendor.Txt,
"dev_family": s.DevFamily.Txt, "dev_family": s.DevFamily.Txt,
"is_wired": s.IsWired.Txt, "is_wired": s.IsWired.Txt,
"is_guest": s.IsGuest.Txt, "is_guest": s.IsGuest.Txt,
"use_fixedip": s.UseFixedIP.Txt, "use_fixed_ip": s.UseFixedIP.Txt,
"channel": s.Channel.Txt, "channel": s.Channel.Txt,
"vlan": s.Vlan.Txt, "vlan": s.Vlan.Txt,
"hostname": s.Name, "hostname": s.Name,
"essid": s.Essid, "essid": s.Essid,
"bssid": s.Bssid, "bssid": s.Bssid,
"ip": s.IP, "ip": s.IP,
} }
powerSaveEnabled := 0.0 powerSaveEnabled := 0.0
if s.PowersaveEnabled.Val { if s.PowersaveEnabled.Val {
@ -64,12 +64,12 @@ func (u *DatadogUnifi) batchClient(r report, s *unifi.Client) { // nolint: funle
"tx_rate": float64(s.TxRate), "tx_rate": float64(s.TxRate),
"uptime": float64(s.Uptime), "uptime": float64(s.Uptime),
"wifi_tx_attempts": float64(s.WifiTxAttempts), "wifi_tx_attempts": float64(s.WifiTxAttempts),
"wired-rx_bytes": float64(s.WiredRxBytes), "wired_rx_bytes": float64(s.WiredRxBytes),
"wired-rx_bytes-r": float64(s.WiredRxBytesR), "wired_rx_bytes-r": float64(s.WiredRxBytesR),
"wired-rx_packets": float64(s.WiredRxPackets), "wired_rx_packets": float64(s.WiredRxPackets),
"wired-tx_bytes": float64(s.WiredTxBytes), "wired_tx_bytes": float64(s.WiredTxBytes),
"wired-tx_bytes-r": float64(s.WiredTxBytesR), "wired_tx_bytes-r": float64(s.WiredTxBytesR),
"wired-tx_packets": float64(s.WiredTxPackets), "wired_tx_packets": float64(s.WiredTxPackets),
} }
metricName := metricNamespace("clients") metricName := metricNamespace("clients")

View File

@ -21,42 +21,42 @@ func (u *DatadogUnifi) batchIDS(r report, i *unifi.IDS) { // nolint:dupl
} }
tagMap := map[string]string{ tagMap := map[string]string{
"dest_port": strconv.Itoa(i.DestPort), "dest_port": strconv.Itoa(i.DestPort),
"src_port": strconv.Itoa(i.SrcPort), "src_port": strconv.Itoa(i.SrcPort),
"dest_ip": i.DestIP, "dest_ip": i.DestIP,
"dst_mac": i.DstMAC, "dst_mac": i.DstMAC,
"host": i.Host, "host": i.Host,
"msg": i.Msg, "msg": i.Msg,
"src_ip": i.SrcIP, "src_ip": i.SrcIP,
"src_mac": i.SrcMAC, "src_mac": i.SrcMAC,
"dstip_asn": fmt.Sprintf("%d", i.DestIPGeo.Asn), "dst_ip_asn": fmt.Sprintf("%d", i.DestIPGeo.Asn),
"dstip_latitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Latitude), "dst_ip_latitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Latitude),
"dstip_longitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Longitude), "dst_ip_longitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Longitude),
"dstip_city": i.DestIPGeo.City, "dst_ip_city": i.DestIPGeo.City,
"dstip_continent_code": i.DestIPGeo.ContinentCode, "dst_ip_continent_code": i.DestIPGeo.ContinentCode,
"dstip_country_code": i.DestIPGeo.CountryCode, "dst_ip_country_code": i.DestIPGeo.CountryCode,
"dstip_country_name": i.DestIPGeo.CountryName, "dst_ip_country_name": i.DestIPGeo.CountryName,
"dstip_organization": i.DestIPGeo.Organization, "dst_ip_organization": i.DestIPGeo.Organization,
"srcip_asn": fmt.Sprintf("%d", i.SourceIPGeo.Asn), "src_ip_asn": fmt.Sprintf("%d", i.SourceIPGeo.Asn),
"srcip_latitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Latitude), "src_ip_latitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Latitude),
"srcip_longitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Longitude), "src_ip_longitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Longitude),
"srcip_city": i.SourceIPGeo.City, "src_ip_city": i.SourceIPGeo.City,
"srcip_continent_code": i.SourceIPGeo.ContinentCode, "src_ip_continent_code": i.SourceIPGeo.ContinentCode,
"srcip_country_code": i.SourceIPGeo.CountryCode, "src_ip_country_code": i.SourceIPGeo.CountryCode,
"srcip_country_name": i.SourceIPGeo.CountryName, "src_ip_country_name": i.SourceIPGeo.CountryName,
"srcip_organization": i.SourceIPGeo.Organization, "src_ip_organization": i.SourceIPGeo.Organization,
"site_name": i.SiteName, "site_name": i.SiteName,
"source": i.SourceName, "source": i.SourceName,
"in_iface": i.InIface, "in_iface": i.InIface,
"event_type": i.EventType, "event_type": i.EventType,
"subsystem": i.Subsystem, "subsystem": i.Subsystem,
"archived": i.Archived.Txt, "archived": i.Archived.Txt,
"usgip": i.USGIP, "usg_ip": i.USGIP,
"proto": i.Proto, "proto": i.Proto,
"key": i.Key, "key": i.Key,
"catname": i.Catname, "catname": i.Catname,
"app_proto": i.AppProto, "app_proto": i.AppProto,
"action": i.InnerAlertAction, "action": i.InnerAlertAction,
} }
r.addCount(idsT) r.addCount(idsT)
@ -75,62 +75,62 @@ func (u *DatadogUnifi) batchEvent(r report, i *unifi.Event) { // nolint: funlen
} }
tagMap := map[string]string{ tagMap := map[string]string{
"guest": i.Guest, // mac address "guest": i.Guest, // mac address
"user": i.User, // mac address "user": i.User, // mac address
"host": i.Host, // usg device? "host": i.Host, // usg device?
"hostname": i.Hostname, // client name "hostname": i.Hostname, // client name
"dest_port": strconv.Itoa(i.DestPort), "dest_port": strconv.Itoa(i.DestPort),
"src_port": strconv.Itoa(i.SrcPort), "src_port": strconv.Itoa(i.SrcPort),
"dest_ip": i.DestIP, "dst_ip": i.DestIP,
"dst_mac": i.DstMAC, "dst_mac": i.DstMAC,
"ip": i.IP, "ip": i.IP,
"src_ip": i.SrcIP, "src_ip": i.SrcIP,
"src_mac": i.SrcMAC, "src_mac": i.SrcMAC,
"dstip_asn": fmt.Sprintf("%d", i.DestIPGeo.Asn), "dst_ip_asn": fmt.Sprintf("%d", i.DestIPGeo.Asn),
"dstip_latitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Latitude), "dst_ip_latitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Latitude),
"dstip_longitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Longitude), "dst_ip_longitude": fmt.Sprintf("%0.6f", i.DestIPGeo.Longitude),
"dstip_city": i.DestIPGeo.City, "dst_ip_city": i.DestIPGeo.City,
"dstip_continent_code": i.DestIPGeo.ContinentCode, "dst_ip_continent_code": i.DestIPGeo.ContinentCode,
"dstip_country_code": i.DestIPGeo.CountryCode, "dst_ip_country_code": i.DestIPGeo.CountryCode,
"dstip_country_name": i.DestIPGeo.CountryName, "dst_ip_country_name": i.DestIPGeo.CountryName,
"dstip_organization": i.DestIPGeo.Organization, "dst_ip_organization": i.DestIPGeo.Organization,
"srcip_asn": fmt.Sprintf("%d", i.SourceIPGeo.Asn), "src_ip_asn": fmt.Sprintf("%d", i.SourceIPGeo.Asn),
"srcip_latitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Latitude), "src_ip_latitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Latitude),
"srcip_longitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Longitude), "src_ip_longitude": fmt.Sprintf("%0.6f", i.SourceIPGeo.Longitude),
"srcip_city": i.SourceIPGeo.City, "src_ip_city": i.SourceIPGeo.City,
"srcip_continent_code": i.SourceIPGeo.ContinentCode, "src_ip_continent_code": i.SourceIPGeo.ContinentCode,
"srcip_country_code": i.SourceIPGeo.CountryCode, "src_ip_country_code": i.SourceIPGeo.CountryCode,
"srcip_country_name": i.SourceIPGeo.CountryName, "src_ip_country_name": i.SourceIPGeo.CountryName,
"srcip_organization": i.SourceIPGeo.Organization, "src_ip_organization": i.SourceIPGeo.Organization,
"admin": i.Admin, // username "admin": i.Admin, // username
"site_name": i.SiteName, "site_name": i.SiteName,
"source": i.SourceName, "source": i.SourceName,
"ap_from": i.ApFrom, "ap_from": i.ApFrom,
"ap_to": i.ApTo, "ap_to": i.ApTo,
"ap": i.Ap, "ap": i.Ap,
"ap_name": i.ApName, "ap_name": i.ApName,
"gw": i.Gw, "gw": i.Gw,
"gw_name": i.GwName, "gw_name": i.GwName,
"sw": i.Sw, "sw": i.Sw,
"sw_name": i.SwName, "sw_name": i.SwName,
"catname": i.Catname, "catname": i.Catname,
"radio": i.Radio, "radio": i.Radio,
"radio_from": i.RadioFrom, "radio_from": i.RadioFrom,
"radio_to": i.RadioTo, "radio_to": i.RadioTo,
"key": i.Key, "key": i.Key,
"in_iface": i.InIface, "in_iface": i.InIface,
"event_type": i.EventType, "event_type": i.EventType,
"subsystem": i.Subsystem, "subsystem": i.Subsystem,
"ssid": i.SSID, "ssid": i.SSID,
"is_admin": i.IsAdmin.Txt, "is_admin": i.IsAdmin.Txt,
"channel": i.Channel.Txt, "channel": i.Channel.Txt,
"channel_from": i.ChannelFrom.Txt, "channel_from": i.ChannelFrom.Txt,
"channel_to": i.ChannelTo.Txt, "channel_to": i.ChannelTo.Txt,
"usgip": i.USGIP, "usg_ip": i.USGIP,
"network": i.Network, "network": i.Network,
"app_proto": i.AppProto, "app_proto": i.AppProto,
"proto": i.Proto, "proto": i.Proto,
"action": i.InnerAlertAction, "action": i.InnerAlertAction,
} }
r.addCount(eventT) r.addCount(eventT)

View File

@ -14,12 +14,12 @@ func (u *DatadogUnifi) reportIDS(r report, i *unifi.IDS) {
tag("event_type", i.EventType), tag("event_type", i.EventType),
tag("proto", i.Proto), tag("proto", i.Proto),
tag("app_proto", i.AppProto), tag("app_proto", i.AppProto),
tag("usgip", i.Usgip), tag("usg_ip", i.USGIP),
tag("country_code", i.SrcipGeo.CountryCode), tag("country_code", i.SourceIPGeo.CountryCode),
tag("country_name", i.SrcipGeo.CountryName), tag("country_name", i.SourceIPGeo.CountryName),
tag("city", i.SrcipGeo.City), tag("city", i.SourceIPGeo.City),
tag("srcipASN", i.SrcipASN), tag("src_ip_ASN", i.SrcIPASN),
tag("usgipASN", i.UsgipASN), tag("usg_ip_ASN", i.USGIPASN),
tag("alert_category", i.InnerAlertCategory), tag("alert_category", i.InnerAlertCategory),
tag("subsystem", i.Subsystem), tag("subsystem", i.Subsystem),
tag("catname", i.Catname), tag("catname", i.Catname),

View File

@ -9,7 +9,7 @@ import (
// Logf logs a message. // Logf logs a message.
func (u *DatadogUnifi) Logf(msg string, v ...interface{}) { 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(), Ts: time.Now(),
Msg: fmt.Sprintf(msg, v...), Msg: fmt.Sprintf(msg, v...),
Tags: map[string]string{"type": "info"}, Tags: map[string]string{"type": "info"},
@ -19,7 +19,7 @@ func (u *DatadogUnifi) Logf(msg string, v ...interface{}) {
// LogErrorf logs an error message. // LogErrorf logs an error message.
func (u *DatadogUnifi) LogErrorf(msg string, v ...interface{}) { 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(), Ts: time.Now(),
Msg: fmt.Sprintf(msg, v...), Msg: fmt.Sprintf(msg, v...),
Tags: map[string]string{"type": "error"}, Tags: map[string]string{"type": "error"},
@ -29,7 +29,7 @@ func (u *DatadogUnifi) LogErrorf(msg string, v ...interface{}) {
// LogDebugf logs a debug message. // LogDebugf logs a debug message.
func (u *DatadogUnifi) LogDebugf(msg string, v ...interface{}) { 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(), Ts: time.Now(),
Msg: fmt.Sprintf(msg, v...), Msg: fmt.Sprintf(msg, v...),
Tags: map[string]string{"type": "debug"}, Tags: map[string]string{"type": "debug"},

View File

@ -26,8 +26,8 @@ func (u *DatadogUnifi) reportSite(r report, s *unifi.Site) {
"num_user": h.NumUser.Val, "num_user": h.NumUser.Val,
"num_guest": h.NumGuest.Val, "num_guest": h.NumGuest.Val,
"num_iot": h.NumIot.Val, "num_iot": h.NumIot.Val,
"tx_bytes-r": h.TxBytesR.Val, "tx_bytes_r": h.TxBytesR.Val,
"rx_bytes-r": h.RxBytesR.Val, "rx_bytes_r": h.RxBytesR.Val,
"num_ap": h.NumAp.Val, "num_ap": h.NumAp.Val,
"num_adopted": h.NumAdopted.Val, "num_adopted": h.NumAdopted.Val,
"num_disabled": h.NumDisabled.Val, "num_disabled": h.NumDisabled.Val,

View File

@ -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_rx"] = t.CuSelfRx.Val
data["cu_self_tx"] = t.CuSelfTx.Val data["cu_self_tx"] = t.CuSelfTx.Val
data["cu_total"] = t.CuTotal.Val data["cu_total"] = t.CuTotal.Val
data["extchannel"] = t.Extchannel.Val data["ext_channel"] = t.Extchannel.Val
data["gain"] = t.Gain.Val data["gain"] = t.Gain.Val
data["guest_num_sta"] = t.GuestNumSta.Val data["guest_num_sta"] = t.GuestNumSta.Val
data["num_sta"] = t.NumSta.Val data["num_sta"] = t.NumSta.Val

View File

@ -116,12 +116,12 @@ func (u *DatadogUnifi) batchUDM(r report, s *unifi.UDM) { // nolint: funlen
map[string]float64{ map[string]float64{
"bytes": s.Bytes.Val, "bytes": s.Bytes.Val,
"last_seen": s.LastSeen.Val, "last_seen": s.LastSeen.Val,
"guest-num_sta": s.GuestNumSta.Val, "guest_num_sta": s.GuestNumSta.Val,
"rx_bytes": s.RxBytes.Val, "rx_bytes": s.RxBytes.Val,
"tx_bytes": s.TxBytes.Val, "tx_bytes": s.TxBytes.Val,
"uptime": s.Uptime.Val, "uptime": s.Uptime.Val,
"state": s.State.Val, "state": s.State.Val,
"user-num_sta": s.UserNumSta.Val, "user_num_sta": s.UserNumSta.Val,
"num_desktop": s.NumDesktop.Val, "num_desktop": s.NumDesktop.Val,
"num_handheld": s.NumHandheld.Val, "num_handheld": s.NumHandheld.Val,
"num_mobile": s.NumMobile.Val, "num_mobile": s.NumMobile.Val,
@ -149,7 +149,7 @@ func (u *DatadogUnifi) batchUDM(r report, s *unifi.UDM) { // nolint: funlen
data = CombineFloat64( data = CombineFloat64(
u.batchUSWstat(s.Stat.Sw), u.batchUSWstat(s.Stat.Sw),
map[string]float64{ map[string]float64{
"guest-num_sta": s.GuestNumSta.Val, "guest_num_sta": s.GuestNumSta.Val,
"bytes": s.Bytes.Val, "bytes": s.Bytes.Val,
"last_seen": s.LastSeen.Val, "last_seen": s.LastSeen.Val,
"rx_bytes": s.RxBytes.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["tx_bytes"] = s.TxBytes.Val
data["uptime"] = s.Uptime.Val data["uptime"] = s.Uptime.Val
data["state"] = s.State.Val data["state"] = s.State.Val
data["user-num_sta"] = s.UserNumSta.Val data["user_num_sta"] = s.UserNumSta.Val
data["guest-num_sta"] = s.GuestNumSta.Val data["guest_num_sta"] = s.GuestNumSta.Val
data["num_sta"] = s.NumSta.Val data["num_sta"] = s.NumSta.Val
metricName = metricNamespace("uap") metricName = metricNamespace("uap")

View File

@ -33,12 +33,12 @@ func (u *DatadogUnifi) batchUSG(r report, s *unifi.USG) {
map[string]float64{ map[string]float64{
"bytes": s.Bytes.Val, "bytes": s.Bytes.Val,
"last_seen": s.LastSeen.Val, "last_seen": s.LastSeen.Val,
"guest-num_sta": s.GuestNumSta.Val, "guest_num_sta": s.GuestNumSta.Val,
"rx_bytes": s.RxBytes.Val, "rx_bytes": s.RxBytes.Val,
"tx_bytes": s.TxBytes.Val, "tx_bytes": s.TxBytes.Val,
"uptime": s.Uptime.Val, "uptime": s.Uptime.Val,
"state": s.State.Val, "state": s.State.Val,
"user-num_sta": s.UserNumSta.Val, "user_num_sta": s.UserNumSta.Val,
"num_desktop": s.NumDesktop.Val, "num_desktop": s.NumDesktop.Val,
"num_handheld": s.NumHandheld.Val, "num_handheld": s.NumHandheld.Val,
"num_mobile": s.NumMobile.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{ return map[string]float64{
"uplink_latency": ul.Latency.Val, "uplink_latency": ul.Latency.Val,
"uplink_speed": ul.Speed.Val, "uplink_speed": ul.Speed.Val,
"speedtest-status_latency": ss.Latency.Val, "speedtest_status_latency": ss.Latency.Val,
"speedtest-status_runtime": ss.Runtime.Val, "speedtest_status_runtime": ss.Runtime.Val,
"speedtest-status_rundate": ss.Rundate.Val, "speedtest_status_rundate": ss.Rundate.Val,
"speedtest-status_ping": ss.StatusPing.Val, "speedtest_status_ping": ss.StatusPing.Val,
"speedtest-status_xput_download": ss.XputDownload.Val, "speedtest_status_xput_download": ss.XputDownload.Val,
"speedtest-status_xput_upload": ss.XputUpload.Val, "speedtest_status_xput_upload": ss.XputUpload.Val,
"lan-rx_bytes": gw.LanRxBytes.Val, "lan_rx_bytes": gw.LanRxBytes.Val,
"lan-rx_packets": gw.LanRxPackets.Val, "lan_rx_packets": gw.LanRxPackets.Val,
"lan-tx_bytes": gw.LanTxBytes.Val, "lan_tx_bytes": gw.LanTxBytes.Val,
"lan-tx_packets": gw.LanTxPackets.Val, "lan_tx_packets": gw.LanTxPackets.Val,
"lan-rx_dropped": gw.LanRxDropped.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 fullDuplex = 1.0
} }
data := map[string]float64{ data := map[string]float64{
"bytes-r": wan.BytesR.Val, "bytes_r": wan.BytesR.Val,
"full_duplex": fullDuplex, "full_duplex": fullDuplex,
"max_speed": wan.MaxSpeed.Val, "max_speed": wan.MaxSpeed.Val,
"rx_bytes": wan.RxBytes.Val, "rx_bytes": wan.RxBytes.Val,
"rx_bytes-r": wan.RxBytesR.Val, "rx_bytes_r": wan.RxBytesR.Val,
"rx_dropped": wan.RxDropped.Val, "rx_dropped": wan.RxDropped.Val,
"rx_errors": wan.RxErrors.Val, "rx_errors": wan.RxErrors.Val,
"rx_broadcast": wan.RxBroadcast.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, "rx_packets": wan.RxPackets.Val,
"speed": wan.Speed.Val, "speed": wan.Speed.Val,
"tx_bytes": wan.TxBytes.Val, "tx_bytes": wan.TxBytes.Val,
"tx_bytes-r": wan.TxBytesR.Val, "tx_bytes_r": wan.TxBytesR.Val,
"tx_dropped": wan.TxDropped.Val, "tx_dropped": wan.TxDropped.Val,
"tx_errors": wan.TxErrors.Val, "tx_errors": wan.TxErrors.Val,
"tx_packets": wan.TxPackets.Val, "tx_packets": wan.TxPackets.Val,

View File

@ -29,8 +29,7 @@ func (u *DatadogUnifi) batchUSW(r report, s *unifi.USW) {
u.batchUSWstat(s.Stat.Sw), u.batchUSWstat(s.Stat.Sw),
u.batchSysStats(s.SysStats, s.SystemStats), u.batchSysStats(s.SysStats, s.SystemStats),
map[string]float64{ map[string]float64{
"guest-num_sta": s.GuestNumSta.Val, "guest_num_sta": s.GuestNumSta.Val,
"bytes": s.Bytes.Val, "bytes": s.Bytes.Val,
"fan_level": s.FanLevel.Val, "fan_level": s.FanLevel.Val,
"general_temperature": s.GeneralTemperature.Val, "general_temperature": s.GeneralTemperature.Val,
@ -39,7 +38,7 @@ func (u *DatadogUnifi) batchUSW(r report, s *unifi.USW) {
"tx_bytes": s.TxBytes.Val, "tx_bytes": s.TxBytes.Val,
"uptime": s.Uptime.Val, "uptime": s.Uptime.Val,
"state": s.State.Val, "state": s.State.Val,
"user-num_sta": s.UserNumSta.Val, "user_num_sta": s.UserNumSta.Val,
}) })
r.addCount(uswT) 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_idx": p.PortIdx.Txt,
"port_id": t["name"] + " Port " + p.PortIdx.Txt, "port_id": t["name"] + " Port " + p.PortIdx.Txt,
"poe_enable": p.PoeEnable.Txt, "poe_enable": p.PoeEnable.Txt,
"flowctrl_rx": p.FlowctrlRx.Txt, "flow_ctrl_rx": p.FlowctrlRx.Txt,
"flowctrl_tx": p.FlowctrlTx.Txt, "flow_ctrl_tx": p.FlowctrlTx.Txt,
"media": p.Media, "media": p.Media,
"has_sfp": p.SFPFound.Txt, "has_sfp": p.SFPFound.Txt,
"sfp_compliance": p.SFPCompliance, "sfp_compliance": p.SFPCompliance,
@ -98,23 +97,23 @@ func (u *DatadogUnifi) batchPortTable(r report, t map[string]string, pt []unifi.
"sfp_part": p.SFPPart, "sfp_part": p.SFPPart,
}) })
data := map[string]float64{ data := map[string]float64{
"dbytes_r": p.BytesR.Val, "bytes_r": p.BytesR.Val,
"rx_broadcast": p.RxBroadcast.Val, "rx_broadcast": p.RxBroadcast.Val,
"rx_bytes": p.RxBytes.Val, "rx_bytes": p.RxBytes.Val,
"rx_bytes-r": p.RxBytesR.Val, "rx_bytes_r": p.RxBytesR.Val,
"rx_dropped": p.RxDropped.Val, "rx_dropped": p.RxDropped.Val,
"rx_errors": p.RxErrors.Val, "rx_errors": p.RxErrors.Val,
"rx_multicast": p.RxMulticast.Val, "rx_multicast": p.RxMulticast.Val,
"rx_packets": p.RxPackets.Val, "rx_packets": p.RxPackets.Val,
"speed": p.Speed.Val, "speed": p.Speed.Val,
"stp_pathcost": p.StpPathcost.Val, "stp_path_cost": p.StpPathcost.Val,
"tx_broadcast": p.TxBroadcast.Val, "tx_broadcast": p.TxBroadcast.Val,
"tx_bytes": p.TxBytes.Val, "tx_bytes": p.TxBytes.Val,
"tx_bytes-r": p.TxBytesR.Val, "tx_bytes_r": p.TxBytesR.Val,
"tx_dropped": p.TxDropped.Val, "tx_dropped": p.TxDropped.Val,
"tx_errors": p.TxErrors.Val, "tx_errors": p.TxErrors.Val,
"tx_multicast": p.TxMulticast.Val, "tx_multicast": p.TxMulticast.Val,
"tx_packets": p.TxPackets.Val, "tx_packets": p.TxPackets.Val,
} }
if p.PoeEnable.Val && p.PortPoe.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_current"] = p.SFPCurrent.Val
data["sfp_voltage"] = p.SFPVoltage.Val data["sfp_voltage"] = p.SFPVoltage.Val
data["sfp_temperature"] = p.SFPTemperature.Val data["sfp_temperature"] = p.SFPTemperature.Val
data["sfp_txpower"] = p.SFPTxpower.Val data["sfp_tx_power"] = p.SFPTxpower.Val
data["sfp_rxpower"] = p.SFPRxpower.Val data["sfp_rx_power"] = p.SFPRxpower.Val
} }
metricName := metricNamespace("usw.ports") metricName := metricNamespace("usw.ports")

View File

@ -34,12 +34,12 @@ func (u *DatadogUnifi) batchUXG(r report, s *unifi.UXG) { // nolint: funlen
map[string]float64{ map[string]float64{
"bytes": s.Bytes.Val, "bytes": s.Bytes.Val,
"last_seen": s.LastSeen.Val, "last_seen": s.LastSeen.Val,
"guest-num_sta": s.GuestNumSta.Val, "guest_num_sta": s.GuestNumSta.Val,
"rx_bytes": s.RxBytes.Val, "rx_bytes": s.RxBytes.Val,
"tx_bytes": s.TxBytes.Val, "tx_bytes": s.TxBytes.Val,
"uptime": s.Uptime.Val, "uptime": s.Uptime.Val,
"state": s.State.Val, "state": s.State.Val,
"user-num_sta": s.UserNumSta.Val, "user_num_sta": s.UserNumSta.Val,
"num_desktop": s.NumDesktop.Val, "num_desktop": s.NumDesktop.Val,
"num_handheld": s.NumHandheld.Val, "num_handheld": s.NumHandheld.Val,
"num_mobile": s.NumMobile.Val, "num_mobile": s.NumMobile.Val,