From 65dfedcf27cbd32e70d47a8db3bbc2053dd33a19 Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Tue, 10 Dec 2019 01:01:54 -0800 Subject: [PATCH] got it --- pkg/poller/start.go | 1 + pkg/promunifi/collector.go | 2 -- pkg/promunifi/uap.go | 4 ---- pkg/promunifi/usg.go | 3 +++ pkg/promunifi/usw.go | 3 +++ 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/poller/start.go b/pkg/poller/start.go index 4ef96124..d2c63083 100644 --- a/pkg/poller/start.go +++ b/pkg/poller/start.go @@ -36,6 +36,7 @@ func New() *UnifiPoller { // Parses cli flags, parses config file, parses env vars, sets up logging, then: // - dumps a json payload OR - executes Run(). func (u *UnifiPoller) Start() error { + log.SetOutput(os.Stdout) log.SetFlags(log.LstdFlags) u.Flag.Parse(os.Args[1:]) diff --git a/pkg/promunifi/collector.go b/pkg/promunifi/collector.go index e54ef6c4..aa14b1a8 100644 --- a/pkg/promunifi/collector.go +++ b/pkg/promunifi/collector.go @@ -3,7 +3,6 @@ package promunifi import ( "fmt" - "log" "reflect" "strings" "sync" @@ -113,7 +112,6 @@ func (u *promUnifi) Collect(ch chan<- prometheus.Metric) { defer r.close() if r.Metrics, err = r.cf.CollectFn(); err != nil { - log.Println("Error", err) r.error(ch, prometheus.NewInvalidDesc(fmt.Errorf("metric fetch failed")), err) return } diff --git a/pkg/promunifi/uap.go b/pkg/promunifi/uap.go index b21d8491..658162d3 100644 --- a/pkg/promunifi/uap.go +++ b/pkg/promunifi/uap.go @@ -1,8 +1,6 @@ package promunifi import ( - "log" - "github.com/prometheus/client_golang/prometheus" "golift.io/unifi" ) @@ -178,10 +176,8 @@ func (u *promUnifi) exportUAP(r report, d *unifi.UAP) { // udm doesn't have these stats exposed yet, so pass 2 or 6 metrics. func (u *promUnifi) exportUAPstats(r report, labels []string, ap *unifi.Ap, bytes ...unifi.FlexInt) { if ap == nil { - log.Println("ap was nil?!", labels[2]) return } - log.Println("ap not nil") labelU := []string{"user", labels[1], labels[2]} labelG := []string{"guest", labels[1], labels[2]} r.send([]*metric{ diff --git a/pkg/promunifi/usg.go b/pkg/promunifi/usg.go index 6c2ffd01..b4005b1c 100644 --- a/pkg/promunifi/usg.go +++ b/pkg/promunifi/usg.go @@ -85,6 +85,9 @@ func (u *promUnifi) exportUSG(r report, d *unifi.USG) { // Gateway States func (u *promUnifi) exportUSGstats(r report, labels []string, gw *unifi.Gw, st unifi.SpeedtestStatus, ul unifi.Uplink) { + if gw == nil { + return + } labelLan := []string{"lan", labels[1], labels[2]} labelWan := []string{"all", labels[1], labels[2]} r.send([]*metric{ diff --git a/pkg/promunifi/usw.go b/pkg/promunifi/usw.go index 831e71ee..b77821d1 100644 --- a/pkg/promunifi/usw.go +++ b/pkg/promunifi/usw.go @@ -116,6 +116,9 @@ func (u *promUnifi) exportUSW(r report, d *unifi.USW) { // Switch Stats func (u *promUnifi) exportUSWstats(r report, labels []string, sw *unifi.Sw) { + if sw == nil { + return + } labelS := labels[1:] r.send([]*metric{ {u.USW.SwRxPackets, counter, sw.RxPackets, labelS},