mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 04:27:25 +01:00
Fix http server addr format
This commit is contained in:
parent
aac475fc98
commit
baa45b833b
@ -54,15 +54,22 @@ func (r *HttpReceiver) Init(name string, config json.RawMessage) error {
|
|||||||
if !strings.HasPrefix(p, "/") {
|
if !strings.HasPrefix(p, "/") {
|
||||||
p = "/" + p
|
p = "/" + p
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s:%s%s", r.config.Addr, r.config.Port, p)
|
addr := fmt.Sprintf("%s:%s", r.config.Addr, r.config.Port)
|
||||||
cclog.ComponentDebug(r.name, "INIT", uri)
|
uri := addr + p
|
||||||
|
cclog.ComponentDebug(r.name, "INIT", "listen on:", uri)
|
||||||
r.handler = influx.NewMetricHandler()
|
r.handler = influx.NewMetricHandler()
|
||||||
r.parser = influx.NewParser(r.handler)
|
r.parser = influx.NewParser(r.handler)
|
||||||
r.parser.SetTimeFunc(DefaultTime)
|
r.parser.SetTimeFunc(DefaultTime)
|
||||||
|
|
||||||
|
// Create new router and register p as path
|
||||||
r.router = mux.NewRouter()
|
r.router = mux.NewRouter()
|
||||||
r.router.Path(p).HandlerFunc(r.ServerHttp)
|
r.router.Path(p).HandlerFunc(r.ServerHttp)
|
||||||
r.server = &http.Server{Addr: uri, Handler: r.router}
|
|
||||||
|
// Create http server, with router as handler
|
||||||
|
r.server = &http.Server{
|
||||||
|
Addr: addr,
|
||||||
|
Handler: r.router,
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var AvailableReceivers = map[string]func(name string, config json.RawMessage) (Receiver, error){
|
var AvailableReceivers = map[string]func(name string, config json.RawMessage) (Receiver, error){
|
||||||
|
"http": NewHttpReceiver,
|
||||||
"ipmi": NewIPMIReceiver,
|
"ipmi": NewIPMIReceiver,
|
||||||
"nats": NewNatsReceiver,
|
"nats": NewNatsReceiver,
|
||||||
"redfish": NewRedfishReceiver,
|
"redfish": NewRedfishReceiver,
|
||||||
|
Loading…
Reference in New Issue
Block a user