mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-30 07:59:53 -08:00
Changes per code review.
This commit is contained in:
parent
062443133e
commit
09a3de1669
|
@ -11,6 +11,11 @@ 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"
|
||||||
)
|
)
|
||||||
|
@ -99,7 +104,7 @@ func (c *statCollector) Update() (updates int, err error) {
|
||||||
parts := strings.Fields(scanner.Text())
|
parts := strings.Fields(scanner.Text())
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(parts[0], "cpu"):
|
case strings.HasPrefix(parts[0], "cpu"):
|
||||||
// Export only per-cpu stats, it can be aggregted up in prometheus.
|
// Export only per-cpu stats, it can be aggregated up in prometheus.
|
||||||
if parts[0] == "cpu" {
|
if parts[0] == "cpu" {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -110,7 +115,8 @@ func (c *statCollector) Update() (updates int, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return updates, err
|
return updates, err
|
||||||
}
|
}
|
||||||
value /= 100 // Convert from ticks to seconds
|
// Convert from ticks to seconds
|
||||||
|
value /= float64(C.sysconf(C._SC_CLK_TCK))
|
||||||
cpuMetrics.Set(map[string]string{"cpu": parts[0], "mode": cpuFields[i]}, value)
|
cpuMetrics.Set(map[string]string{"cpu": parts[0], "mode": cpuFields[i]}, value)
|
||||||
}
|
}
|
||||||
case parts[0] == "intr":
|
case parts[0] == "intr":
|
||||||
|
|
Loading…
Reference in a new issue