Reduce min Go version to 1.16 and use time.Unix in gpfsMetric

This commit is contained in:
Thomas Roehl 2022-01-28 17:12:55 +01:00
parent 151be7cccd
commit 8bd78561d8
2 changed files with 12 additions and 5 deletions

View File

@ -130,14 +130,21 @@ func (m *GpfsCollector) Read(interval time.Duration, output chan lp.CCMetric) {
continue
}
timestampInt, err := strconv.ParseInt(key_value["_t_"]+key_value["_tu_"], 10, 64)
timestamp := time.UnixMicro(timestampInt)
timestampSec, err := strconv.ParseInt(key_value["_t_"], 10, 64)
if err != nil {
fmt.Fprintf(os.Stderr,
"GpfsCollector.Read(): Failed to convert time stamp '%s': %s\n",
key_value["_t_"]+key_value["_tu_"], err.Error())
"GpfsCollector.Read(): Failed to convert time stamp seconds '%s': %s\n",
key_value["_t_"], err.Error())
continue
}
timestampNano, err := strconv.ParseInt(key_value["_tu_"], 10, 64)
if err != nil {
fmt.Fprintf(os.Stderr,
"GpfsCollector.Read(): Failed to convert time stamp nanoseconds '%s': %s\n",
key_value["_tu_"], err.Error())
continue
}
timestamp := time.Unix(timestampSec, timestampNano)
// bytes read
bytesRead, err := strconv.ParseInt(key_value["_br_"], 10, 64)

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/ClusterCockpit/cc-metric-collector
go 1.17
go 1.16
require (
github.com/NVIDIA/go-nvml v0.11.1-0