Fix seconds reported by schedstat (#1426)

Upstream bugfix: https://github.com/prometheus/procfs/pull/191

Signed-off-by: Phil Frost <phil@postmates.com>
This commit is contained in:
Phil Frost 2019-08-06 13:08:06 -04:00 committed by Ben Kochie
commit 26d4fbdf07
10 changed files with 509 additions and 40 deletions

View file

@ -20,6 +20,8 @@ import (
"github.com/prometheus/procfs"
)
const nsPerSec = 1e9
var (
runningSecondsTotal = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "schedstat", "running_seconds_total"),
@ -71,14 +73,14 @@ func (c *schedstatCollector) Update(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(
runningSecondsTotal,
prometheus.CounterValue,
cpu.RunningSeconds(),
float64(cpu.RunningNanoseconds)/nsPerSec,
cpu.CPUNum,
)
ch <- prometheus.MustNewConstMetric(
waitingSecondsTotal,
prometheus.CounterValue,
cpu.WaitingSeconds(),
float64(cpu.WaitingNanoseconds)/nsPerSec,
cpu.CPUNum,
)