fixes
This commit is contained in:
		
							parent
							
								
									dbe0a6bc94
								
							
						
					
					
						commit
						9a48c771eb
					
				|  | @ -11,7 +11,7 @@ HBREPO="golift/homebrew-mugs" | ||||||
| MAINT="David Newhall II <david at sleepers dot pro>" | MAINT="David Newhall II <david at sleepers dot pro>" | ||||||
| VENDOR="Go Lift <code at golift dot io>" | VENDOR="Go Lift <code at golift dot io>" | ||||||
| DESC="Polls a UniFi controller and exports metrics to InfluxDB" | DESC="Polls a UniFi controller and exports metrics to InfluxDB" | ||||||
| GOLANGCI_LINT_ARGS="--enable-all -D gochecknoglobals -D dupl -D lll -D funlen -D wsl -e G402" | GOLANGCI_LINT_ARGS="--enable-all -D gochecknoglobals -D dupl -D lll -D funlen -D wsl -e G402 -D gomnd" | ||||||
| # Example must exist at examples/$CONFIG_FILE.example | # Example must exist at examples/$CONFIG_FILE.example | ||||||
| CONFIG_FILE="up.conf" | CONFIG_FILE="up.conf" | ||||||
| LICENSE="MIT" | LICENSE="MIT" | ||||||
|  |  | ||||||
|  | @ -25,6 +25,7 @@ install: | ||||||
|   - curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest |   - curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest | ||||||
|   - rvm install 2.0.0 |   - rvm install 2.0.0 | ||||||
|   - rvm 2.0.0 do gem install --no-document fpm |   - rvm 2.0.0 do gem install --no-document fpm | ||||||
|  |   - rvm 2.0.0 gem install --no-document package_cloud | ||||||
| before_script: | before_script: | ||||||
|   # Create your own deploy key, tar it, and encrypt the file to make this work. Optionally add a bitly_token file to the archive. |   # Create your own deploy key, tar it, and encrypt the file to make this work. Optionally add a bitly_token file to the archive. | ||||||
|   - openssl aes-256-cbc -K $encrypted_e3d3b4b2abab_key -iv $encrypted_e3d3b4b2abab_iv -in .secret-files.tar.enc -out .secret-files.tar -d |   - openssl aes-256-cbc -K $encrypted_e3d3b4b2abab_key -iv $encrypted_e3d3b4b2abab_iv -in .secret-files.tar.enc -out .secret-files.tar -d | ||||||
|  | @ -70,3 +71,7 @@ deploy: | ||||||
|     script: scripts/formula-deploy.sh |     script: scripts/formula-deploy.sh | ||||||
|     on: |     on: | ||||||
|       tags: true |       tags: true | ||||||
|  |   - provider: script | ||||||
|  |     script: scripts/package-deploy.sh | ||||||
|  |     on: | ||||||
|  |       tags: true | ||||||
|  |  | ||||||
							
								
								
									
										17
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										17
									
								
								Makefile
								
								
								
								
							|  | @ -276,20 +276,3 @@ install: man readme $(BINARY) | ||||||
| 	/usr/bin/install -m 0644 -cp examples/$(CONFIG_FILE).example $(ETC)/$(BINARY)/ | 	/usr/bin/install -m 0644 -cp examples/$(CONFIG_FILE).example $(ETC)/$(BINARY)/ | ||||||
| 	[ -f $(ETC)/$(BINARY)/$(CONFIG_FILE) ] || /usr/bin/install -m 0644 -cp  examples/$(CONFIG_FILE).example $(ETC)/$(BINARY)/$(CONFIG_FILE) | 	[ -f $(ETC)/$(BINARY)/$(CONFIG_FILE) ] || /usr/bin/install -m 0644 -cp  examples/$(CONFIG_FILE).example $(ETC)/$(BINARY)/$(CONFIG_FILE) | ||||||
| 	/usr/bin/install -m 0644 -cp LICENSE *.html examples/* $(PREFIX)/share/doc/$(BINARY)/ | 	/usr/bin/install -m 0644 -cp LICENSE *.html examples/* $(PREFIX)/share/doc/$(BINARY)/ | ||||||
| 
 |  | ||||||
| # If you installed with `make install` run `make uninstall` before installing a binary package. (even on Linux!!!)
 |  | ||||||
| # This will remove the package install from macOS, it will not remove a package install from Linux.
 |  | ||||||
| uninstall: |  | ||||||
| 	@echo "  ==> You must run make uninstall as root on Linux. Recommend not running as root on macOS." |  | ||||||
| 	[ -x /bin/systemctl ] && /bin/systemctl disable $(BINARY) || true |  | ||||||
| 	[ -x /bin/systemctl ] && /bin/systemctl stop $(BINARY) || true |  | ||||||
| 	[ -x /bin/launchctl ] && [ -f ~/Library/LaunchAgents/com.github.$(GHUSER).$(BINARY).plist ] \
 |  | ||||||
| 		&& /bin/launchctl unload ~/Library/LaunchAgents/com.github.$(GHUSER).$(BINARY).plist || true |  | ||||||
| 	[ -x /bin/launchctl ] && [ -f /Library/LaunchAgents/com.github.$(GHUSER).$(BINARY).plist ] \
 |  | ||||||
| 		&& /bin/launchctl unload /Library/LaunchAgents/com.github.$(GHUSER).$(BINARY).plist || true |  | ||||||
| 	rm -rf /usr/local/{etc,bin,share/doc}/$(BINARY) |  | ||||||
| 	rm -f ~/Library/LaunchAgents/com.github.$(GHUSER).$(BINARY).plist |  | ||||||
| 	rm -f /Library/LaunchAgents/com.github.$(GHUSER).$(BINARY).plist || true |  | ||||||
| 	rm -f /etc/systemd/system/$(BINARY).service /usr/local/share/man/man1/$(BINARY).1.gz |  | ||||||
| 	[ -x /bin/systemctl ] && /bin/systemctl --system daemon-reload || true |  | ||||||
| 	@[ -f /Library/LaunchAgents/com.github.$(GHUSER).$(BINARY).plist ] && echo "  ==> Unload and delete this file manually:" && echo "  sudo launchctl unload /Library/LaunchAgents/com.github.$(GHUSER).$(BINARY).plist" && echo "  sudo rm -f /Library/LaunchAgents/com.github.$(GHUSER).$(BINARY).plist" || true |  | ||||||
|  |  | ||||||
|  | @ -160,14 +160,14 @@ func descUAP(ns string) *uap { | ||||||
| 
 | 
 | ||||||
| func (u *promUnifi) exportUAP(r report, d *unifi.UAP) { | func (u *promUnifi) exportUAP(r report, d *unifi.UAP) { | ||||||
| 	labels := []string{d.Type, d.SiteName, d.Name} | 	labels := []string{d.Type, d.SiteName, d.Name} | ||||||
| 	infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt} | 	infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} | ||||||
| 	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) | ||||||
| 	u.exportVAPtable(r, labels, d.VapTable) | 	u.exportVAPtable(r, labels, d.VapTable) | ||||||
| 	u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) | 	u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) | ||||||
| 	u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) | 	u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) | ||||||
| 	u.exportSTAcount(r, labels, d.UserNumSta, d.GuestNumSta) | 	u.exportSTAcount(r, labels, d.UserNumSta, d.GuestNumSta) | ||||||
| 	u.exportRADtable(r, labels, d.RadioTable, d.RadioTableStats) | 	u.exportRADtable(r, labels, d.RadioTable, d.RadioTableStats) | ||||||
| 	r.sendone(u.Device.Info, gauge, d.Uptime, append(labels, infoLabels...)) | 	r.sendone(u.Device.Info, gauge, 1.0, append(labels, infoLabels...)) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // udm doesn't have these stats exposed yet, so pass 2 or 6 metrics.
 | // udm doesn't have these stats exposed yet, so pass 2 or 6 metrics.
 | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ type unifiDevice struct { | ||||||
| 
 | 
 | ||||||
| func descDevice(ns string) *unifiDevice { | func descDevice(ns string) *unifiDevice { | ||||||
| 	labels := []string{"type", "site_name", "name"} | 	labels := []string{"type", "site_name", "name"} | ||||||
| 	infoLabels := []string{"version", "model", "serial", "mac", "ip", "id", "bytes"} | 	infoLabels := []string{"version", "model", "serial", "mac", "ip", "id", "bytes", "uptime"} | ||||||
| 	return &unifiDevice{ | 	return &unifiDevice{ | ||||||
| 		Info:          prometheus.NewDesc(ns+"info", "Device Information", append(labels, infoLabels...), nil), | 		Info:          prometheus.NewDesc(ns+"info", "Device Information", append(labels, infoLabels...), nil), | ||||||
| 		Temperature:   prometheus.NewDesc(ns+"temperature_celsius", "Temperature", labels, nil), | 		Temperature:   prometheus.NewDesc(ns+"temperature_celsius", "Temperature", labels, nil), | ||||||
|  | @ -59,7 +59,7 @@ func descDevice(ns string) *unifiDevice { | ||||||
| // UDM is a collection of stats from USG, USW and UAP. It has no unique stats.
 | // UDM is a collection of stats from USG, USW and UAP. It has no unique stats.
 | ||||||
| func (u *promUnifi) exportUDM(r report, d *unifi.UDM) { | func (u *promUnifi) exportUDM(r report, d *unifi.UDM) { | ||||||
| 	labels := []string{d.Type, d.SiteName, d.Name} | 	labels := []string{d.Type, d.SiteName, d.Name} | ||||||
| 	infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt} | 	infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} | ||||||
| 	// Shared data (all devices do this).
 | 	// Shared data (all devices do this).
 | ||||||
| 	u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) | 	u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) | ||||||
| 	u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) | 	u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) | ||||||
|  | @ -71,7 +71,7 @@ func (u *promUnifi) exportUDM(r report, d *unifi.UDM) { | ||||||
| 	u.exportWANPorts(r, labels, d.Wan1, d.Wan2) | 	u.exportWANPorts(r, labels, d.Wan1, d.Wan2) | ||||||
| 	u.exportUSGstats(r, labels, d.Stat.Gw, d.SpeedtestStatus, d.Uplink) | 	u.exportUSGstats(r, labels, d.Stat.Gw, d.SpeedtestStatus, d.Uplink) | ||||||
| 	// Dream Machine System Data.
 | 	// Dream Machine System Data.
 | ||||||
| 	r.sendone(u.Device.Info, gauge, d.Uptime, append(labels, infoLabels...)) | 	r.sendone(u.Device.Info, gauge, 1.0, append(labels, infoLabels...)) | ||||||
| 	// 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) | 		u.exportUAPstats(r, labels, d.Stat.Ap) | ||||||
|  |  | ||||||
|  | @ -70,14 +70,14 @@ func descUSG(ns string) *usg { | ||||||
| 
 | 
 | ||||||
| func (u *promUnifi) exportUSG(r report, d *unifi.USG) { | func (u *promUnifi) exportUSG(r report, d *unifi.USG) { | ||||||
| 	labels := []string{d.Type, d.SiteName, d.Name} | 	labels := []string{d.Type, d.SiteName, d.Name} | ||||||
| 	infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt} | 	infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} | ||||||
| 	// Gateway System Data.
 | 	// Gateway System Data.
 | ||||||
| 	u.exportWANPorts(r, labels, d.Wan1, d.Wan2) | 	u.exportWANPorts(r, labels, d.Wan1, d.Wan2) | ||||||
| 	u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) | 	u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) | ||||||
| 	u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) | 	u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) | ||||||
| 	u.exportUSGstats(r, labels, d.Stat.Gw, d.SpeedtestStatus, d.Uplink) | 	u.exportUSGstats(r, labels, d.Stat.Gw, d.SpeedtestStatus, d.Uplink) | ||||||
| 	u.exportSTAcount(r, labels, d.UserNumSta, d.GuestNumSta, d.NumDesktop, d.UserNumSta, d.GuestNumSta) | 	u.exportSTAcount(r, labels, d.UserNumSta, d.GuestNumSta, d.NumDesktop, d.UserNumSta, d.GuestNumSta) | ||||||
| 	r.sendone(u.Device.Info, gauge, d.Uptime, append(labels, infoLabels...)) | 	r.sendone(u.Device.Info, gauge, 1.0, append(labels, infoLabels...)) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Gateway States
 | // Gateway States
 | ||||||
|  |  | ||||||
|  | @ -92,13 +92,13 @@ func descUSW(ns string) *usw { | ||||||
| 
 | 
 | ||||||
| func (u *promUnifi) exportUSW(r report, d *unifi.USW) { | func (u *promUnifi) exportUSW(r report, d *unifi.USW) { | ||||||
| 	labels := []string{d.Type, d.SiteName, d.Name} | 	labels := []string{d.Type, d.SiteName, d.Name} | ||||||
| 	infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt} | 	infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} | ||||||
| 	u.exportUSWstats(r, labels, d.Stat.Sw) | 	u.exportUSWstats(r, labels, d.Stat.Sw) | ||||||
| 	u.exportPRTtable(r, labels, d.PortTable) | 	u.exportPRTtable(r, labels, d.PortTable) | ||||||
| 	u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) | 	u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) | ||||||
| 	u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) | 	u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) | ||||||
| 	u.exportSTAcount(r, labels, d.UserNumSta, d.GuestNumSta) | 	u.exportSTAcount(r, labels, d.UserNumSta, d.GuestNumSta) | ||||||
| 	r.sendone(u.Device.Info, gauge, d.Uptime, append(labels, infoLabels...)) | 	r.sendone(u.Device.Info, gauge, 1.0, append(labels, infoLabels...)) | ||||||
| 	// Switch System Data.
 | 	// Switch System Data.
 | ||||||
| 	if d.HasTemperature.Val { | 	if d.HasTemperature.Val { | ||||||
| 		r.sendone(u.Device.Temperature, gauge, d.GeneralTemperature, labels) | 		r.sendone(u.Device.Temperature, gauge, d.GeneralTemperature, labels) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue