Merge pull request #4 from unifi-poller/dn2_events
Updates for new poller Interface.
This commit is contained in:
commit
4bee01da7d
|
|
@ -0,0 +1 @@
|
|||
/go.sum
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
language: go
|
||||
go:
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
before_install:
|
||||
# download super-linter: golangci-lint
|
||||
- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest
|
||||
script:
|
||||
- go test ./...
|
||||
- golangci-lint run --enable-all
|
||||
- golangci-lint run --enable-all -D exhaustivestruct,nlreturn
|
||||
|
|
|
|||
|
|
@ -39,8 +39,10 @@ type uclient struct {
|
|||
}
|
||||
|
||||
func descClient(ns string) *uclient {
|
||||
labels := []string{"name", "mac", "site_name", "gw_name", "sw_name", "vlan",
|
||||
"ip", "oui", "network", "sw_port", "ap_name", "source", "wired"}
|
||||
labels := []string{
|
||||
"name", "mac", "site_name", "gw_name", "sw_name", "vlan",
|
||||
"ip", "oui", "network", "sw_port", "ap_name", "source", "wired",
|
||||
}
|
||||
labelW := append([]string{"radio_name", "radio", "radio_proto", "channel", "essid", "bssid", "radio_desc"}, labels...)
|
||||
labelDPI := []string{"name", "mac", "site_name", "source", "category", "application"}
|
||||
|
||||
|
|
@ -72,10 +74,18 @@ func descClient(ns string) *uclient {
|
|||
}
|
||||
}
|
||||
|
||||
func (u *promUnifi) exportClientDPI(r report, s *unifi.DPITable, appTotal, catTotal totalsDPImap) {
|
||||
func (u *promUnifi) exportClientDPI(r report, v interface{}, appTotal, catTotal totalsDPImap) {
|
||||
s, ok := v.(*unifi.DPITable)
|
||||
if !ok {
|
||||
u.LogErrorf("invalid type given to ClientsDPI: %T", v)
|
||||
return
|
||||
}
|
||||
|
||||
for _, dpi := range s.ByApp {
|
||||
labelDPI := []string{s.Name, s.MAC, s.SiteName, s.SourceName,
|
||||
unifi.DPICats.Get(dpi.Cat), unifi.DPIApps.GetApp(dpi.Cat, dpi.App)}
|
||||
labelDPI := []string{
|
||||
s.Name, s.MAC, s.SiteName, s.SourceName,
|
||||
unifi.DPICats.Get(dpi.Cat), unifi.DPIApps.GetApp(dpi.Cat, dpi.App),
|
||||
}
|
||||
|
||||
fillDPIMapTotals(appTotal, labelDPI[5], s.SourceName, s.SiteName, dpi)
|
||||
fillDPIMapTotals(catTotal, labelDPI[4], s.SourceName, s.SiteName, dpi)
|
||||
|
|
@ -90,10 +100,13 @@ func (u *promUnifi) exportClientDPI(r report, s *unifi.DPITable, appTotal, catTo
|
|||
}
|
||||
|
||||
func (u *promUnifi) exportClient(r report, c *unifi.Client) {
|
||||
labels := []string{c.Name, c.Mac, c.SiteName, c.GwName, c.SwName, c.Vlan.Txt,
|
||||
c.IP, c.Oui, c.Network, c.SwPort.Txt, c.ApName, c.SourceName, ""}
|
||||
labelW := append([]string{c.RadioName, c.Radio, c.RadioProto, c.Channel.Txt,
|
||||
c.Essid, c.Bssid, c.RadioDescription}, labels...)
|
||||
labels := []string{
|
||||
c.Name, c.Mac, c.SiteName, c.GwName, c.SwName, c.Vlan.Txt,
|
||||
c.IP, c.Oui, c.Network, c.SwPort.Txt, c.ApName, c.SourceName, "",
|
||||
}
|
||||
labelW := append([]string{
|
||||
c.RadioName, c.Radio, c.RadioProto, c.Channel.Txt, c.Essid, c.Bssid, c.RadioDescription,
|
||||
}, labels...)
|
||||
|
||||
if c.IsWired.Val {
|
||||
labels[len(labels)-1] = "true"
|
||||
|
|
|
|||
|
|
@ -14,8 +14,12 @@ import (
|
|||
"github.com/prometheus/common/version"
|
||||
"github.com/unifi-poller/poller"
|
||||
"github.com/unifi-poller/unifi"
|
||||
"github.com/unifi-poller/webserver"
|
||||
)
|
||||
|
||||
// PluginName is the name of this plugin.
|
||||
const PluginName = "prometheus"
|
||||
|
||||
const (
|
||||
// channel buffer, fits at least one batch.
|
||||
defaultBuffer = 50
|
||||
|
|
@ -25,9 +29,7 @@ const (
|
|||
gauge = prometheus.GaugeValue
|
||||
)
|
||||
|
||||
var (
|
||||
errMetricFetchFailed = fmt.Errorf("metric fetch failed")
|
||||
)
|
||||
var ErrMetricFetchFailed = fmt.Errorf("metric fetch failed")
|
||||
|
||||
type promUnifi struct {
|
||||
*Config `json:"prometheus" toml:"prometheus" xml:"prometheus" yaml:"prometheus"`
|
||||
|
|
@ -48,6 +50,9 @@ type Config struct {
|
|||
// provided string and an underscore ("_").
|
||||
Namespace string `json:"namespace" toml:"namespace" xml:"namespace" yaml:"namespace"`
|
||||
HTTPListen string `json:"http_listen" toml:"http_listen" xml:"http_listen" yaml:"http_listen"`
|
||||
// If these are provided, the app will attempt to listen with an SSL connection.
|
||||
SSLCrtPath string `json:"ssl_cert_path" toml:"ssl_cert_path" xml:"ssl_cert_path" yaml:"ssl_cert_path"`
|
||||
SSLKeyPath string `json:"ssl_key_path" toml:"ssl_key_path" xml:"ssl_key_path" yaml:"ssl_key_path"`
|
||||
// If true, any error encountered during collection is reported as an
|
||||
// invalid metric (see NewInvalidMetric). Otherwise, errors are ignored
|
||||
// and the collected metrics will be incomplete. Possibly, no metrics
|
||||
|
|
@ -72,6 +77,10 @@ type Report struct {
|
|||
Total int // Total count of metrics recorded.
|
||||
Errors int // Total count of errors recording metrics.
|
||||
Zeros int // Total count of metrics equal to zero.
|
||||
USG int // Total count of USG devices.
|
||||
USW int // Total count of USW devices.
|
||||
UAP int // Total count of UAP devices.
|
||||
UDM int // Total count of UDM devices.
|
||||
Metrics *poller.Metrics // Metrics collected and recorded.
|
||||
Elapsed time.Duration // Duration elapsed collecting and exporting.
|
||||
Fetch time.Duration // Duration elapsed making controller requests.
|
||||
|
|
@ -92,7 +101,7 @@ func init() { // nolint: gochecknoinits
|
|||
u := &promUnifi{Config: &Config{}}
|
||||
|
||||
poller.NewOutput(&poller.Output{
|
||||
Name: "prometheus",
|
||||
Name: PluginName,
|
||||
Config: u,
|
||||
Method: u.Run,
|
||||
})
|
||||
|
|
@ -101,14 +110,14 @@ func init() { // nolint: gochecknoinits
|
|||
// Run creates the collectors and starts the web server up.
|
||||
// Should be run in a Go routine. Returns nil if not configured.
|
||||
func (u *promUnifi) Run(c poller.Collect) error {
|
||||
if u.Config == nil || u.Disable {
|
||||
c.Logf("Prometheus config missing (or disabled), Prometheus HTTP listener disabled!")
|
||||
if u.Collector = c; u.Config == nil || u.Disable {
|
||||
u.Logf("Prometheus config missing (or disabled), Prometheus HTTP listener disabled!")
|
||||
return nil
|
||||
}
|
||||
|
||||
u.Namespace = strings.Trim(strings.Replace(u.Namespace, "-", "_", -1), "_")
|
||||
u.Namespace = strings.Trim(strings.ReplaceAll(u.Namespace, "-", "_"), "_")
|
||||
if u.Namespace == "" {
|
||||
u.Namespace = strings.Replace(poller.AppName, "-", "", -1)
|
||||
u.Namespace = strings.ReplaceAll(poller.AppName, "-", "")
|
||||
}
|
||||
|
||||
if u.HTTPListen == "" {
|
||||
|
|
@ -119,8 +128,6 @@ func (u *promUnifi) Run(c poller.Collect) error {
|
|||
u.Buffer = defaultBuffer
|
||||
}
|
||||
|
||||
// Later can pass this in from poller by adding a method to the interface.
|
||||
u.Collector = c
|
||||
u.Client = descClient(u.Namespace + "_client_")
|
||||
u.Device = descDevice(u.Namespace + "_device_") // stats for all device types.
|
||||
u.UAP = descUAP(u.Namespace + "_device_")
|
||||
|
|
@ -129,16 +136,23 @@ func (u *promUnifi) Run(c poller.Collect) error {
|
|||
u.Site = descSite(u.Namespace + "_site_")
|
||||
mux := http.NewServeMux()
|
||||
|
||||
webserver.UpdateOutput(&webserver.Output{Name: PluginName, Config: u.Config})
|
||||
prometheus.MustRegister(version.NewCollector(u.Namespace))
|
||||
prometheus.MustRegister(u)
|
||||
c.Logf("Prometheus exported at https://%s/ - namespace: %s", u.HTTPListen, u.Namespace)
|
||||
mux.Handle("/metrics", promhttp.HandlerFor(prometheus.DefaultGatherer,
|
||||
promhttp.HandlerOpts{ErrorHandling: promhttp.ContinueOnError},
|
||||
))
|
||||
mux.HandleFunc("/scrape", u.ScrapeHandler)
|
||||
mux.HandleFunc("/", u.DefaultHandler)
|
||||
|
||||
return http.ListenAndServe(u.HTTPListen, mux)
|
||||
switch u.SSLKeyPath == "" && u.SSLCrtPath == "" {
|
||||
case true:
|
||||
u.Logf("Prometheus exported at http://%s/ - namespace: %s", u.HTTPListen, u.Namespace)
|
||||
return http.ListenAndServe(u.HTTPListen, mux)
|
||||
default:
|
||||
u.Logf("Prometheus exported at https://%s/ - namespace: %s", u.HTTPListen, u.Namespace)
|
||||
return http.ListenAndServeTLS(u.HTTPListen, u.SSLCrtPath, u.SSLKeyPath, mux)
|
||||
}
|
||||
}
|
||||
|
||||
// ScrapeHandler allows prometheus to scrape a single source, instead of all sources.
|
||||
|
|
@ -153,7 +167,7 @@ func (u *promUnifi) ScrapeHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if pathOld := r.URL.Query().Get("path"); pathOld != "" {
|
||||
u.Collector.LogErrorf("deprecated 'path' parameter used; update your config to use 'target'")
|
||||
u.LogErrorf("deprecated 'path' parameter used; update your config to use 'target'")
|
||||
|
||||
if t.Path == "" {
|
||||
t.Path = pathOld
|
||||
|
|
@ -161,7 +175,7 @@ func (u *promUnifi) ScrapeHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if roleOld := r.URL.Query().Get("role"); roleOld != "" {
|
||||
u.Collector.LogErrorf("deprecated 'role' parameter used; update your config to use 'target'")
|
||||
u.LogErrorf("deprecated 'role' parameter used; update your config to use 'target'")
|
||||
|
||||
if t.Path == "" {
|
||||
t.Path = roleOld
|
||||
|
|
@ -169,7 +183,7 @@ func (u *promUnifi) ScrapeHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if t.Path == "" {
|
||||
u.Collector.LogErrorf("'target' parameter missing on scrape from %v", r.RemoteAddr)
|
||||
u.LogErrorf("'target' parameter missing on scrape from %v", r.RemoteAddr)
|
||||
http.Error(w, "'target' parameter must be specified: configured OR unconfigured url", 400)
|
||||
|
||||
return
|
||||
|
|
@ -227,25 +241,18 @@ func (u *promUnifi) collect(ch chan<- prometheus.Metric, filter *poller.Filter)
|
|||
r := &Report{
|
||||
Config: u.Config,
|
||||
ch: make(chan []*metric, u.Config.Buffer),
|
||||
Start: time.Now()}
|
||||
Start: time.Now(),
|
||||
}
|
||||
defer r.close()
|
||||
|
||||
ok := false
|
||||
|
||||
r.Metrics, ok, err = u.Collector.MetricsFrom(filter)
|
||||
r.Metrics, err = u.Collector.Metrics(filter)
|
||||
r.Fetch = time.Since(r.Start)
|
||||
|
||||
if err != nil {
|
||||
r.error(ch, prometheus.NewInvalidDesc(err), errMetricFetchFailed)
|
||||
u.Collector.LogErrorf("metric fetch failed: %v", err)
|
||||
r.error(ch, prometheus.NewInvalidDesc(err), ErrMetricFetchFailed)
|
||||
u.LogErrorf("metric fetch failed: %v", err)
|
||||
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if r.Metrics.Devices == nil {
|
||||
r.Metrics.Devices = &unifi.Devices{}
|
||||
return
|
||||
}
|
||||
|
||||
// Pass Report interface into our collecting and reporting methods.
|
||||
|
|
@ -258,7 +265,7 @@ func (u *promUnifi) collect(ch chan<- prometheus.Metric, filter *poller.Filter)
|
|||
// This is where our channels connects to the prometheus channel.
|
||||
func (u *promUnifi) exportMetrics(r report, ch chan<- prometheus.Metric, ourChan chan []*metric) {
|
||||
descs := make(map[*prometheus.Desc]bool) // used as a counter
|
||||
defer r.report(u.Collector, descs)
|
||||
defer r.report(u, descs)
|
||||
|
||||
for newMetrics := range ourChan {
|
||||
for _, m := range newMetrics {
|
||||
|
|
@ -286,7 +293,7 @@ func (u *promUnifi) loopExports(r report) {
|
|||
m := r.metrics()
|
||||
|
||||
for _, s := range m.Sites {
|
||||
u.exportSite(r, s)
|
||||
u.switchExport(r, s)
|
||||
}
|
||||
|
||||
for _, s := range m.SitesDPI {
|
||||
|
|
@ -294,7 +301,11 @@ func (u *promUnifi) loopExports(r report) {
|
|||
}
|
||||
|
||||
for _, c := range m.Clients {
|
||||
u.exportClient(r, c)
|
||||
u.switchExport(r, c)
|
||||
}
|
||||
|
||||
for _, d := range m.Devices {
|
||||
u.switchExport(r, d)
|
||||
}
|
||||
|
||||
appTotal := make(totalsDPImap)
|
||||
|
|
@ -305,20 +316,27 @@ func (u *promUnifi) loopExports(r report) {
|
|||
}
|
||||
|
||||
u.exportClientDPItotals(r, appTotal, catTotal)
|
||||
}
|
||||
|
||||
for _, d := range m.UAPs {
|
||||
u.exportUAP(r, d)
|
||||
}
|
||||
|
||||
for _, d := range m.UDMs {
|
||||
u.exportUDM(r, d)
|
||||
}
|
||||
|
||||
for _, d := range m.USGs {
|
||||
u.exportUSG(r, d)
|
||||
}
|
||||
|
||||
for _, d := range m.USWs {
|
||||
u.exportUSW(r, d)
|
||||
func (u *promUnifi) switchExport(r report, v interface{}) {
|
||||
switch v := v.(type) {
|
||||
case *unifi.UAP:
|
||||
r.addUAP()
|
||||
u.exportUAP(r, v)
|
||||
case *unifi.USW:
|
||||
r.addUSW()
|
||||
u.exportUSW(r, v)
|
||||
case *unifi.USG:
|
||||
r.addUSG()
|
||||
u.exportUSG(r, v)
|
||||
case *unifi.UDM:
|
||||
r.addUDM()
|
||||
u.exportUDM(r, v)
|
||||
case *unifi.Site:
|
||||
u.exportSite(r, v)
|
||||
case *unifi.Client:
|
||||
u.exportClient(r, v)
|
||||
default:
|
||||
u.LogErrorf("invalid type: %T", v)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
module github.com/unifi-poller/promunifi
|
||||
|
||||
go 1.14
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/prometheus/client_golang v1.6.0
|
||||
github.com/prometheus/common v0.10.0
|
||||
github.com/prometheus/procfs v0.1.2 // indirect
|
||||
github.com/unifi-poller/poller v0.0.6
|
||||
github.com/unifi-poller/unifi v0.0.5
|
||||
github.com/prometheus/client_golang v1.9.0
|
||||
github.com/prometheus/common v0.18.0
|
||||
github.com/unifi-poller/poller v0.0.8-0.20200630113056-ab41c7f9c2d5
|
||||
github.com/unifi-poller/unifi v0.0.5-0.20200620103801-b927287ea1cd
|
||||
github.com/unifi-poller/webserver v0.0.0-20200628212441-340749c94743
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,164 +0,0 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.6.0 h1:YVPodQOcK15POxhgARIvnDRVpLcuK8mglnMrWfyrw6A=
|
||||
github.com/prometheus/client_golang v1.6.0/go.mod h1:ZLOG9ck3JLRdB5MgO8f+lLTe83AXG6ro35rLTxvnIl4=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/prometheus/procfs v0.1.1/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/prometheus/procfs v0.1.2 h1:DS2izEFqEVp1gPg5yvEF/YzS6Ajo8YdKRJjQKiQm59A=
|
||||
github.com/prometheus/procfs v0.1.2/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/unifi-poller/poller v0.0.6 h1:KhOWUeYI029Nn/4NOIk/yblQ3tEd9QhS+u/8/S9ZoDs=
|
||||
github.com/unifi-poller/poller v0.0.6/go.mod h1:RkRJ4pAc2dAN8Xu9+VOumeE3BdN5QDQ3PC+jBx8hWW0=
|
||||
github.com/unifi-poller/unifi v0.0.4/go.mod h1:bTUtctrf56aapjKH+L+98eThBaVFbQXw5iNGZI0g/+E=
|
||||
github.com/unifi-poller/unifi v0.0.5 h1:Izeun32YxcQOeKZUXY0Sy4ltKYFuYxWGcN9JS6xkIJU=
|
||||
github.com/unifi-poller/unifi v0.0.5/go.mod h1:L1kMRH2buZhB31vZnRC1im7Tk/4uD3ET4biwl2faYy8=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200610111108-226ff32320da h1:bGb80FudwxpeucJUjPYJXuJ8Hk91vNtfvrymzwiei38=
|
||||
golang.org/x/sys v0.0.0-20200610111108-226ff32320da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golift.io/cnfg v0.0.5 h1:HnMU8Z9C/igKvir1dqaHx5BPuNGZrp99FCtdJyP2Z4I=
|
||||
golift.io/cnfg v0.0.5/go.mod h1:ScFDIJg/rJGHbRaed/i7g1lBhywEjB0JiP2uZr3xC3A=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA=
|
||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package promunifi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/unifi-poller/webserver"
|
||||
)
|
||||
|
||||
// Logf logs a message.
|
||||
func (u *promUnifi) Logf(msg string, v ...interface{}) {
|
||||
webserver.NewOutputEvent(PluginName, PluginName, &webserver.Event{
|
||||
Ts: time.Now(),
|
||||
Msg: fmt.Sprintf(msg, v...),
|
||||
Tags: map[string]string{"type": "info"},
|
||||
})
|
||||
u.Collector.Logf(msg, v...)
|
||||
}
|
||||
|
||||
// LogErrorf logs an error message.
|
||||
func (u *promUnifi) LogErrorf(msg string, v ...interface{}) {
|
||||
webserver.NewOutputEvent(PluginName, PluginName, &webserver.Event{
|
||||
Ts: time.Now(),
|
||||
Msg: fmt.Sprintf(msg, v...),
|
||||
Tags: map[string]string{"type": "error"},
|
||||
})
|
||||
u.Collector.LogErrorf(msg, v...)
|
||||
}
|
||||
|
||||
// LogDebugf logs a debug message.
|
||||
func (u *promUnifi) LogDebugf(msg string, v ...interface{}) {
|
||||
webserver.NewOutputEvent(PluginName, PluginName, &webserver.Event{
|
||||
Ts: time.Now(),
|
||||
Msg: fmt.Sprintf(msg, v...),
|
||||
Tags: map[string]string{"type": "debug"},
|
||||
})
|
||||
u.Collector.LogDebugf(msg, v...)
|
||||
}
|
||||
|
|
@ -16,9 +16,13 @@ type report interface {
|
|||
done()
|
||||
send([]*metric)
|
||||
metrics() *poller.Metrics
|
||||
report(c poller.Collect, descs map[*prometheus.Desc]bool)
|
||||
report(c poller.Logger, descs map[*prometheus.Desc]bool)
|
||||
export(m *metric, v float64) prometheus.Metric
|
||||
error(ch chan<- prometheus.Metric, d *prometheus.Desc, v interface{})
|
||||
addUDM()
|
||||
addUSG()
|
||||
addUAP()
|
||||
addUSW()
|
||||
}
|
||||
|
||||
// Satisfy gomnd.
|
||||
|
|
@ -37,14 +41,14 @@ func (r *Report) metrics() *poller.Metrics {
|
|||
return r.Metrics
|
||||
}
|
||||
|
||||
func (r *Report) report(c poller.Collect, descs map[*prometheus.Desc]bool) {
|
||||
func (r *Report) report(c poller.Logger, descs map[*prometheus.Desc]bool) {
|
||||
m := r.Metrics
|
||||
|
||||
c.Logf("UniFi Measurements Exported. Site: %d, Client: %d, "+
|
||||
"UAP: %d, USG/UDM: %d, USW: %d, Descs: %d, "+
|
||||
"Metrics: %d, Errs: %d, 0s: %d, Reqs/Total: %v / %v",
|
||||
len(m.Sites), len(m.Clients), len(m.UAPs), len(m.UDMs)+len(m.USGs), len(m.USWs),
|
||||
len(descs), r.Total, r.Errors, r.Zeros,
|
||||
"UAP: %d, USG/UDM: %d, USW: %d, DPI Site/Client: %d/%d, Desc: %d, "+
|
||||
"Metric: %d, Err: %d, 0s: %d, Req/Total: %v / %v",
|
||||
len(m.Sites), len(m.Clients), r.UAP, r.UDM+r.USG, r.USW, len(m.SitesDPI),
|
||||
len(m.ClientsDPI), len(descs), r.Total, r.Errors, r.Zeros,
|
||||
r.Fetch.Round(time.Millisecond/oneDecimalPoint),
|
||||
r.Elapsed.Round(time.Millisecond/oneDecimalPoint))
|
||||
}
|
||||
|
|
@ -67,6 +71,22 @@ func (r *Report) error(ch chan<- prometheus.Metric, d *prometheus.Desc, v interf
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Report) addUSW() {
|
||||
r.USW++
|
||||
}
|
||||
|
||||
func (r *Report) addUAP() {
|
||||
r.UAP++
|
||||
}
|
||||
|
||||
func (r *Report) addUSG() {
|
||||
r.USG++
|
||||
}
|
||||
|
||||
func (r *Report) addUDM() {
|
||||
r.UDM++
|
||||
}
|
||||
|
||||
// close is not part of the interface.
|
||||
func (r *Report) close() {
|
||||
r.wg.Wait()
|
||||
|
|
|
|||
|
|
@ -75,7 +75,13 @@ func descSite(ns string) *site {
|
|||
}
|
||||
}
|
||||
|
||||
func (u *promUnifi) exportSiteDPI(r report, s *unifi.DPITable) {
|
||||
func (u *promUnifi) exportSiteDPI(r report, v interface{}) {
|
||||
s, ok := v.(*unifi.DPITable)
|
||||
if !ok {
|
||||
u.LogErrorf("invalid type given to SiteDPI: %T", v)
|
||||
return
|
||||
}
|
||||
|
||||
for _, dpi := range s.ByApp {
|
||||
labelDPI := []string{unifi.DPICats.Get(dpi.Cat), unifi.DPIApps.GetApp(dpi.Cat, dpi.App), s.SiteName, s.SourceName}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,8 +161,10 @@ func (u *promUnifi) exportPRTtable(r report, labels []string, pt []unifi.Port) {
|
|||
}
|
||||
|
||||
// Copy labels, and add four new ones.
|
||||
labelP := []string{labels[2] + " Port " + p.PortIdx.Txt, p.PortIdx.Txt,
|
||||
p.Name, p.Mac, p.IP, labels[1], labels[2], labels[3]}
|
||||
labelP := []string{
|
||||
labels[2] + " Port " + p.PortIdx.Txt, p.PortIdx.Txt,
|
||||
p.Name, p.Mac, p.IP, labels[1], labels[2], labels[3],
|
||||
}
|
||||
|
||||
if p.PoeEnable.Val && p.PortPoe.Val {
|
||||
r.send([]*metric{
|
||||
|
|
|
|||
Loading…
Reference in New Issue