From d54beeec9644692a25b5682ae36d9ac64782471d Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Sat, 13 Jun 2020 20:28:56 -0700 Subject: [PATCH 1/2] Add UDM temp, and remove Info label metrics --- integrations/promunifi/go.mod | 4 +--- integrations/promunifi/go.sum | 7 +++++++ integrations/promunifi/uap.go | 2 +- integrations/promunifi/udm.go | 16 +++++++++++----- integrations/promunifi/usg.go | 2 +- integrations/promunifi/usw.go | 4 ++-- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/integrations/promunifi/go.mod b/integrations/promunifi/go.mod index 5c83f357..1a942f24 100644 --- a/integrations/promunifi/go.mod +++ b/integrations/promunifi/go.mod @@ -8,7 +8,5 @@ require ( github.com/prometheus/common v0.9.1 github.com/prometheus/procfs v0.0.10 // indirect github.com/unifi-poller/poller v0.0.5 - github.com/unifi-poller/unifi v0.0.4 - golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect - golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect + github.com/unifi-poller/unifi v0.0.5-0.20200614031431-bd4934fc585b ) diff --git a/integrations/promunifi/go.sum b/integrations/promunifi/go.sum index 9676cb24..7d839b42 100644 --- a/integrations/promunifi/go.sum +++ b/integrations/promunifi/go.sum @@ -47,6 +47,8 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= @@ -96,6 +98,8 @@ github.com/unifi-poller/unifi v0.0.3 h1:6pmjW7MuEEDKKvYoxjL3EZlaLOgmhYyxJBAg4X7G github.com/unifi-poller/unifi v0.0.3/go.mod h1:DagVD/I+VMnVUHmTT4Fi76lPI+DHbuMwwtMIzanwMxM= github.com/unifi-poller/unifi v0.0.4 h1:NDTxHTdF0MAt1y1RU8J+MSqdYlO0CEIqlrktcj3y/og= github.com/unifi-poller/unifi v0.0.4/go.mod h1:bTUtctrf56aapjKH+L+98eThBaVFbQXw5iNGZI0g/+E= +github.com/unifi-poller/unifi v0.0.5-0.20200614031431-bd4934fc585b h1:g3nleMBVzn/0PVwzoNYCwioFgYjzOxMByAO66a/tTf0= +github.com/unifi-poller/unifi v0.0.5-0.20200614031431-bd4934fc585b/go.mod h1:L1kMRH2buZhB31vZnRC1im7Tk/4uD3ET4biwl2faYy8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -104,6 +108,8 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjut golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -119,6 +125,7 @@ golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfru golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golift.io/cnfg v0.0.5 h1:HnMU8Z9C/igKvir1dqaHx5BPuNGZrp99FCtdJyP2Z4I= diff --git a/integrations/promunifi/uap.go b/integrations/promunifi/uap.go index eb921137..4a7bc9ae 100644 --- a/integrations/promunifi/uap.go +++ b/integrations/promunifi/uap.go @@ -166,7 +166,7 @@ func (u *promUnifi) exportUAP(r report, d *unifi.UAP) { } labels := []string{d.Type, d.SiteName, d.Name, d.SourceName} - infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} + infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID} u.exportUAPstats(r, labels, d.Stat.Ap, d.BytesD, d.TxBytesD, d.RxBytesD, d.BytesR) u.exportVAPtable(r, labels, d.VapTable) u.exportPRTtable(r, labels, d.PortTable) diff --git a/integrations/promunifi/udm.go b/integrations/promunifi/udm.go index b73b0117..19283930 100644 --- a/integrations/promunifi/udm.go +++ b/integrations/promunifi/udm.go @@ -32,12 +32,13 @@ type unifiDevice struct { func descDevice(ns string) *unifiDevice { labels := []string{"type", "site_name", "name", "source"} - infoLabels := []string{"version", "model", "serial", "mac", "ip", "id", "bytes", "uptime"} + infoLabels := []string{"version", "model", "serial", "mac", "ip", "id"} return &unifiDevice{ - Info: prometheus.NewDesc(ns+"info", "Device Information", append(labels, infoLabels...), nil), - Uptime: prometheus.NewDesc(ns+"uptime_seconds", "Device Uptime", labels, nil), - Temperature: prometheus.NewDesc(ns+"temperature_celsius", "Temperature", labels, nil), + Info: prometheus.NewDesc(ns+"info", "Device Information", append(labels, infoLabels...), nil), + Uptime: prometheus.NewDesc(ns+"uptime_seconds", "Device Uptime", labels, nil), + Temperature: prometheus.NewDesc(ns+"temperature_celsius", "Temperature", + append(labels, "temp_area", "temp_type"), nil), TotalMaxPower: prometheus.NewDesc(ns+"max_power_total", "Total Max Power", labels, nil), FanLevel: prometheus.NewDesc(ns+"fan_level", "Fan Level", labels, nil), TotalTxBytes: prometheus.NewDesc(ns+"transmit_bytes_total", "Total Transmitted Bytes", labels, nil), @@ -66,7 +67,7 @@ func (u *promUnifi) exportUDM(r report, d *unifi.UDM) { } labels := []string{d.Type, d.SiteName, d.Name, d.SourceName} - infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} + infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID} // Shared data (all devices do this). u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) @@ -83,6 +84,11 @@ func (u *promUnifi) exportUDM(r report, d *unifi.UDM) { {u.Device.Uptime, gauge, d.Uptime, labels}, }) + // UDM pro has special temp sensors. UDM non-pro may not have temp; not sure. + for _, t := range d.Temperatures { + r.send([]*metric{{u.Device.Temperature, gauge, t.Value, append(labels, t.Name, t.Type)}}) + } + // Wireless Data - UDM (non-pro) only if d.Stat.Ap != nil && d.VapTable != nil { u.exportUAPstats(r, labels, d.Stat.Ap, d.BytesD, d.TxBytesD, d.RxBytesD, d.BytesR) diff --git a/integrations/promunifi/usg.go b/integrations/promunifi/usg.go index da945bb5..7c94deb5 100644 --- a/integrations/promunifi/usg.go +++ b/integrations/promunifi/usg.go @@ -77,7 +77,7 @@ func (u *promUnifi) exportUSG(r report, d *unifi.USG) { } labels := []string{d.Type, d.SiteName, d.Name, d.SourceName} - infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} + infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID} // Gateway System Data. u.exportWANPorts(r, labels, d.Wan1, d.Wan2) diff --git a/integrations/promunifi/usw.go b/integrations/promunifi/usw.go index d8e7f970..eae941fa 100644 --- a/integrations/promunifi/usw.go +++ b/integrations/promunifi/usw.go @@ -98,7 +98,7 @@ func (u *promUnifi) exportUSW(r report, d *unifi.USW) { } labels := []string{d.Type, d.SiteName, d.Name, d.SourceName} - infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} + infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID} u.exportUSWstats(r, labels, d.Stat.Sw) u.exportPRTtable(r, labels, d.PortTable) @@ -112,7 +112,7 @@ func (u *promUnifi) exportUSW(r report, d *unifi.USW) { // Switch System Data. if d.HasTemperature.Val { - r.send([]*metric{{u.Device.Temperature, gauge, d.GeneralTemperature, labels}}) + r.send([]*metric{{u.Device.Temperature, gauge, d.GeneralTemperature, append(labels, "general", "board")}}) } if d.HasFan.Val { From 7b04d8a9df5aaea979989511fc2247fd183f6a48 Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Sat, 13 Jun 2020 20:48:34 -0700 Subject: [PATCH 2/2] minor change --- integrations/promunifi/go.mod | 2 +- integrations/promunifi/go.sum | 2 ++ integrations/promunifi/udm.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/integrations/promunifi/go.mod b/integrations/promunifi/go.mod index 1a942f24..d6c664fe 100644 --- a/integrations/promunifi/go.mod +++ b/integrations/promunifi/go.mod @@ -8,5 +8,5 @@ require ( github.com/prometheus/common v0.9.1 github.com/prometheus/procfs v0.0.10 // indirect github.com/unifi-poller/poller v0.0.5 - github.com/unifi-poller/unifi v0.0.5-0.20200614031431-bd4934fc585b + github.com/unifi-poller/unifi v0.0.5-0.20200614034623-f4c1d18157c2 ) diff --git a/integrations/promunifi/go.sum b/integrations/promunifi/go.sum index 7d839b42..6ce31509 100644 --- a/integrations/promunifi/go.sum +++ b/integrations/promunifi/go.sum @@ -100,6 +100,8 @@ github.com/unifi-poller/unifi v0.0.4 h1:NDTxHTdF0MAt1y1RU8J+MSqdYlO0CEIqlrktcj3y github.com/unifi-poller/unifi v0.0.4/go.mod h1:bTUtctrf56aapjKH+L+98eThBaVFbQXw5iNGZI0g/+E= github.com/unifi-poller/unifi v0.0.5-0.20200614031431-bd4934fc585b h1:g3nleMBVzn/0PVwzoNYCwioFgYjzOxMByAO66a/tTf0= github.com/unifi-poller/unifi v0.0.5-0.20200614031431-bd4934fc585b/go.mod h1:L1kMRH2buZhB31vZnRC1im7Tk/4uD3ET4biwl2faYy8= +github.com/unifi-poller/unifi v0.0.5-0.20200614034623-f4c1d18157c2 h1:iDOUe8UECHQoOyzWIarbGNVdwEth16iiUsw+1UgQ+sw= +github.com/unifi-poller/unifi v0.0.5-0.20200614034623-f4c1d18157c2/go.mod h1:L1kMRH2buZhB31vZnRC1im7Tk/4uD3ET4biwl2faYy8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/integrations/promunifi/udm.go b/integrations/promunifi/udm.go index 19283930..dce948fd 100644 --- a/integrations/promunifi/udm.go +++ b/integrations/promunifi/udm.go @@ -9,7 +9,7 @@ import ( type unifiDevice struct { Info *prometheus.Desc Uptime *prometheus.Desc - Temperature *prometheus.Desc // sw only + Temperature *prometheus.Desc // sw,udmp only TotalMaxPower *prometheus.Desc // sw only FanLevel *prometheus.Desc // sw only TotalTxBytes *prometheus.Desc