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