From 9427980ae46752e293fd4f99a1cadc74bdc5641d Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2019 12:06:08 -0700 Subject: [PATCH] text and comment updates. --- CONTRIBUTING.md | 6 +++--- Makefile | 4 ++-- cmd/unifi-poller/README.md | 5 +++-- init/homebrew/unifi-poller.rb.tmpl | 2 +- init/systemd/unifi-poller.service | 2 +- pkg/unifi-poller/config.go | 4 ++-- pkg/unifi-poller/jsondebug.go | 6 +++--- pkg/unifi-poller/poller.go | 10 +++++----- pkg/unifi-poller/unifi.go | 5 +++-- 9 files changed, 23 insertions(+), 21 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fa7c4c86..c3e07e47 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,10 +63,10 @@ too much opinion. If you want to provide a way to do something, please also prov any alternatives you're aware of. If you're not sure, just open an issue and we can hash it out. I'm reasonable. -## Unifi Library +## UniFi Library -If you're trying to fix something in the unifi data collection (ie. you got an +If you're trying to fix something in the UniFi data collection (ie. you got an unmarshal error, or you want to add something I didn't include) then you -should look at the [unifi library](https://github.com/golift/unifi). All the +should look at the [UniFi library](https://github.com/golift/unifi). All the data collection and export code lives there. Contributions and Issues are welcome on that code base as well. diff --git a/Makefile b/Makefile index b1ca8587..2c4cbfc5 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ # This Makefile is written as generic as possible. -# Setting these variables and creating the necesarry paths in your github repo will make this file work. +# Setting these variables and creating the necesarry paths in your GitHub repo will make this file work. # BINARY:=unifi-poller URL:=https://github.com/davidnewhall/$(BINARY) MAINT=David Newhall II -DESC=This daemon polls a Unifi controller at a short interval and stores the collected measurements in an Influx Database. +DESC=This daemon polls a UniFi controller at a short interval and stores the collected measurements in an Influx Database. GOLANGCI_LINT_ARGS=--enable-all -D gochecknoglobals PACKAGE:=./cmd/$(BINARY) LIBRARY:=./pkg/$(BINARY) diff --git a/cmd/unifi-poller/README.md b/cmd/unifi-poller/README.md index 9486c3f9..f56daef0 100644 --- a/cmd/unifi-poller/README.md +++ b/cmd/unifi-poller/README.md @@ -15,7 +15,7 @@ Find them at [Grafana.com](https://grafana.com/dashboards?search=unifi-poller). DESCRIPTION --- -Unifi-Poller is a small Golang application that runs on Windows, macOS, Linux or +UniFi Poller is a small Golang application that runs on Windows, macOS, Linux or Docker. It polls a UniFi controller every 30 seconds for measurements and stores the data in an Influx database. See the example configuration file for more examples and default configurations. @@ -55,7 +55,7 @@ CONFIGURATION * Possible formats: `XML`, `JSON`, `TOML`, `YAML` The config file can be written in four different syntax formats. The application -decides which one to used based on the file's name. If it contains `.xml` it will +decides which one to use based on the file's name. If it contains `.xml` it will be parsed as XML. The same goes for `.json` and `.yaml`. If the filename contains none of these strings, then it is parsed as the default format, TOML. This option is provided so the application can be easily adapted to any environment. @@ -149,3 +149,4 @@ LOCATION --- * UniFi Poller: [https://github.com/davidnewhall/unifi-poller](https://github.com/davidnewhall/unifi-poller) * UniFi Library: [https://github.com/golift/unifi](https://github.com/golift/unifi) +* Grafana Dashboards: [https://grafana.com/dashboards?search=unifi-poller](https://grafana.com/dashboards?search=unifi-poller) diff --git a/init/homebrew/unifi-poller.rb.tmpl b/init/homebrew/unifi-poller.rb.tmpl index 3d6eed61..cf6704ec 100644 --- a/init/homebrew/unifi-poller.rb.tmpl +++ b/init/homebrew/unifi-poller.rb.tmpl @@ -31,7 +31,7 @@ class UnifiPoller < Formula def caveats s = <<-EOS This application will not work until the config file has authentication - information for a Unifi Controller and an Influx Database. Edit the config + information for a UniFi Controller and an Influx Database. Edit the config file at #{etc}/unifi-poller/up.conf then start the application with brew services start unifi-poller ~ log file: #{var}/log/unifi-poller.log The manual explains the config file options: man unifi-poller diff --git a/init/systemd/unifi-poller.service b/init/systemd/unifi-poller.service index 97ed57f3..c8c65428 100644 --- a/init/systemd/unifi-poller.service +++ b/init/systemd/unifi-poller.service @@ -1,7 +1,7 @@ # Sytemd service unit for unifi-poller. [Unit] -Description=Unifi Poller - Stores Unifi Metrics in InfluxDB +Description=UniFi Poller - Stores UniFi Metrics in InfluxDB After=network.target Requires=network.target diff --git a/pkg/unifi-poller/config.go b/pkg/unifi-poller/config.go index cdc143dd..31beff55 100644 --- a/pkg/unifi-poller/config.go +++ b/pkg/unifi-poller/config.go @@ -28,7 +28,7 @@ type Asset interface { Points() ([]*influx.Point, error) } -// UnifiPoller contains the application startup data, and auth info for unifi & influx. +// UnifiPoller contains the application startup data, and auth info for UniFi & Influx. type UnifiPoller struct { ConfigFile string DumpJSON string @@ -40,7 +40,7 @@ type UnifiPoller struct { *Config } -// Metrics contains all the data from the controller and an influx endpoint to send them to. +// Metrics contains all the data from the controller and an influx endpoint to send it to. type Metrics struct { unifi.Sites unifi.Clients diff --git a/pkg/unifi-poller/jsondebug.go b/pkg/unifi-poller/jsondebug.go index 507bddb0..18f4b50a 100644 --- a/pkg/unifi-poller/jsondebug.go +++ b/pkg/unifi-poller/jsondebug.go @@ -9,14 +9,14 @@ import ( "github.com/pkg/errors" ) -// DumpJSONPayload prints raw json from the Unifi Controller. +// DumpJSONPayload prints raw json from the UniFi Controller. func (u *UnifiPoller) DumpJSONPayload() (err error) { u.Quiet = true u.Unifi, err = unifi.NewUnifi(u.UnifiUser, u.UnifiPass, u.UnifiBase, u.VerifySSL) if err != nil { return err } - fmt.Fprintln(os.Stderr, "[INFO] Authenticated to Unifi Controller @", u.UnifiBase, "as user", u.UnifiUser) + fmt.Fprintln(os.Stderr, "[INFO] Authenticated to UniFi Controller @", u.UnifiBase, "as user", u.UnifiUser) if err := u.CheckSites(); err != nil { return err } @@ -51,7 +51,7 @@ func (u *UnifiPoller) dumpSitesJSON(path, name string, sites []unifi.Site) error return nil } -// PrintRawAPIJSON prints the raw json for a user-provided path on a Unifi Controller. +// PrintRawAPIJSON prints the raw json for a user-provided path on a UniFi Controller. func (u *UnifiPoller) PrintRawAPIJSON(apiPath string) error { body, err := u.GetJSON(apiPath) fmt.Println(string(body)) diff --git a/pkg/unifi-poller/poller.go b/pkg/unifi-poller/poller.go index e21f459e..81b43bf8 100644 --- a/pkg/unifi-poller/poller.go +++ b/pkg/unifi-poller/poller.go @@ -70,7 +70,7 @@ func (u *UnifiPoller) Run() (err error) { log.SetFlags(log.Lshortfile | log.Lmicroseconds | log.Ldate) u.LogDebugf("Debug Logging Enabled") } - log.Printf("[INFO] Unifi-Poller v%v Starting Up! PID: %d", Version, os.Getpid()) + log.Printf("[INFO] UniFi Poller v%v Starting Up! PID: %d", Version, os.Getpid()) if err = u.GetUnifi(); err != nil { return err @@ -81,7 +81,7 @@ func (u *UnifiPoller) Run() (err error) { return u.PollController() } -// GetInfluxDB returns an influxdb interface. +// GetInfluxDB returns an InfluxDB interface. func (u *UnifiPoller) GetInfluxDB() (err error) { u.Client, err = influx.NewHTTPClient(influx.HTTPConfig{ Addr: u.InfluxURL, @@ -95,7 +95,7 @@ func (u *UnifiPoller) GetInfluxDB() (err error) { return nil } -// GetUnifi returns a Unifi controller interface. +// GetUnifi returns a UniFi controller interface. func (u *UnifiPoller) GetUnifi() (err error) { // Create an authenticated session to the Unifi Controller. u.Unifi, err = unifi.NewUnifi(u.UnifiUser, u.UnifiPass, u.UnifiBase, u.VerifySSL) @@ -108,10 +108,10 @@ func (u *UnifiPoller) GetUnifi() (err error) { if err != nil { v.ServerVersion = "unknown" } - u.Logf("Authenticated to Unifi Controller at %s version %s as user %s", u.UnifiBase, v.ServerVersion, u.UnifiUser) + u.Logf("Authenticated to UniFi Controller at %s version %s as user %s", u.UnifiBase, v.ServerVersion, u.UnifiUser) if err = u.CheckSites(); err != nil { return err } - u.Logf("Polling Unifi Controller Sites: %v", u.Sites) + u.Logf("Polling UniFi Controller Sites: %v", u.Sites) return nil } diff --git a/pkg/unifi-poller/unifi.go b/pkg/unifi-poller/unifi.go index 816d8db1..4fcd2bbe 100644 --- a/pkg/unifi-poller/unifi.go +++ b/pkg/unifi-poller/unifi.go @@ -37,7 +37,8 @@ FIRST: return nil } -// PollController runs forever, polling unifi, and pushing to influx. +// PollController runs forever, polling UniFi, and pushing to influx. +// This is started by Run() after everything checks out. func (u *UnifiPoller) PollController() error { log.Println("[INFO] Everything checks out! Poller started, interval:", u.Interval.Round(time.Second)) ticker := time.NewTicker(u.Interval.Round(time.Second)) @@ -77,7 +78,7 @@ func (u *UnifiPoller) PollController() error { i, _ := p.Fields() fieldcount += len(i) } - u.Logf("Unifi Measurements Recorded. Sites: %d, Clients: %d, "+ + u.Logf("UniFi Measurements Recorded. Sites: %d, Clients: %d, "+ "Wireless APs: %d, Gateways: %d, Switches: %d, Points: %d, Fields: %d", len(m.Sites), len(m.Clients), len(m.UAPs), len(m.USGs), len(m.USWs), pointcount, fieldcount)