Skip to content

Commit

Permalink
Fix seconds reported by schedstat (#1426)
Browse files Browse the repository at this point in the history
Upstream bugfix: prometheus/procfs#191

Signed-off-by: Phil Frost <[email protected]>
  • Loading branch information
Phil Frost authored and SuperQ committed Aug 6, 2019
1 parent 75462bf commit 26d4fbd
Show file tree
Hide file tree
Showing 10 changed files with 509 additions and 40 deletions.
8 changes: 4 additions & 4 deletions collector/fixtures/e2e-64k-page-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2440,16 +2440,16 @@ node_qdisc_requeues_total{device="eth0",kind="pfifo_fast"} 2
node_qdisc_requeues_total{device="wlan0",kind="fq"} 1
# HELP node_schedstat_running_seconds_total Number of seconds CPU spent running a process.
# TYPE node_schedstat_running_seconds_total counter
node_schedstat_running_seconds_total{cpu="0"} 2.045936778163039e+13
node_schedstat_running_seconds_total{cpu="1"} 1.904686152592476e+13
node_schedstat_running_seconds_total{cpu="0"} 2.045936778163039e+06
node_schedstat_running_seconds_total{cpu="1"} 1.904686152592476e+06
# HELP node_schedstat_timeslices_total Number of timeslices executed by CPU.
# TYPE node_schedstat_timeslices_total counter
node_schedstat_timeslices_total{cpu="0"} 4.767485306e+09
node_schedstat_timeslices_total{cpu="1"} 5.145567945e+09
# HELP node_schedstat_waiting_seconds_total Number of seconds spent by processing waiting for this CPU.
# TYPE node_schedstat_waiting_seconds_total counter
node_schedstat_waiting_seconds_total{cpu="0"} 3.43796328169361e+12
node_schedstat_waiting_seconds_total{cpu="1"} 3.64107263788241e+12
node_schedstat_waiting_seconds_total{cpu="0"} 343796.328169361
node_schedstat_waiting_seconds_total{cpu="1"} 364107.263788241
# HELP node_scrape_collector_duration_seconds node_exporter: Duration of a collector scrape.
# TYPE node_scrape_collector_duration_seconds gauge
# HELP node_scrape_collector_success node_exporter: Whether a collector succeeded.
Expand Down
8 changes: 4 additions & 4 deletions collector/fixtures/e2e-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2440,16 +2440,16 @@ node_qdisc_requeues_total{device="eth0",kind="pfifo_fast"} 2
node_qdisc_requeues_total{device="wlan0",kind="fq"} 1
# HELP node_schedstat_running_seconds_total Number of seconds CPU spent running a process.
# TYPE node_schedstat_running_seconds_total counter
node_schedstat_running_seconds_total{cpu="0"} 2.045936778163039e+13
node_schedstat_running_seconds_total{cpu="1"} 1.904686152592476e+13
node_schedstat_running_seconds_total{cpu="0"} 2.045936778163039e+06
node_schedstat_running_seconds_total{cpu="1"} 1.904686152592476e+06
# HELP node_schedstat_timeslices_total Number of timeslices executed by CPU.
# TYPE node_schedstat_timeslices_total counter
node_schedstat_timeslices_total{cpu="0"} 4.767485306e+09
node_schedstat_timeslices_total{cpu="1"} 5.145567945e+09
# HELP node_schedstat_waiting_seconds_total Number of seconds spent by processing waiting for this CPU.
# TYPE node_schedstat_waiting_seconds_total counter
node_schedstat_waiting_seconds_total{cpu="0"} 3.43796328169361e+12
node_schedstat_waiting_seconds_total{cpu="1"} 3.64107263788241e+12
node_schedstat_waiting_seconds_total{cpu="0"} 343796.328169361
node_schedstat_waiting_seconds_total{cpu="1"} 364107.263788241
# HELP node_scrape_collector_duration_seconds node_exporter: Duration of a collector scrape.
# TYPE node_scrape_collector_duration_seconds gauge
# HELP node_scrape_collector_success node_exporter: Whether a collector succeeded.
Expand Down
6 changes: 4 additions & 2 deletions collector/schedstat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/prometheus/procfs"
)

const nsPerSec = 1e9

var (
runningSecondsTotal = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "schedstat", "running_seconds_total"),
Expand Down Expand Up @@ -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,
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
github.com/prometheus/common v0.4.1
github.com/prometheus/procfs v0.0.4-0.20190702183519-8f55e607908e
github.com/prometheus/procfs v0.0.4-0.20190731153504-5da962fa40f1
github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/soundcloud/go-runit v0.0.0-20150630195641-06ad41a06c4a
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.4-0.20190702183519-8f55e607908e h1:p57e/ejwNofSHhEh+d7KoCVpHSTN3efX5Aj3z0jGWIE=
github.com/prometheus/procfs v0.0.4-0.20190702183519-8f55e607908e/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.0.4-0.20190731153504-5da962fa40f1 h1:uqK/YnaVFq1uofHlzj+IR4HhCYA/nbrvJ431l7cm7Vs=
github.com/prometheus/procfs v0.0.4-0.20190731153504-5da962fa40f1/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745 h1:IuH7WumZNax0D+rEqmy2TyhKCzrtMGqbZO0b8rO00JA=
github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745/go.mod h1:G81aIFAMS9ECrwBYR9YxhlPjWgrItd+Kje78O6+uqm8=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand Down
266 changes: 266 additions & 0 deletions vendor/github.com/prometheus/procfs/fixtures.ttar

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/prometheus/procfs/internal/util/parse.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 26d4fbd

Please sign in to comment.