mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-26 15:29:04 +01:00
Read config JSON only if there is any
This commit is contained in:
parent
8d643bb5e8
commit
cb8221e73c
@ -13,7 +13,7 @@ import (
|
|||||||
const NETSTATFILE = `/proc/net/dev`
|
const NETSTATFILE = `/proc/net/dev`
|
||||||
|
|
||||||
type NetstatCollectorConfig struct {
|
type NetstatCollectorConfig struct {
|
||||||
ExcludeDevices []string `json:"exclude_devices, omitempty"`
|
ExcludeDevices []string `json:"exclude_devices"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetstatCollector struct {
|
type NetstatCollector struct {
|
||||||
@ -31,11 +31,13 @@ func (m *NetstatCollector) Init(config []byte) error {
|
|||||||
2: "pkts_in",
|
2: "pkts_in",
|
||||||
10: "pkts_out",
|
10: "pkts_out",
|
||||||
}
|
}
|
||||||
|
if len(config) > 0 {
|
||||||
err := json.Unmarshal(config, &m.config)
|
err := json.Unmarshal(config, &m.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err.Error())
|
log.Print(err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_, err = ioutil.ReadFile(string(NETSTATFILE))
|
_, err = ioutil.ReadFile(string(NETSTATFILE))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
m.init = true
|
m.init = true
|
||||||
|
Loading…
Reference in New Issue
Block a user