Merge pull request #3 from unifi-poller/dn2_no_role
Deprecate role param.
This commit is contained in:
commit
e6d4f6a589
|
|
@ -145,20 +145,32 @@ func (u *promUnifi) Run(c poller.Collect) error {
|
|||
func (u *promUnifi) ScrapeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
t := &target{u: u, Filter: &poller.Filter{
|
||||
Name: r.URL.Query().Get("input"), // "unifi"
|
||||
Path: r.URL.Query().Get("path"), // url: "https://127.0.0.1:8443"
|
||||
Role: r.URL.Query().Get("role"), // configured role in up.conf.
|
||||
Path: r.URL.Query().Get("target"), // url: "https://127.0.0.1:8443"
|
||||
}}
|
||||
|
||||
if t.Name == "" {
|
||||
u.Collector.LogErrorf("input parameter missing on scrape from %v", r.RemoteAddr)
|
||||
http.Error(w, `'input' parameter must be specified (try "unifi")`, 400)
|
||||
|
||||
return
|
||||
t.Name = "unifi" // the default
|
||||
}
|
||||
|
||||
if t.Role == "" && t.Path == "" {
|
||||
u.Collector.LogErrorf("role and path parameters missing on scrape from %v", r.RemoteAddr)
|
||||
http.Error(w, "'role' OR 'path' parameter must be specified: configured role OR unconfigured url", 400)
|
||||
if pathOld := r.URL.Query().Get("path"); pathOld != "" {
|
||||
u.Collector.LogErrorf("deprecated 'path' parameter used; update your config to use 'target'")
|
||||
|
||||
if t.Path == "" {
|
||||
t.Path = pathOld
|
||||
}
|
||||
}
|
||||
|
||||
if roleOld := r.URL.Query().Get("role"); roleOld != "" {
|
||||
u.Collector.LogErrorf("deprecated 'role' parameter used; update your config to use 'target'")
|
||||
|
||||
if t.Path == "" {
|
||||
t.Path = roleOld
|
||||
}
|
||||
}
|
||||
|
||||
if t.Path == "" {
|
||||
u.Collector.LogErrorf("'target' parameter missing on scrape from %v", r.RemoteAddr)
|
||||
http.Error(w, "'target' parameter must be specified: configured OR unconfigured url", 400)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
@ -220,12 +232,7 @@ func (u *promUnifi) collect(ch chan<- prometheus.Metric, filter *poller.Filter)
|
|||
|
||||
ok := false
|
||||
|
||||
if filter == nil {
|
||||
r.Metrics, ok, err = u.Collector.Metrics()
|
||||
} else {
|
||||
r.Metrics, ok, err = u.Collector.MetricsFrom(filter)
|
||||
}
|
||||
|
||||
r.Fetch = time.Since(r.Start)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue