mirror of
				https://github.com/ClusterCockpit/cc-metric-collector.git
				synced 2025-11-04 02:35:07 +01:00 
			
		
		
		
	Set default for topprocs collector to Top2 processes if no config is given
This commit is contained in:
		@@ -12,6 +12,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const MAX_NUM_PROCS = 10
 | 
			
		||||
const DEFAULT_NUM_PROCS = 2
 | 
			
		||||
 | 
			
		||||
type TopProcsCollectorConfig struct {
 | 
			
		||||
	num_procs int `json:"num_procs"`
 | 
			
		||||
@@ -32,6 +33,8 @@ func (m *TopProcsCollector) Init(config []byte) error {
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
	    m.config.num_procs = int(DEFAULT_NUM_PROCS)
 | 
			
		||||
	}
 | 
			
		||||
	if m.config.num_procs <= 0 || m.config.num_procs > MAX_NUM_PROCS {
 | 
			
		||||
		return errors.New(fmt.Sprintf("num_procs option must be set in 'topprocs' config (range: 1-%d)", MAX_NUM_PROCS))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user