Switched to cclog.ComponentError() for error reporting in Read()

This commit is contained in:
Holger Obermaier
2022-02-04 14:42:42 +01:00
parent 66b9a25a88
commit 76b69c59b4
5 changed files with 79 additions and 42 deletions

View File

@@ -4,13 +4,13 @@ import (
"bufio"
"encoding/json"
"fmt"
"log"
"os"
"path/filepath"
"strconv"
"strings"
"time"
cclog "github.com/ClusterCockpit/cc-metric-collector/internal/ccLogger"
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
"golang.org/x/sys/unix"
)
@@ -200,12 +200,16 @@ func (m *CPUFreqCollector) Read(interval time.Duration, output chan lp.CCMetric)
// Read current frequency
line, ok := readOneLine(t.scalingCurFreqFile)
if !ok {
log.Printf("CPUFreqCollector.Read(): Failed to read one line from file '%s'", t.scalingCurFreqFile)
cclog.ComponentError(
m.name,
fmt.Sprintf("Read(): Failed to read one line from file '%s'", t.scalingCurFreqFile))
continue
}
cpuFreq, err := strconv.Atoi(line)
if err != nil {
log.Printf("CPUFreqCollector.Read(): Failed to convert CPU frequency '%s': %v", line, err)
cclog.ComponentError(
m.name,
fmt.Sprintf("Read(): Failed to convert CPU frequency '%s': %v", line, err))
continue
}