got it
This commit is contained in:
		
							parent
							
								
									1dec643836
								
							
						
					
					
						commit
						65dfedcf27
					
				| 
						 | 
					@ -36,6 +36,7 @@ func New() *UnifiPoller {
 | 
				
			||||||
// Parses cli flags, parses config file, parses env vars, sets up logging, then:
 | 
					// Parses cli flags, parses config file, parses env vars, sets up logging, then:
 | 
				
			||||||
// - dumps a json payload OR - executes Run().
 | 
					// - dumps a json payload OR - executes Run().
 | 
				
			||||||
func (u *UnifiPoller) Start() error {
 | 
					func (u *UnifiPoller) Start() error {
 | 
				
			||||||
 | 
						log.SetOutput(os.Stdout)
 | 
				
			||||||
	log.SetFlags(log.LstdFlags)
 | 
						log.SetFlags(log.LstdFlags)
 | 
				
			||||||
	u.Flag.Parse(os.Args[1:])
 | 
						u.Flag.Parse(os.Args[1:])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,6 @@ package promunifi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"log"
 | 
					 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
| 
						 | 
					@ -113,7 +112,6 @@ func (u *promUnifi) Collect(ch chan<- prometheus.Metric) {
 | 
				
			||||||
	defer r.close()
 | 
						defer r.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if r.Metrics, err = r.cf.CollectFn(); err != nil {
 | 
						if r.Metrics, err = r.cf.CollectFn(); err != nil {
 | 
				
			||||||
		log.Println("Error", err)
 | 
					 | 
				
			||||||
		r.error(ch, prometheus.NewInvalidDesc(fmt.Errorf("metric fetch failed")), err)
 | 
							r.error(ch, prometheus.NewInvalidDesc(fmt.Errorf("metric fetch failed")), err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,6 @@
 | 
				
			||||||
package promunifi
 | 
					package promunifi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"log"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus"
 | 
						"github.com/prometheus/client_golang/prometheus"
 | 
				
			||||||
	"golift.io/unifi"
 | 
						"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.
 | 
					// 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) {
 | 
					func (u *promUnifi) exportUAPstats(r report, labels []string, ap *unifi.Ap, bytes ...unifi.FlexInt) {
 | 
				
			||||||
	if ap == nil {
 | 
						if ap == nil {
 | 
				
			||||||
		log.Println("ap was nil?!", labels[2])
 | 
					 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	log.Println("ap not nil")
 | 
					 | 
				
			||||||
	labelU := []string{"user", labels[1], labels[2]}
 | 
						labelU := []string{"user", labels[1], labels[2]}
 | 
				
			||||||
	labelG := []string{"guest", labels[1], labels[2]}
 | 
						labelG := []string{"guest", labels[1], labels[2]}
 | 
				
			||||||
	r.send([]*metric{
 | 
						r.send([]*metric{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -85,6 +85,9 @@ func (u *promUnifi) exportUSG(r report, d *unifi.USG) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Gateway States
 | 
					// Gateway States
 | 
				
			||||||
func (u *promUnifi) exportUSGstats(r report, labels []string, gw *unifi.Gw, st unifi.SpeedtestStatus, ul unifi.Uplink) {
 | 
					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]}
 | 
						labelLan := []string{"lan", labels[1], labels[2]}
 | 
				
			||||||
	labelWan := []string{"all", labels[1], labels[2]}
 | 
						labelWan := []string{"all", labels[1], labels[2]}
 | 
				
			||||||
	r.send([]*metric{
 | 
						r.send([]*metric{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -116,6 +116,9 @@ func (u *promUnifi) exportUSW(r report, d *unifi.USW) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Switch Stats
 | 
					// Switch Stats
 | 
				
			||||||
func (u *promUnifi) exportUSWstats(r report, labels []string, sw *unifi.Sw) {
 | 
					func (u *promUnifi) exportUSWstats(r report, labels []string, sw *unifi.Sw) {
 | 
				
			||||||
 | 
						if sw == nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	labelS := labels[1:]
 | 
						labelS := labels[1:]
 | 
				
			||||||
	r.send([]*metric{
 | 
						r.send([]*metric{
 | 
				
			||||||
		{u.USW.SwRxPackets, counter, sw.RxPackets, labelS},
 | 
							{u.USW.SwRxPackets, counter, sw.RxPackets, labelS},
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue