export buffer, lock cnfg
This commit is contained in:
parent
4a354647aa
commit
ad562e5976
|
|
@ -12,3 +12,7 @@
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "golift.io/unifi"
|
name = "golift.io/unifi"
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "golift.io/cnfg"
|
||||||
|
branch = "master"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// channel buffer, fits at least one batch.
|
// channel buffer, fits at least one batch.
|
||||||
buffer = 50
|
defaultBuffer = 50
|
||||||
defaultHTTPListen = "0.0.0.0:9130"
|
defaultHTTPListen = "0.0.0.0:9130"
|
||||||
// simply fewer letters.
|
// simply fewer letters.
|
||||||
counter = prometheus.CounterValue
|
counter = prometheus.CounterValue
|
||||||
|
|
@ -50,6 +50,9 @@ type Config struct {
|
||||||
// will be collected at all.
|
// will be collected at all.
|
||||||
ReportErrors bool `json:"report_errors" toml:"report_errors" xml:"report_errors" yaml:"report_errors"`
|
ReportErrors bool `json:"report_errors" toml:"report_errors" xml:"report_errors" yaml:"report_errors"`
|
||||||
Disable bool `json:"disable" toml:"disable" xml:"disable" yaml:"disable"`
|
Disable bool `json:"disable" toml:"disable" xml:"disable" yaml:"disable"`
|
||||||
|
// Buffer is a channel buffer.
|
||||||
|
// Default is probably 50. Seems fast there; try 1 to see if CPU usage goes down?
|
||||||
|
Buffer int `json:"buffer" toml:"buffer" xml:"buffer" yaml:"buffer"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type metric struct {
|
type metric struct {
|
||||||
|
|
@ -105,6 +108,10 @@ func (u *promUnifi) Run(c poller.Collect) error {
|
||||||
u.HTTPListen = defaultHTTPListen
|
u.HTTPListen = defaultHTTPListen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if u.Buffer == 0 {
|
||||||
|
u.Buffer = defaultBuffer
|
||||||
|
}
|
||||||
|
|
||||||
// Later can pass this in from poller by adding a method to the interface.
|
// Later can pass this in from poller by adding a method to the interface.
|
||||||
u.Collector = c
|
u.Collector = c
|
||||||
u.Client = descClient(u.Namespace + "_client_")
|
u.Client = descClient(u.Namespace + "_client_")
|
||||||
|
|
@ -200,7 +207,7 @@ func (u *promUnifi) collect(ch chan<- prometheus.Metric, filter *poller.Filter)
|
||||||
|
|
||||||
r := &Report{
|
r := &Report{
|
||||||
Config: u.Config,
|
Config: u.Config,
|
||||||
ch: make(chan []*metric, buffer),
|
ch: make(chan []*metric, u.Config.Buffer),
|
||||||
Start: time.Now()}
|
Start: time.Now()}
|
||||||
defer r.close()
|
defer r.close()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue