This commit is contained in:
davidnewhall2 2019-12-10 01:01:54 -08:00
parent 1dec643836
commit 65dfedcf27
5 changed files with 7 additions and 6 deletions

View File

@ -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:])

View File

@ -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
}

View File

@ -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{

View File

@ -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{

View File

@ -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},