From 9a48c771eb686bbbabec7ccf3b114fa67c2c0b3a Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Tue, 3 Dec 2019 02:18:32 -0800 Subject: [PATCH] fixes --- .metadata.sh | 2 +- .travis.yml | 5 +++++ Makefile | 17 ----------------- pkg/promunifi/uap.go | 4 ++-- pkg/promunifi/udm.go | 6 +++--- pkg/promunifi/usg.go | 4 ++-- pkg/promunifi/usw.go | 4 ++-- 7 files changed, 15 insertions(+), 27 deletions(-) diff --git a/.metadata.sh b/.metadata.sh index 98a2d415..0a12ce22 100755 --- a/.metadata.sh +++ b/.metadata.sh @@ -11,7 +11,7 @@ HBREPO="golift/homebrew-mugs" MAINT="David Newhall II " VENDOR="Go Lift " 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 CONFIG_FILE="up.conf" LICENSE="MIT" diff --git a/.travis.yml b/.travis.yml index d0827d55..1c2f9528 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 - rvm install 2.0.0 - rvm 2.0.0 do gem install --no-document fpm + - rvm 2.0.0 gem install --no-document package_cloud 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. - 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 on: tags: true + - provider: script + script: scripts/package-deploy.sh + on: + tags: true diff --git a/Makefile b/Makefile index 672f8ff1..cfcba88b 100644 --- a/Makefile +++ b/Makefile @@ -276,20 +276,3 @@ install: man readme $(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) /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 diff --git a/pkg/promunifi/uap.go b/pkg/promunifi/uap.go index 8cec4507..cedce816 100644 --- a/pkg/promunifi/uap.go +++ b/pkg/promunifi/uap.go @@ -160,14 +160,14 @@ func descUAP(ns string) *uap { func (u *promUnifi) exportUAP(r report, d *unifi.UAP) { 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.exportVAPtable(r, labels, d.VapTable) u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) u.exportSTAcount(r, labels, d.UserNumSta, d.GuestNumSta) 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. diff --git a/pkg/promunifi/udm.go b/pkg/promunifi/udm.go index b4812f56..4cfb0c79 100644 --- a/pkg/promunifi/udm.go +++ b/pkg/promunifi/udm.go @@ -31,7 +31,7 @@ type unifiDevice struct { func descDevice(ns string) *unifiDevice { 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{ Info: prometheus.NewDesc(ns+"info", "Device Information", append(labels, infoLabels...), 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. func (u *promUnifi) exportUDM(r report, d *unifi.UDM) { 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). u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) 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.exportUSGstats(r, labels, d.Stat.Gw, d.SpeedtestStatus, d.Uplink) // 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 if d.Stat.Ap != nil && d.VapTable != nil { u.exportUAPstats(r, labels, d.Stat.Ap) diff --git a/pkg/promunifi/usg.go b/pkg/promunifi/usg.go index 62ed93e2..7ed8d7f9 100644 --- a/pkg/promunifi/usg.go +++ b/pkg/promunifi/usg.go @@ -70,14 +70,14 @@ func descUSG(ns string) *usg { func (u *promUnifi) exportUSG(r report, d *unifi.USG) { 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. u.exportWANPorts(r, labels, d.Wan1, d.Wan2) u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) 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) - r.sendone(u.Device.Info, gauge, d.Uptime, append(labels, infoLabels...)) + r.sendone(u.Device.Info, gauge, 1.0, append(labels, infoLabels...)) } // Gateway States diff --git a/pkg/promunifi/usw.go b/pkg/promunifi/usw.go index 29f4bc87..325f8cec 100644 --- a/pkg/promunifi/usw.go +++ b/pkg/promunifi/usw.go @@ -92,13 +92,13 @@ func descUSW(ns string) *usw { func (u *promUnifi) exportUSW(r report, d *unifi.USW) { 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.exportPRTtable(r, labels, d.PortTable) u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) u.exportSYSstats(r, labels, d.SysStats, d.SystemStats) 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. if d.HasTemperature.Val { r.sendone(u.Device.Temperature, gauge, d.GeneralTemperature, labels)