mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2026-06-10 05:47:30 +02:00
Update cclog calls
This commit is contained in:
@@ -132,11 +132,11 @@ func mainFunc() int {
|
|||||||
if len(rcfg.ConfigFile.Interval) > 0 {
|
if len(rcfg.ConfigFile.Interval) > 0 {
|
||||||
t, err := time.ParseDuration(rcfg.ConfigFile.Interval)
|
t, err := time.ParseDuration(rcfg.ConfigFile.Interval)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.Error("Configuration value 'interval' no valid duration")
|
cclog.Errorf("Configuration value interval=%s no valid duration", rcfg.ConfigFile.Interval)
|
||||||
}
|
}
|
||||||
rcfg.Interval = t
|
rcfg.Interval = t
|
||||||
if rcfg.Interval == 0 {
|
if rcfg.Interval == 0 {
|
||||||
cclog.Error("Configuration value 'interval' must be greater than zero")
|
cclog.Errorf("Configuration value interval=%s must be greater than zero", rcfg.ConfigFile.Interval)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,11 +145,11 @@ func mainFunc() int {
|
|||||||
if len(rcfg.ConfigFile.Duration) > 0 {
|
if len(rcfg.ConfigFile.Duration) > 0 {
|
||||||
t, err := time.ParseDuration(rcfg.ConfigFile.Duration)
|
t, err := time.ParseDuration(rcfg.ConfigFile.Duration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.Error("Configuration value 'duration' no valid duration")
|
cclog.Error("Configuration value duration=%s no valid duration", rcfg.ConfigFile.Duration)
|
||||||
}
|
}
|
||||||
rcfg.Duration = t
|
rcfg.Duration = t
|
||||||
if rcfg.Duration == 0 {
|
if rcfg.Duration == 0 {
|
||||||
cclog.Error("Configuration value 'duration' must be greater than zero")
|
cclog.Error("Configuration value duration=%s must be greater than zero", rcfg.ConfigFile.Duration)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,16 +209,16 @@ func (m *BeegfsMetaCollector) Read(interval time.Duration, output chan lp.CCMess
|
|||||||
} else {
|
} else {
|
||||||
f1, err := strconv.ParseFloat(m.matches["other"], 32)
|
f1, err := strconv.ParseFloat(m.matches["other"], 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err))
|
"Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
f2, err := strconv.ParseFloat(split[i], 32)
|
f2, err := strconv.ParseFloat(split[i], 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err))
|
"Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m.matches["beegfs_cstorage_other"] = fmt.Sprintf("%f", f1+f2)
|
m.matches["beegfs_cstorage_other"] = fmt.Sprintf("%f", f1+f2)
|
||||||
|
|||||||
@@ -200,16 +200,16 @@ func (m *BeegfsStorageCollector) Read(interval time.Duration, output chan lp.CCM
|
|||||||
} else {
|
} else {
|
||||||
f1, err := strconv.ParseFloat(m.matches["other"], 32)
|
f1, err := strconv.ParseFloat(m.matches["other"], 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err))
|
"Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
f2, err := strconv.ParseFloat(split[i], 32)
|
f2, err := strconv.ParseFloat(split[i], 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err))
|
"Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m.matches["beegfs_cstorage_other"] = fmt.Sprintf("%f", f1+f2)
|
m.matches["beegfs_cstorage_other"] = fmt.Sprintf("%f", f1+f2)
|
||||||
|
|||||||
@@ -139,16 +139,16 @@ func (m *CPUFreqCpuInfoCollector) Read(interval time.Duration, output chan lp.CC
|
|||||||
const cpuInfoFile = "/proc/cpuinfo"
|
const cpuInfoFile = "/proc/cpuinfo"
|
||||||
file, err := os.Open(cpuInfoFile)
|
file, err := os.Open(cpuInfoFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to open file '%s': %v", cpuInfoFile, err))
|
"Read(): Failed to open file '%s': %v", cpuInfoFile, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := file.Close(); err != nil {
|
if err := file.Close(); err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to close file '%s': %v", cpuInfoFile, err))
|
"Read(): Failed to close file '%s': %v", cpuInfoFile, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -166,9 +166,9 @@ func (m *CPUFreqCpuInfoCollector) Read(interval time.Duration, output chan lp.CC
|
|||||||
if !t.isHT {
|
if !t.isHT {
|
||||||
value, err := strconv.ParseFloat(strings.TrimSpace(lineSplit[1]), 64)
|
value, err := strconv.ParseFloat(strings.TrimSpace(lineSplit[1]), 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to convert cpu MHz '%s' to float64: %v", lineSplit[1], err))
|
"Read(): Failed to convert cpu MHz '%s' to float64: %v", lineSplit[1], err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if y, err := lp.NewMetric("cpufreq", t.tagSet, m.meta, value, now); err == nil {
|
if y, err := lp.NewMetric("cpufreq", t.tagSet, m.meta, value, now); err == nil {
|
||||||
|
|||||||
@@ -95,10 +95,7 @@ func (m *CPUFreqCollector) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialized
|
// Initialized
|
||||||
cclog.ComponentDebug(
|
cclog.ComponentDebugf(m.name, "initialized %d non-hyper-threading CPUs")
|
||||||
m.name,
|
|
||||||
"initialized",
|
|
||||||
len(m.topology), "non-hyper-threading CPUs")
|
|
||||||
m.init = true
|
m.init = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -116,16 +113,14 @@ func (m *CPUFreqCollector) Read(interval time.Duration, output chan lp.CCMessage
|
|||||||
// Read current frequency
|
// Read current frequency
|
||||||
line, err := os.ReadFile(t.scalingCurFreqFile)
|
line, err := os.ReadFile(t.scalingCurFreqFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name, "Read(): Failed to read file '%s': %v", t.scalingCurFreqFile, err)
|
||||||
fmt.Sprintf("Read(): Failed to read file '%s': %v", t.scalingCurFreqFile, err))
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cpuFreq, err := strconv.ParseInt(strings.TrimSpace(string(line)), 10, 64)
|
cpuFreq, err := strconv.ParseInt(strings.TrimSpace(string(line)), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentError(
|
||||||
m.name,
|
m.name, "Read(): Failed to convert CPU frequency '%s' to int64: %v", line, err)
|
||||||
fmt.Sprintf("Read(): Failed to convert CPU frequency '%s' to int64: %v", line, err))
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -171,15 +171,15 @@ func (m *CpustatCollector) Read(interval time.Duration, output chan lp.CCMessage
|
|||||||
|
|
||||||
file, err := os.Open(CPUSTATFILE)
|
file, err := os.Open(CPUSTATFILE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to open file '%s': %v", CPUSTATFILE, err))
|
"Read(): Failed to open file '%s': %v", CPUSTATFILE, err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := file.Close(); err != nil {
|
if err := file.Close(); err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to close file '%s': %v", string(CPUSTATFILE), err))
|
"Read(): Failed to close file '%s': %v", string(CPUSTATFILE), err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ func (m *CustomCmdCollector) Init(config json.RawMessage) error {
|
|||||||
cmdFields := strings.Fields(c)
|
cmdFields := strings.Fields(c)
|
||||||
command := exec.Command(cmdFields[0], cmdFields[1:]...)
|
command := exec.Command(cmdFields[0], cmdFields[1:]...)
|
||||||
if _, err := command.Output(); err != nil {
|
if _, err := command.Output(); err != nil {
|
||||||
cclog.ComponentWarn(
|
cclog.ComponentWarnf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("%s Init(): Execution of command \"%s\" failed: %v", m.name, command.String(), err))
|
"%s Init(): Execution of command \"%s\" failed: %v", m.name, command.String(), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m.cmdFieldsSlice = append(m.cmdFieldsSlice, cmdFields)
|
m.cmdFieldsSlice = append(m.cmdFieldsSlice, cmdFields)
|
||||||
@@ -77,7 +77,7 @@ func (m *CustomCmdCollector) Init(config json.RawMessage) error {
|
|||||||
if _, err := os.ReadFile(fileName); err != nil {
|
if _, err := os.ReadFile(fileName); err != nil {
|
||||||
cclog.ComponentWarn(
|
cclog.ComponentWarn(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("%s Init(): Reading of file \"%s\" failed: %v", m.name, fileName, err))
|
"%s Init(): Reading of file \"%s\" failed: %v", m.name, fileName, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m.files = append(m.files, fileName)
|
m.files = append(m.files, fileName)
|
||||||
@@ -100,20 +100,18 @@ func (m *CustomCmdCollector) Read(interval time.Duration, output chan lp.CCMessa
|
|||||||
command := exec.Command(cmdFields[0], cmdFields[1:]...)
|
command := exec.Command(cmdFields[0], cmdFields[1:]...)
|
||||||
stdout, err := command.Output()
|
stdout, err := command.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to read command output for command \"%s\": %v", command.String(), err),
|
"Read(): Failed to read command output for command \"%s\": %v", command.String(), err)
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read and decode influxDB line-protocol from command output
|
// Read and decode influxDB line-protocol from command output
|
||||||
metrics, err := lp.FromBytes(stdout)
|
metrics, err := lp.FromBytes(stdout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to decode influx Message: %v", err),
|
"Read(): Failed to decode influx Message: %v", err)
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, metric := range metrics {
|
for _, metric := range metrics {
|
||||||
@@ -128,20 +126,18 @@ func (m *CustomCmdCollector) Read(interval time.Duration, output chan lp.CCMessa
|
|||||||
for _, filename := range m.files {
|
for _, filename := range m.files {
|
||||||
input, err := os.ReadFile(filename)
|
input, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to read file \"%s\": %v\n", filename, err),
|
"Read(): Failed to read file \"%s\": %v\n", filename, err)
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read and decode influxDB line-protocol from file
|
// Read and decode influxDB line-protocol from file
|
||||||
metrics, err := lp.FromBytes(input)
|
metrics, err := lp.FromBytes(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to decode influx Message: %v", err),
|
"Read(): Failed to decode influx Message: %v", err)
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, metric := range metrics {
|
for _, metric := range metrics {
|
||||||
|
|||||||
@@ -77,16 +77,16 @@ func (m *DiskstatCollector) Read(interval time.Duration, output chan lp.CCMessag
|
|||||||
|
|
||||||
file, err := os.Open(MOUNTFILE)
|
file, err := os.Open(MOUNTFILE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to open file '%s': %v", MOUNTFILE, err))
|
"Read(): Failed to open file '%s': %v", MOUNTFILE, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := file.Close(); err != nil {
|
if err := file.Close(); err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentError(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to close file '%s': %v", MOUNTFILE, err))
|
"Read(): Failed to close file '%s': %v", MOUNTFILE, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ func (m *GpfsCollector) Init(config json.RawMessage) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// if using sudo, exec.lookPath will return EACCES (file mode r-x------), this can be ignored
|
// if using sudo, exec.lookPath will return EACCES (file mode r-x------), this can be ignored
|
||||||
if m.config.Sudo && errors.Is(err, syscall.EACCES) {
|
if m.config.Sudo && errors.Is(err, syscall.EACCES) {
|
||||||
cclog.ComponentWarn(m.name, fmt.Sprintf("got error looking for mmpmon binary '%s': %v . This is expected when using sudo, continuing.", m.config.Mmpmon, err))
|
cclog.ComponentWarnf(m.name, "got error looking for mmpmon binary '%s': %v . This is expected when using sudo, continuing.", m.config.Mmpmon, err)
|
||||||
// the file was given in the config, use it
|
// the file was given in the config, use it
|
||||||
p = m.config.Mmpmon
|
p = m.config.Mmpmon
|
||||||
} else {
|
} else {
|
||||||
@@ -517,23 +517,23 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMessage) {
|
|||||||
// return code
|
// return code
|
||||||
rc, err := strconv.Atoi(key_value["_rc_"])
|
rc, err := strconv.Atoi(key_value["_rc_"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, fmt.Sprintf("Read(): Failed to convert return code '%s' to int: %v", key_value["_rc_"], err))
|
cclog.ComponentErrorf(m.name, "Read(): Failed to convert return code '%s' to int: %v", key_value["_rc_"], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if rc != 0 {
|
if rc != 0 {
|
||||||
cclog.ComponentError(m.name, fmt.Sprintf("Read(): Filesystem '%s' is not ok.", filesystem))
|
cclog.ComponentErrorf(m.name, "Read(): Filesystem '%s' is not ok.", filesystem)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// timestamp
|
// timestamp
|
||||||
sec, err := strconv.ParseInt(key_value["_t_"], 10, 64)
|
sec, err := strconv.ParseInt(key_value["_t_"], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, fmt.Sprintf("Read(): Failed to convert seconds '%s' to int64: %v", key_value["_t_"], err))
|
cclog.ComponentErrorf(m.name, "Read(): Failed to convert seconds '%s' to int64: %v", key_value["_t_"], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
msec, err := strconv.ParseInt(key_value["_tu_"], 10, 64)
|
msec, err := strconv.ParseInt(key_value["_tu_"], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, fmt.Sprintf("Read(): Failed to convert micro seconds '%s' to int64: %v", key_value["_tu_"], err))
|
cclog.ComponentErrorf(m.name, "Read(): Failed to convert micro seconds '%s' to int64: %v", key_value["_tu_"], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
timestamp := time.Unix(sec, msec*1000)
|
timestamp := time.Unix(sec, msec*1000)
|
||||||
@@ -551,7 +551,7 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMessage) {
|
|||||||
for _, metric := range GpfsAbsMetrics {
|
for _, metric := range GpfsAbsMetrics {
|
||||||
value, err := strconv.ParseInt(key_value[metric.prefix], 10, 64)
|
value, err := strconv.ParseInt(key_value[metric.prefix], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, fmt.Sprintf("Read(): Failed to convert %s '%s' to int64: %v", metric.desc, key_value[metric.prefix], err))
|
cclog.ComponentErrorf(m.name, "Read(): Failed to convert %s '%s' to int64: %v", metric.desc, key_value[metric.prefix], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newstate[metric.prefix] = value
|
newstate[metric.prefix] = value
|
||||||
@@ -636,7 +636,7 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMessage) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// the value could not be computed correctly
|
// the value could not be computed correctly
|
||||||
cclog.ComponentWarn(m.name, fmt.Sprintf("Read(): Could not compute value for filesystem %s of metric %s: vold_ok = %t, vnew_ok = %t", filesystem, metric.name, vold_ok, vnew_ok))
|
cclog.ComponentWarnf(m.name, "Read(): Could not compute value for filesystem %s of metric %s: vold_ok = %t, vnew_ok = %t", filesystem, metric.name, vold_ok, vnew_ok)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,16 +145,16 @@ func (m *IOstatCollector) Read(interval time.Duration, output chan lp.CCMessage)
|
|||||||
|
|
||||||
file, err := os.Open(IOSTATFILE)
|
file, err := os.Open(IOSTATFILE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to open file '%s': %v", IOSTATFILE, err))
|
"Read(): Failed to open file '%s': %v", IOSTATFILE, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := file.Close(); err != nil {
|
if err := file.Close(); err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to close file '%s': %v", IOSTATFILE, err))
|
"Read(): Failed to close file '%s': %v", IOSTATFILE, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ package collectors
|
|||||||
#cgo LDFLAGS: -Wl,--unresolved-symbols=ignore-in-object-files
|
#cgo LDFLAGS: -Wl,--unresolved-symbols=ignore-in-object-files
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <likwid.h>
|
#include <likwid.h>
|
||||||
|
|
||||||
|
|
||||||
|
int cc_add_hwthread(int cpu_id) {
|
||||||
|
return HPMaddThread(cpu_id);
|
||||||
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
@@ -261,12 +267,12 @@ func (m *LikwidCollector) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
for _, metric := range evset.Metrics {
|
for _, metric := range evset.Metrics {
|
||||||
// Try to evaluate the metric
|
// Try to evaluate the metric
|
||||||
cclog.ComponentDebug(m.name, "Checking", metric.Name)
|
cclog.ComponentDebugf(m.name, "Checking %s", metric.Name)
|
||||||
if !checkMetricType(metric.Type) {
|
if !checkMetricType(metric.Type) {
|
||||||
cclog.ComponentError(m.name, "Metric", metric.Name, "uses invalid type", metric.Type)
|
cclog.ComponentErrorf(m.name, "Metric %s uses invalid type %s", metric.Name, metric.Type)
|
||||||
metric.Calc = ""
|
metric.Calc = ""
|
||||||
} else if !testLikwidMetricFormula(metric.Calc, params) {
|
} else if !testLikwidMetricFormula(metric.Calc, params) {
|
||||||
cclog.ComponentError(m.name, "Metric", metric.Name, "cannot be calculated with given counters")
|
cclog.ComponentError(m.name, "Metric %s cannot be calculated with given counters", metric.Name)
|
||||||
metric.Calc = ""
|
metric.Calc = ""
|
||||||
} else {
|
} else {
|
||||||
globalParams = append(globalParams, metric.Name)
|
globalParams = append(globalParams, metric.Name)
|
||||||
@@ -281,13 +287,13 @@ func (m *LikwidCollector) Init(config json.RawMessage) error {
|
|||||||
for _, metric := range m.config.Metrics {
|
for _, metric := range m.config.Metrics {
|
||||||
// Try to evaluate the global metric
|
// Try to evaluate the global metric
|
||||||
if !checkMetricType(metric.Type) {
|
if !checkMetricType(metric.Type) {
|
||||||
cclog.ComponentError(m.name, "Metric", metric.Name, "uses invalid type", metric.Type)
|
cclog.ComponentErrorf(m.name, "Metric %s uses invalid type %s", metric.Name, metric.Type)
|
||||||
metric.Calc = ""
|
metric.Calc = ""
|
||||||
} else if !testLikwidMetricFormula(metric.Calc, globalParams) {
|
} else if !testLikwidMetricFormula(metric.Calc, globalParams) {
|
||||||
cclog.ComponentError(m.name, "Metric", metric.Name, "cannot be calculated with given counters")
|
cclog.ComponentError(m.name, "Metric %s cannot be calculated with given counters", metric.Name)
|
||||||
metric.Calc = ""
|
metric.Calc = ""
|
||||||
} else if !checkMetricType(metric.Type) {
|
} else if !checkMetricType(metric.Type) {
|
||||||
cclog.ComponentError(m.name, "Metric", metric.Name, "has invalid type")
|
cclog.ComponentError(m.name, "Metric %s has invalid type", metric.Name)
|
||||||
metric.Calc = ""
|
metric.Calc = ""
|
||||||
} else {
|
} else {
|
||||||
totalMetrics++
|
totalMetrics++
|
||||||
@@ -328,7 +334,7 @@ func (m *LikwidCollector) Init(config json.RawMessage) error {
|
|||||||
for _, c := range m.cpulist {
|
for _, c := range m.cpulist {
|
||||||
m.measureThread.Call(
|
m.measureThread.Call(
|
||||||
func() {
|
func() {
|
||||||
retCode := C.HPMaddThread(C.uint32_t(c))
|
retCode := C.cc_add_hwthread(C.int(c))
|
||||||
if retCode != 0 {
|
if retCode != 0 {
|
||||||
err := fmt.Errorf("C.HPMaddThread(%v) failed with return code %v", c, retCode)
|
err := fmt.Errorf("C.HPMaddThread(%v) failed with return code %v", c, retCode)
|
||||||
cclog.ComponentError(m.name, err.Error())
|
cclog.ComponentError(m.name, err.Error())
|
||||||
@@ -375,16 +381,16 @@ func (m *LikwidCollector) takeMeasurement(evidx int, evset LikwidEventsetConfig,
|
|||||||
// Watch changes for the lock file ()
|
// Watch changes for the lock file ()
|
||||||
watcher, err := fsnotify.NewWatcher()
|
watcher, err := fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("takeMeasurement(): Failed to create a new fsnotify.Watcher: %v", err))
|
"takeMeasurement(): Failed to create a new fsnotify.Watcher: %v", err)
|
||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := watcher.Close(); err != nil {
|
if err := watcher.Close(); err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("takeMeasurement(): Failed to close fsnotify.Watcher: %v", err))
|
"takeMeasurement(): Failed to close fsnotify.Watcher: %v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if len(m.config.LockfilePath) > 0 {
|
if len(m.config.LockfilePath) > 0 {
|
||||||
@@ -597,7 +603,7 @@ func (m *LikwidCollector) calcEventsetMetrics(evset LikwidEventsetConfig, interv
|
|||||||
if tid >= 0 && len(metric.Calc) > 0 {
|
if tid >= 0 && len(metric.Calc) > 0 {
|
||||||
value, err := agg.EvalFloat64Condition(metric.Calc, evset.results[tid])
|
value, err := agg.EvalFloat64Condition(metric.Calc, evset.results[tid])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, "Calculation for metric", metric.Name, "failed:", err.Error())
|
cclog.ComponentErrorf(m.name, "Calculation for metric %s failed: %s", metric.Name, err.Error())
|
||||||
value = 0.0
|
value = 0.0
|
||||||
}
|
}
|
||||||
if m.config.InvalidToZero && (math.IsNaN(value) || math.IsInf(value, 0)) {
|
if m.config.InvalidToZero && (math.IsNaN(value) || math.IsInf(value, 0)) {
|
||||||
@@ -762,7 +768,7 @@ func (m *LikwidCollector) calcGlobalMetrics(groups []LikwidEventsetConfig, inter
|
|||||||
// Evaluate the metric
|
// Evaluate the metric
|
||||||
value, err := agg.EvalFloat64Condition(metric.Calc, params)
|
value, err := agg.EvalFloat64Condition(metric.Calc, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, "Calculation for metric", metric.Name, "failed:", err.Error())
|
cclog.ComponentErrorf(m.name, "Calculation for metric %s failed: %s", metric.Name, err.Error())
|
||||||
value = 0.0
|
value = 0.0
|
||||||
}
|
}
|
||||||
if m.config.InvalidToZero && (math.IsNaN(value) || math.IsInf(value, 0)) {
|
if m.config.InvalidToZero && (math.IsNaN(value) || math.IsInf(value, 0)) {
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ func (m *LoadavgCollector) Read(interval time.Duration, output chan lp.CCMessage
|
|||||||
}
|
}
|
||||||
buffer, err := os.ReadFile(LOADAVGFILE)
|
buffer, err := os.ReadFile(LOADAVGFILE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to read file '%s': %v", LOADAVGFILE, err))
|
"Read(): Failed to read file '%s': %v", LOADAVGFILE, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
@@ -101,9 +101,9 @@ func (m *LoadavgCollector) Read(interval time.Duration, output chan lp.CCMessage
|
|||||||
for i, name := range m.load_matches {
|
for i, name := range m.load_matches {
|
||||||
x, err := strconv.ParseFloat(ls[i], 64)
|
x, err := strconv.ParseFloat(ls[i], 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to convert '%s' to float64: %v", ls[i], err))
|
"Read(): Failed to convert '%s' to float64: %v", ls[i], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if m.load_skips[i] {
|
if m.load_skips[i] {
|
||||||
@@ -120,9 +120,9 @@ func (m *LoadavgCollector) Read(interval time.Duration, output chan lp.CCMessage
|
|||||||
for i, name := range m.proc_matches {
|
for i, name := range m.proc_matches {
|
||||||
x, err := strconv.ParseInt(lv[i], 10, 64)
|
x, err := strconv.ParseInt(lv[i], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to convert '%s' to float64: %v", lv[i], err))
|
"Read(): Failed to convert '%s' to float64: %v", lv[i], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if m.proc_skips[i] {
|
if m.proc_skips[i] {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ func getStats(filename string) map[string]MemstatStats {
|
|||||||
case 5:
|
case 5:
|
||||||
v, err := strconv.ParseFloat(linefields[3], 64)
|
v, err := strconv.ParseFloat(linefields[3], 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cclog.ComponentDebug("getStats", strings.Trim(linefields[2], ":"), v, linefields[4])
|
cclog.ComponentDebug("MemstatCollector", "getStats %s value %v unit %s", strings.Trim(linefields[2], ":"), v, linefields[4])
|
||||||
stats[strings.Trim(linefields[2], ":")] = MemstatStats{
|
stats[strings.Trim(linefields[2], ":")] = MemstatStats{
|
||||||
value: v,
|
value: v,
|
||||||
unit: linefields[4],
|
unit: linefields[4],
|
||||||
|
|||||||
@@ -222,16 +222,16 @@ func (m *NetstatCollector) Read(interval time.Duration, output chan lp.CCMessage
|
|||||||
|
|
||||||
file, err := os.Open(NETSTATFILE)
|
file, err := os.Open(NETSTATFILE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to open file '%s': %v", NETSTATFILE, err))
|
"Read(): Failed to open file '%s': %v", NETSTATFILE, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := file.Close(); err != nil {
|
if err := file.Close(); err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to close file '%s': %v", NETSTATFILE, err))
|
"Read(): Failed to close file '%s': %v", NETSTATFILE, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -125,10 +125,9 @@ func (m *nfsCollector) Read(interval time.Duration, output chan lp.CCMessage) {
|
|||||||
timestamp := time.Now()
|
timestamp := time.Now()
|
||||||
|
|
||||||
if err := m.updateStats(); err != nil {
|
if err := m.updateStats(); err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): updateStats() failed: %v", err),
|
"Read(): updateStats() failed: %v", err)
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var prefix string
|
var prefix string
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ func (m *NUMAStatsCollector) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialized
|
// Initialized
|
||||||
cclog.ComponentDebug(m.name, "initialized", len(m.topology), "NUMA domains")
|
cclog.ComponentDebugf(m.name, "initialized %d NUMA domains", len(m.topology))
|
||||||
m.init = true
|
m.init = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ func (m *NvidiaCollector) Init(config json.RawMessage) error {
|
|||||||
// Skip excluded devices by ID
|
// Skip excluded devices by ID
|
||||||
str_i := strconv.Itoa(i)
|
str_i := strconv.Itoa(i)
|
||||||
if slices.Contains(m.config.ExcludeDevices, str_i) {
|
if slices.Contains(m.config.ExcludeDevices, str_i) {
|
||||||
cclog.ComponentDebug(m.name, "Skipping excluded device", str_i)
|
cclog.ComponentDebugf(m.name, "Skipping excluded device %s", str_i)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ func (m *NvidiaCollector) Init(config json.RawMessage) error {
|
|||||||
device, ret := nvml.DeviceGetHandleByIndex(i)
|
device, ret := nvml.DeviceGetHandleByIndex(i)
|
||||||
if ret != nvml.SUCCESS {
|
if ret != nvml.SUCCESS {
|
||||||
err = errors.New(nvml.ErrorString(ret))
|
err = errors.New(nvml.ErrorString(ret))
|
||||||
cclog.ComponentError(m.name, "Unable to get device at index", i, ":", err.Error())
|
cclog.ComponentErrorf(m.name, "Unable to get device at index %d: %s", i, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ func (m *NvidiaCollector) Init(config json.RawMessage) error {
|
|||||||
pciInfo, ret := nvml.DeviceGetPciInfo(device)
|
pciInfo, ret := nvml.DeviceGetPciInfo(device)
|
||||||
if ret != nvml.SUCCESS {
|
if ret != nvml.SUCCESS {
|
||||||
err = errors.New(nvml.ErrorString(ret))
|
err = errors.New(nvml.ErrorString(ret))
|
||||||
cclog.ComponentError(m.name, "Unable to get PCI info for device at index", i, ":", err.Error())
|
cclog.ComponentErrorf(m.name, "Unable to get PCI info for device at index %d: %s", i, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Create PCI ID in the common format used by the NVML.
|
// Create PCI ID in the common format used by the NVML.
|
||||||
@@ -141,7 +141,7 @@ func (m *NvidiaCollector) Init(config json.RawMessage) error {
|
|||||||
|
|
||||||
// Skip excluded devices specified by PCI ID
|
// Skip excluded devices specified by PCI ID
|
||||||
if slices.Contains(m.config.ExcludeDevices, pci_id) {
|
if slices.Contains(m.config.ExcludeDevices, pci_id) {
|
||||||
cclog.ComponentDebug(m.name, "Skipping excluded device", pci_id)
|
cclog.ComponentDebugf(m.name, "Skipping excluded device %s", pci_id)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ func (m *NvidiaCollector) Init(config json.RawMessage) error {
|
|||||||
if m.config.AddBoardNumberMeta {
|
if m.config.AddBoardNumberMeta {
|
||||||
board, ret := nvml.DeviceGetBoardPartNumber(device)
|
board, ret := nvml.DeviceGetBoardPartNumber(device)
|
||||||
if ret != nvml.SUCCESS {
|
if ret != nvml.SUCCESS {
|
||||||
cclog.ComponentError(m.name, "Unable to get boart part number for device at index", i, ":", err.Error())
|
cclog.ComponentErrorf(m.name, "Unable to get boart part number for device at index %d: %s", i, err.Error())
|
||||||
} else {
|
} else {
|
||||||
g.meta["board_number"] = board
|
g.meta["board_number"] = board
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ func (m *NvidiaCollector) Init(config json.RawMessage) error {
|
|||||||
if m.config.AddSerialMeta {
|
if m.config.AddSerialMeta {
|
||||||
serial, ret := nvml.DeviceGetSerial(device)
|
serial, ret := nvml.DeviceGetSerial(device)
|
||||||
if ret != nvml.SUCCESS {
|
if ret != nvml.SUCCESS {
|
||||||
cclog.ComponentError(m.name, "Unable to get serial number for device at index", i, ":", err.Error())
|
cclog.ComponentErrorf(m.name, "Unable to get serial number for device at index %d: %s", i, err.Error())
|
||||||
} else {
|
} else {
|
||||||
g.meta["serial"] = serial
|
g.meta["serial"] = serial
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ func (m *NvidiaCollector) Init(config json.RawMessage) error {
|
|||||||
if m.config.AddUuidMeta {
|
if m.config.AddUuidMeta {
|
||||||
uuid, ret := nvml.DeviceGetUUID(device)
|
uuid, ret := nvml.DeviceGetUUID(device)
|
||||||
if ret != nvml.SUCCESS {
|
if ret != nvml.SUCCESS {
|
||||||
cclog.ComponentError(m.name, "Unable to get UUID for device at index", i, ":", err.Error())
|
cclog.ComponentErrorf(m.name, "Unable to get UUID for device at index %d: %s", i, err.Error())
|
||||||
} else {
|
} else {
|
||||||
g.meta["uuid"] = uuid
|
g.meta["uuid"] = uuid
|
||||||
}
|
}
|
||||||
@@ -1128,97 +1128,97 @@ func (m *NvidiaCollector) Read(interval time.Duration, output chan lp.CCMessage)
|
|||||||
}
|
}
|
||||||
err = readMemoryInfo(device, output)
|
err = readMemoryInfo(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readMemoryInfo for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readMemoryInfo for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readUtilization(device, output)
|
err = readUtilization(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readUtilization for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readUtilization for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readTemp(device, output)
|
err = readTemp(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readTemp for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readTemp for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readFan(device, output)
|
err = readFan(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readFan for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readFan for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readEccMode(device, output)
|
err = readEccMode(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readEccMode for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readEccMode for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readPerfState(device, output)
|
err = readPerfState(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readPerfState for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readPerfState for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readPowerUsage(device, output)
|
err = readPowerUsage(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readPowerUsage for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readPowerUsage for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readEnergyConsumption(device, output)
|
err = readEnergyConsumption(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readEnergyConsumption for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readEnergyConsumption for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readClocks(device, output)
|
err = readClocks(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readClocks for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readClocks for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readMaxClocks(device, output)
|
err = readMaxClocks(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readMaxClocks for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readMaxClocks for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readEccErrors(device, output)
|
err = readEccErrors(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readEccErrors for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readEccErrors for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readPowerLimit(device, output)
|
err = readPowerLimit(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readPowerLimit for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readPowerLimit for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readEncUtilization(device, output)
|
err = readEncUtilization(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readEncUtilization for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readEncUtilization for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readDecUtilization(device, output)
|
err = readDecUtilization(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readDecUtilization for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readDecUtilization for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readRemappedRows(device, output)
|
err = readRemappedRows(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readRemappedRows for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readRemappedRows for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readBarMemoryInfo(device, output)
|
err = readBarMemoryInfo(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readBarMemoryInfo for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readBarMemoryInfo for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readProcessCounts(device, output)
|
err = readProcessCounts(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readProcessCounts for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readProcessCounts for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readViolationStats(device, output)
|
err = readViolationStats(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readViolationStats for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readViolationStats for device %s failed", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readNVLinkStats(device, output)
|
err = readNVLinkStats(device, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentDebug(m.name, "readNVLinkStats for device", name, "failed")
|
cclog.ComponentDebugf(m.name, "readNVLinkStats for device %s failed", name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1244,7 +1244,7 @@ func (m *NvidiaCollector) Read(interval time.Duration, output chan lp.CCMessage)
|
|||||||
if maxMig == 0 {
|
if maxMig == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cclog.ComponentDebug(m.name, "Reading MIG devices for GPU", i)
|
cclog.ComponentDebugf(m.name, "Reading MIG devices for GPU %d", i)
|
||||||
|
|
||||||
for j := range maxMig {
|
for j := range maxMig {
|
||||||
mdev, ret := nvml.DeviceGetMigDeviceHandleByIndex(m.gpus[i].device, j)
|
mdev, ret := nvml.DeviceGetMigDeviceHandleByIndex(m.gpus[i].device, j)
|
||||||
@@ -1268,7 +1268,7 @@ func (m *NvidiaCollector) Read(interval time.Duration, output chan lp.CCMessage)
|
|||||||
if m.config.UseUuidForMigDevices {
|
if m.config.UseUuidForMigDevices {
|
||||||
uuid, ret := nvml.DeviceGetUUID(mdev)
|
uuid, ret := nvml.DeviceGetUUID(mdev)
|
||||||
if ret != nvml.SUCCESS {
|
if ret != nvml.SUCCESS {
|
||||||
cclog.ComponentError(m.name, "Unable to get UUID for mig device at index", j, ":", err.Error())
|
cclog.ComponentErrorf(m.name, "Unable to get UUID for mig device at index %d: %s", j, err.Error())
|
||||||
} else {
|
} else {
|
||||||
migDevice.tags["stype-id"] = uuid
|
migDevice.tags["stype-id"] = uuid
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,11 +208,10 @@ func (m *RAPLCollector) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialized
|
// Initialized
|
||||||
cclog.ComponentDebug(
|
cclog.ComponentDebugf(
|
||||||
m.name,
|
m.name,
|
||||||
"initialized",
|
"initialized %d zones with running average power limit (RAPL) monitoring attributes",
|
||||||
len(m.RAPLZoneInfo),
|
len(m.RAPLZoneInfo))
|
||||||
"zones with running average power limit (RAPL) monitoring attributes")
|
|
||||||
m.init = true
|
m.init = true
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ func (m *RocmSmiCollector) Init(config json.RawMessage) error {
|
|||||||
if m.config.AddSerialMeta {
|
if m.config.AddSerialMeta {
|
||||||
serial, ret := rocm_smi.DeviceGetSerialNumber(device)
|
serial, ret := rocm_smi.DeviceGetSerialNumber(device)
|
||||||
if ret != rocm_smi.STATUS_SUCCESS {
|
if ret != rocm_smi.STATUS_SUCCESS {
|
||||||
cclog.ComponentError(m.name, "Unable to get serial number for device at index", i, ":", rocm_smi.StatusStringNoError(ret))
|
cclog.ComponentErrorf(m.name, "Unable to get serial number for device at index %d: %s", i, rocm_smi.StatusStringNoError(ret))
|
||||||
} else {
|
} else {
|
||||||
dev.meta["serial"] = serial
|
dev.meta["serial"] = serial
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ func (m *RocmSmiCollector) Read(interval time.Duration, output chan lp.CCMessage
|
|||||||
for _, dev := range m.devices {
|
for _, dev := range m.devices {
|
||||||
metrics, ret := rocm_smi.DeviceGetMetrics(dev.device)
|
metrics, ret := rocm_smi.DeviceGetMetrics(dev.device)
|
||||||
if ret != rocm_smi.STATUS_SUCCESS {
|
if ret != rocm_smi.STATUS_SUCCESS {
|
||||||
cclog.ComponentError(m.name, "Unable to get metrics for device at index", dev.index, ":", rocm_smi.StatusStringNoError(ret))
|
cclog.ComponentErrorf(m.name, "Unable to get metrics for device at index %d: %s", dev.index, rocm_smi.StatusStringNoError(ret))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,15 +147,15 @@ func (m *SchedstatCollector) Read(interval time.Duration, output chan lp.CCMessa
|
|||||||
|
|
||||||
file, err := os.Open(SCHEDSTATFILE)
|
file, err := os.Open(SCHEDSTATFILE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to open file '%s': %v", SCHEDSTATFILE, err))
|
"Read(): Failed to open file '%s': %v", SCHEDSTATFILE, err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := file.Close(); err != nil {
|
if err := file.Close(); err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to close file '%s': %v", SCHEDSTATFILE, err))
|
"Read(): Failed to close file '%s': %v", SCHEDSTATFILE, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ func (m *SlurmCgroupCollector) Read(interval time.Duration, output chan lp.CCMes
|
|||||||
globPattern := filepath.Join(m.cgroupBase, "job_*")
|
globPattern := filepath.Join(m.cgroupBase, "job_*")
|
||||||
jobDirs, err := filepath.Glob(globPattern)
|
jobDirs, err := filepath.Glob(globPattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, "Error globbing job directories:", err.Error())
|
cclog.ComponentErrorf(m.name, "Error globbing job directories: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ func (m *SlurmCgroupCollector) Read(interval time.Duration, output chan lp.CCMes
|
|||||||
|
|
||||||
jobdata, err := m.ReadJobData(jKey)
|
jobdata, err := m.ReadJobData(jKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, "Error reading job data for", jKey, ":", err.Error())
|
cclog.ComponentError(m.name, "Error reading job data for %s: %s", jKey, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -228,12 +228,12 @@ func (m *SmartMonCollector) Read(interval time.Duration, output chan lp.CCMessag
|
|||||||
|
|
||||||
stdout, err := command.Output()
|
stdout, err := command.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, "cannot read data for device", d.Name)
|
cclog.ComponentErrorf(m.name, "cannot read data for device %s", d.Name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(stdout, &data)
|
err = json.Unmarshal(stdout, &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, "cannot unmarshal data for device", d.Name)
|
cclog.ComponentErrorf(m.name, "cannot unmarshal data for device %s", d.Name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !m.excludeMetric.temp {
|
if !m.excludeMetric.temp {
|
||||||
|
|||||||
@@ -188,16 +188,16 @@ func (m *TempCollector) Read(interval time.Duration, output chan lp.CCMessage) {
|
|||||||
// Read sensor file
|
// Read sensor file
|
||||||
buffer, err := os.ReadFile(sensor.file)
|
buffer, err := os.ReadFile(sensor.file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to read file '%s': %v", sensor.file, err))
|
"Read(): Failed to read file '%s': %v", sensor.file, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
x, err := strconv.ParseInt(strings.TrimSpace(string(buffer)), 10, 64)
|
x, err := strconv.ParseInt(strings.TrimSpace(string(buffer)), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to convert temperature '%s' to int64: %v", buffer, err))
|
"Read(): Failed to convert temperature '%s' to int64: %v", buffer, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
x /= 1000
|
x /= 1000
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ func (m *TopProcsCollector) Read(interval time.Duration, output chan lp.CCMessag
|
|||||||
command := exec.Command("ps", "-Ao", "comm", "--sort=-pcpu")
|
command := exec.Command("ps", "-Ao", "comm", "--sort=-pcpu")
|
||||||
stdout, err := command.Output()
|
stdout, err := command.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(
|
cclog.ComponentErrorf(
|
||||||
m.name,
|
m.name,
|
||||||
fmt.Sprintf("Read(): Failed to read output from command \"%s\": %v", command.String(), err))
|
"Read(): Failed to read output from command \"%s\": %v", command.String(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,18 +35,18 @@ type metricRouterTagConfig struct {
|
|||||||
|
|
||||||
// Metric router configuration
|
// Metric router configuration
|
||||||
type metricRouterConfig struct {
|
type metricRouterConfig struct {
|
||||||
HostnameTagName string `json:"hostname_tag"` // Key name used when adding the hostname to a metric (default 'hostname')
|
HostnameTagName string `json:"hostname_tag,omitempty"` // Key name used when adding the hostname to a metric (default 'hostname')
|
||||||
AddTags []metricRouterTagConfig `json:"add_tags"` // List of tags that are added when the condition is met
|
AddTags []metricRouterTagConfig `json:"add_tags,omitempty"` // List of tags that are added when the condition is met
|
||||||
DelTags []metricRouterTagConfig `json:"delete_tags"` // List of tags that are removed when the condition is met
|
DelTags []metricRouterTagConfig `json:"delete_tags,omitempty"` // List of tags that are removed when the condition is met
|
||||||
IntervalAgg []agg.MetricAggregatorIntervalConfig `json:"interval_aggregates"` // List of aggregation function processed at the end of an interval
|
IntervalAgg []agg.MetricAggregatorIntervalConfig `json:"interval_aggregates,omitempty"` // List of aggregation function processed at the end of an interval
|
||||||
DropMetrics []string `json:"drop_metrics"` // List of metric names to drop. For fine-grained dropping use drop_metrics_if
|
DropMetrics []string `json:"drop_metrics,omitempty"` // List of metric names to drop. For fine-grained dropping use drop_metrics_if
|
||||||
DropMetricsIf []string `json:"drop_metrics_if"` // List of evaluatable terms to drop metrics
|
DropMetricsIf []string `json:"drop_metrics_if,omitempty"` // List of evaluatable terms to drop metrics
|
||||||
RenameMetrics map[string]string `json:"rename_metrics"` // Map to rename metric name from key to value
|
RenameMetrics map[string]string `json:"rename_metrics,omitempty"` // Map to rename metric name from key to value
|
||||||
IntervalStamp bool `json:"interval_timestamp"` // Update timestamp periodically by ticker each interval?
|
IntervalStamp bool `json:"interval_timestamp,omitempty"` // Update timestamp periodically by ticker each interval?
|
||||||
NumCacheIntervals int `json:"num_cache_intervals"` // Number of intervals of cached metrics for evaluation
|
NumCacheIntervals int `json:"num_cache_intervals,omitempty"` // Number of intervals of cached metrics for evaluation
|
||||||
MaxForward int `json:"max_forward"` // Number of maximal forwarded metrics at one select
|
MaxForward int `json:"max_forward,omitempty"` // Number of maximal forwarded metrics at one select
|
||||||
NormalizeUnits bool `json:"normalize_units"` // Check unit meta flag and normalize it using cc-units
|
NormalizeUnits bool `json:"normalize_units,omitempty"` // Check unit meta flag and normalize it using cc-units
|
||||||
ChangeUnitPrefix map[string]string `json:"change_unit_prefix"` // Add prefix that should be applied to the metrics
|
ChangeUnitPrefix map[string]string `json:"change_unit_prefix,omitempty"` // Add prefix that should be applied to the metrics
|
||||||
MessageProcessor json.RawMessage `json:"process_messages,omitempty"`
|
MessageProcessor json.RawMessage `json:"process_messages,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ func (r *metricRouter) Start() {
|
|||||||
|
|
||||||
case timestamp := <-timeChan:
|
case timestamp := <-timeChan:
|
||||||
r.timestamp = timestamp
|
r.timestamp = timestamp
|
||||||
cclog.ComponentDebug("MetricRouter", "Update timestamp", r.timestamp.UnixNano())
|
cclog.ComponentDebugf("MetricRouter", "Update timestamp %d", r.timestamp.UnixNano())
|
||||||
|
|
||||||
case p := <-r.coll_input:
|
case p := <-r.coll_input:
|
||||||
coll_forward(p)
|
coll_forward(p)
|
||||||
|
|||||||
Reference in New Issue
Block a user