mirror of
https://github.com/prometheus/node_exporter.git
synced 2025-02-21 03:25:57 -08:00
remove cgo dependency
by hardcoding `USER_HZ` (aka. `_SC_CLK_TCK`) to 100, which it is for all platforms Go supports. See prometheus/node_exporter#52 for discussion around this too. Closes prometheus/node_exporter#52.
This commit is contained in:
parent
b4f40ab13f
commit
2ee8470004
|
@ -11,11 +11,9 @@ import (
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// #include <unistd.h>
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
procStat = "/proc/stat"
|
procStat = "/proc/stat"
|
||||||
|
userHz = 100
|
||||||
)
|
)
|
||||||
|
|
||||||
type statCollector struct {
|
type statCollector struct {
|
||||||
|
@ -112,7 +110,7 @@ func (c *statCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Convert from ticks to seconds
|
// Convert from ticks to seconds
|
||||||
value /= float64(C.sysconf(C._SC_CLK_TCK))
|
value /= userHz
|
||||||
c.cpu.With(prometheus.Labels{"cpu": parts[0], "mode": cpuFields[i]}).Set(value)
|
c.cpu.With(prometheus.Labels{"cpu": parts[0], "mode": cpuFields[i]}).Set(value)
|
||||||
}
|
}
|
||||||
case parts[0] == "intr":
|
case parts[0] == "intr":
|
||||||
|
|
Loading…
Reference in a new issue