From 59f23a4c8b8823686bc542c2c2c6775b411afccf Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 25 Mar 2021 01:38:05 -0700 Subject: [PATCH] add UXG and UDM storage --- integrations/promunifi/go.mod | 11 ++++++++--- integrations/promunifi/udm.go | 11 +++++++++++ integrations/promunifi/uxg.go | 8 ++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/integrations/promunifi/go.mod b/integrations/promunifi/go.mod index f76f1cb6..efa667a1 100644 --- a/integrations/promunifi/go.mod +++ b/integrations/promunifi/go.mod @@ -3,9 +3,14 @@ module github.com/unifi-poller/promunifi go 1.15 require ( - github.com/prometheus/client_golang v1.9.0 - github.com/prometheus/common v0.18.0 + github.com/golang/protobuf v1.5.1 // indirect + github.com/prometheus/client_golang v1.10.0 + github.com/prometheus/common v0.20.0 github.com/unifi-poller/poller v0.0.0-20210315075554-47d92433b172 - github.com/unifi-poller/unifi v0.0.7-0.20210315051727-4c317f9a2b95 + github.com/unifi-poller/unifi v0.0.7 github.com/unifi-poller/webserver v0.0.0-20210315055414-fa42b37295b7 + golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect + golang.org/x/net v0.0.0-20210324205630-d1beb07c2056 // indirect + golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/integrations/promunifi/udm.go b/integrations/promunifi/udm.go index 5acb4e03..a8be2943 100644 --- a/integrations/promunifi/udm.go +++ b/integrations/promunifi/udm.go @@ -10,6 +10,7 @@ type unifiDevice struct { Info *prometheus.Desc Uptime *prometheus.Desc Temperature *prometheus.Desc + Storage *prometheus.Desc TotalMaxPower *prometheus.Desc // sw only FanLevel *prometheus.Desc // sw only TotalTxBytes *prometheus.Desc @@ -39,6 +40,8 @@ func descDevice(ns string) *unifiDevice { Uptime: prometheus.NewDesc(ns+"uptime_seconds", "Device Uptime", labels, nil), Temperature: prometheus.NewDesc(ns+"temperature_celsius", "Temperature", append(labels, "temp_area", "temp_type"), nil), + Storage: prometheus.NewDesc(ns+"storage", "Storage", + append(labels, "mountpoint", "name", "valtype"), 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), @@ -89,6 +92,14 @@ func (u *promUnifi) exportUDM(r report, d *unifi.UDM) { r.send([]*metric{{u.Device.Temperature, gauge, t.Value, append(labels, t.Name, t.Type)}}) } + // UDM pro and UXG have hard drives. + for _, t := range d.Storage { + r.send([]*metric{ + {u.Device.Storage, gauge, t.Size.Val, append(labels, t.MountPoint, t.Name, "size")}, + {u.Device.Storage, gauge, t.Used.Val, append(labels, t.MountPoint, t.Name, "used")}, + }) + } + // 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/uxg.go b/integrations/promunifi/uxg.go index defe5f03..26b38575 100644 --- a/integrations/promunifi/uxg.go +++ b/integrations/promunifi/uxg.go @@ -31,4 +31,12 @@ func (u *promUnifi) exportUXG(r report, d *unifi.UXG) { for _, t := range d.Temperatures { r.send([]*metric{{u.Device.Temperature, gauge, t.Value, append(labels, t.Name, t.Type)}}) } + + // UDM pro and UXG have hard drives. + for _, t := range d.Storage { + r.send([]*metric{ + {u.Device.Storage, gauge, t.Size.Val, append(labels, t.MountPoint, t.Name, "size")}, + {u.Device.Storage, gauge, t.Used.Val, append(labels, t.MountPoint, t.Name, "used")}, + }) + } }