From 884cf4f2e245a090122b0dc5302ee2f40f0aa9c1 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 14 Mar 2021 22:27:40 -0700 Subject: [PATCH] add more temps for USG --- integrations/promunifi/go.mod | 2 +- integrations/promunifi/usg.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/integrations/promunifi/go.mod b/integrations/promunifi/go.mod index a237c6c4..0d873cc5 100644 --- a/integrations/promunifi/go.mod +++ b/integrations/promunifi/go.mod @@ -6,6 +6,6 @@ require ( github.com/prometheus/client_golang v1.9.0 github.com/prometheus/common v0.18.0 github.com/unifi-poller/poller v0.0.8 - github.com/unifi-poller/unifi v0.0.7-0.20210315003727-a4802cb45269 + github.com/unifi-poller/unifi v0.0.7-0.20210315051727-4c317f9a2b95 github.com/unifi-poller/webserver v0.0.0-20200628212441-340749c94743 ) diff --git a/integrations/promunifi/usg.go b/integrations/promunifi/usg.go index 0d508bbd..5112c1c6 100644 --- a/integrations/promunifi/usg.go +++ b/integrations/promunifi/usg.go @@ -1,6 +1,9 @@ package promunifi import ( + "strconv" + "strings" + "github.com/prometheus/client_golang/prometheus" "github.com/unifi-poller/unifi" ) @@ -83,6 +86,15 @@ func (u *promUnifi) exportUSG(r report, d *unifi.USG) { r.send([]*metric{{u.Device.Temperature, gauge, t.Value, append(labels, t.Name, t.Type)}}) } + for k, v := range d.SystemStats.Temps { + temp, _ := strconv.ParseInt(strings.Split(v, " ")[0], 10, 64) + k = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(k, " ", "_"), ")", ""), "(", "") + + if k = strings.ToLower(k); temp != 0 && k != "" { + r.send([]*metric{{u.Device.Temperature, gauge, temp, append(labels, k, k)}}) + } + } + // Gateway System Data. u.exportWANPorts(r, labels, d.Wan1, d.Wan2) u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes)