add UXG and UDM storage
This commit is contained in:
		
							parent
							
								
									479a7679b1
								
							
						
					
					
						commit
						59f23a4c8b
					
				|  | @ -3,9 +3,14 @@ module github.com/unifi-poller/promunifi | ||||||
| go 1.15 | go 1.15 | ||||||
| 
 | 
 | ||||||
| require ( | require ( | ||||||
| 	github.com/prometheus/client_golang v1.9.0 | 	github.com/golang/protobuf v1.5.1 // indirect | ||||||
| 	github.com/prometheus/common v0.18.0 | 	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/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 | 	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 | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ type unifiDevice struct { | ||||||
| 	Info          *prometheus.Desc | 	Info          *prometheus.Desc | ||||||
| 	Uptime        *prometheus.Desc | 	Uptime        *prometheus.Desc | ||||||
| 	Temperature   *prometheus.Desc | 	Temperature   *prometheus.Desc | ||||||
|  | 	Storage       *prometheus.Desc | ||||||
| 	TotalMaxPower *prometheus.Desc // sw only
 | 	TotalMaxPower *prometheus.Desc // sw only
 | ||||||
| 	FanLevel      *prometheus.Desc // sw only
 | 	FanLevel      *prometheus.Desc // sw only
 | ||||||
| 	TotalTxBytes  *prometheus.Desc | 	TotalTxBytes  *prometheus.Desc | ||||||
|  | @ -39,6 +40,8 @@ func descDevice(ns string) *unifiDevice { | ||||||
| 		Uptime: prometheus.NewDesc(ns+"uptime_seconds", "Device Uptime", labels, nil), | 		Uptime: prometheus.NewDesc(ns+"uptime_seconds", "Device Uptime", labels, nil), | ||||||
| 		Temperature: prometheus.NewDesc(ns+"temperature_celsius", "Temperature", | 		Temperature: prometheus.NewDesc(ns+"temperature_celsius", "Temperature", | ||||||
| 			append(labels, "temp_area", "temp_type"), nil), | 			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), | 		TotalMaxPower: prometheus.NewDesc(ns+"max_power_total", "Total Max Power", labels, nil), | ||||||
| 		FanLevel:      prometheus.NewDesc(ns+"fan_level", "Fan Level", labels, nil), | 		FanLevel:      prometheus.NewDesc(ns+"fan_level", "Fan Level", labels, nil), | ||||||
| 		TotalTxBytes:  prometheus.NewDesc(ns+"transmit_bytes_total", "Total Transmitted Bytes", 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)}}) | 		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
 | 	// Wireless Data - UDM (non-pro) only
 | ||||||
| 	if d.Stat.Ap != nil && d.VapTable != nil { | 	if d.Stat.Ap != nil && d.VapTable != nil { | ||||||
| 		u.exportUAPstats(r, labels, d.Stat.Ap, d.BytesD, d.TxBytesD, d.RxBytesD, d.BytesR) | 		u.exportUAPstats(r, labels, d.Stat.Ap, d.BytesD, d.TxBytesD, d.RxBytesD, d.BytesR) | ||||||
|  |  | ||||||
|  | @ -31,4 +31,12 @@ func (u *promUnifi) exportUXG(r report, d *unifi.UXG) { | ||||||
| 	for _, t := range d.Temperatures { | 	for _, t := range d.Temperatures { | ||||||
| 		r.send([]*metric{{u.Device.Temperature, gauge, t.Value, append(labels, t.Name, t.Type)}}) | 		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")}, | ||||||
|  | 		}) | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue