mirror of
				https://github.com/ClusterCockpit/cc-metric-collector.git
				synced 2025-11-04 02:35:07 +01:00 
			
		
		
		
	Merge latest commits from develop to main branch (#114)
				
					
				
			* Add cpu_used (all-cpu_idle) to CpustatCollector * Update cc-metric-collector.init * Allow selection of timestamp precision in HttpSink * Add comment about precision requirement for cc-metric-store * Fix for API changes in gofish@v0.15.0 * Update requirements to latest version * Read sensors through redfish * Update golang toolchain to 1.21 * Remove stray error check * Update main config in configuration.md * Update Release action to use golang 1.22 stable release, no golang RPMs anymore * Update runonce action to use golang 1.22 stable release, no golang RPMs anymore * Update README.md Use right JSON type in configuration * Update sink's README * Test whether ipmitool or ipmi-sensors can be executed without errors --------- Co-authored-by: Holger Obermaier <Holger.Obermaier@kit.edu> Co-authored-by: Holger Obermaier <40787752+ho-ob@users.noreply.github.com>
This commit is contained in:
		@@ -12,6 +12,7 @@ import (
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger"
 | 
			
		||||
	lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric"
 | 
			
		||||
)
 | 
			
		||||
@@ -54,15 +55,30 @@ func (m *IpmiCollector) Init(config json.RawMessage) error {
 | 
			
		||||
	// Check if executables ipmitool or ipmisensors are found
 | 
			
		||||
	p, err := exec.LookPath(m.config.IpmitoolPath)
 | 
			
		||||
	if err == nil {
 | 
			
		||||
		m.ipmitool = p
 | 
			
		||||
		command := exec.Command(p)
 | 
			
		||||
		err := command.Run()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			cclog.ComponentError(m.name, fmt.Sprintf("Failed to execute %s: %v", p, err.Error()))
 | 
			
		||||
			m.ipmitool = ""
 | 
			
		||||
		} else {
 | 
			
		||||
			m.ipmitool = p
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	p, err = exec.LookPath(m.config.IpmisensorsPath)
 | 
			
		||||
	if err == nil {
 | 
			
		||||
		m.ipmisensors = p
 | 
			
		||||
		command := exec.Command(p)
 | 
			
		||||
		err := command.Run()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			cclog.ComponentError(m.name, fmt.Sprintf("Failed to execute %s: %v", p, err.Error()))
 | 
			
		||||
			m.ipmisensors = ""
 | 
			
		||||
		} else {
 | 
			
		||||
			m.ipmisensors = p
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(m.ipmitool) == 0 && len(m.ipmisensors) == 0 {
 | 
			
		||||
		return errors.New("no IPMI reader found")
 | 
			
		||||
		return errors.New("no usable IPMI reader found")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	m.init = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@@ -119,8 +135,8 @@ func (m *IpmiCollector) readIpmiTool(cmd string, output chan lp.CCMetric) {
 | 
			
		||||
		cclog.ComponentError(
 | 
			
		||||
			m.name,
 | 
			
		||||
			fmt.Sprintf("readIpmiTool(): Failed to wait for the end of command \"%s\": %v\n", command.String(), err),
 | 
			
		||||
			fmt.Sprintf("readIpmiTool(): command stderr: \"%s\"\n", string(errMsg)),
 | 
			
		||||
		)
 | 
			
		||||
		cclog.ComponentError(m.name, fmt.Sprintf("readIpmiTool(): command stderr: \"%s\"\n", strings.TrimSpace(string(errMsg))))
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user