mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-23 12:30:46 +01:00
feat: add support for cpu freq governor metrics
Signed-off-by: Lukas Coppens <lukas.coppens@be-mobile.com>
This commit is contained in:
parent
8d3c594346
commit
fe19fdd1e8
@ -23,17 +23,17 @@ import (
|
|||||||
var (
|
var (
|
||||||
cpuFreqHertzDesc = prometheus.NewDesc(
|
cpuFreqHertzDesc = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_hertz"),
|
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_hertz"),
|
||||||
"Current cpu thread frequency in hertz.",
|
"Current CPU thread frequency in hertz.",
|
||||||
[]string{"cpu"}, nil,
|
[]string{"cpu"}, nil,
|
||||||
)
|
)
|
||||||
cpuFreqMinDesc = prometheus.NewDesc(
|
cpuFreqMinDesc = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_min_hertz"),
|
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_min_hertz"),
|
||||||
"Minimum cpu thread frequency in hertz.",
|
"Minimum CPU thread frequency in hertz.",
|
||||||
[]string{"cpu"}, nil,
|
[]string{"cpu"}, nil,
|
||||||
)
|
)
|
||||||
cpuFreqMaxDesc = prometheus.NewDesc(
|
cpuFreqMaxDesc = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_max_hertz"),
|
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_max_hertz"),
|
||||||
"Maximum cpu thread frequency in hertz.",
|
"Maximum CPU thread frequency in hertz.",
|
||||||
[]string{"cpu"}, nil,
|
[]string{"cpu"}, nil,
|
||||||
)
|
)
|
||||||
cpuFreqScalingFreqDesc = prometheus.NewDesc(
|
cpuFreqScalingFreqDesc = prometheus.NewDesc(
|
||||||
@ -51,4 +51,9 @@ var (
|
|||||||
"Maximum scaled CPU thread frequency in hertz.",
|
"Maximum scaled CPU thread frequency in hertz.",
|
||||||
[]string{"cpu"}, nil,
|
[]string{"cpu"}, nil,
|
||||||
)
|
)
|
||||||
|
cpuFreqScalingGovernorDesc = prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_governor"),
|
||||||
|
"Current enabled CPU frequency governor.",
|
||||||
|
[]string{"cpu", "governor"}, nil,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
@ -104,6 +104,22 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error {
|
|||||||
stats.Name,
|
stats.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if stats.Governor != "" {
|
||||||
|
availableGovernors := strings.Split(stats.AvailableGovernors, " ")
|
||||||
|
for _, g := range availableGovernors {
|
||||||
|
state := 0
|
||||||
|
if g == stats.Governor {
|
||||||
|
state = 1
|
||||||
|
}
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
cpuFreqScalingGovernorDesc,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(state),
|
||||||
|
stats.Name,
|
||||||
|
g,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -326,6 +326,16 @@ node_cpu_scaling_frequency_min_hertz{cpu="0"} 8e+08
|
|||||||
node_cpu_scaling_frequency_min_hertz{cpu="1"} 8e+08
|
node_cpu_scaling_frequency_min_hertz{cpu="1"} 8e+08
|
||||||
node_cpu_scaling_frequency_min_hertz{cpu="2"} 1e+06
|
node_cpu_scaling_frequency_min_hertz{cpu="2"} 1e+06
|
||||||
node_cpu_scaling_frequency_min_hertz{cpu="3"} 1e+06
|
node_cpu_scaling_frequency_min_hertz{cpu="3"} 1e+06
|
||||||
|
# HELP node_cpu_scaling_governor Current enabled CPU frequency governor.
|
||||||
|
# TYPE node_cpu_scaling_governor gauge
|
||||||
|
node_cpu_scaling_governor{cpu="0",governor="performance"} 0
|
||||||
|
node_cpu_scaling_governor{cpu="0",governor="powersave"} 1
|
||||||
|
node_cpu_scaling_governor{cpu="1",governor="performance"} 0
|
||||||
|
node_cpu_scaling_governor{cpu="1",governor="powersave"} 1
|
||||||
|
node_cpu_scaling_governor{cpu="2",governor="performance"} 0
|
||||||
|
node_cpu_scaling_governor{cpu="2",governor="powersave"} 1
|
||||||
|
node_cpu_scaling_governor{cpu="3",governor="performance"} 0
|
||||||
|
node_cpu_scaling_governor{cpu="3",governor="powersave"} 1
|
||||||
# HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.
|
# HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.
|
||||||
# TYPE node_cpu_seconds_total counter
|
# TYPE node_cpu_seconds_total counter
|
||||||
node_cpu_seconds_total{cpu="0",mode="idle"} 10870.69
|
node_cpu_seconds_total{cpu="0",mode="idle"} 10870.69
|
||||||
|
@ -348,6 +348,16 @@ node_cpu_scaling_frequency_min_hertz{cpu="0"} 8e+08
|
|||||||
node_cpu_scaling_frequency_min_hertz{cpu="1"} 8e+08
|
node_cpu_scaling_frequency_min_hertz{cpu="1"} 8e+08
|
||||||
node_cpu_scaling_frequency_min_hertz{cpu="2"} 1e+06
|
node_cpu_scaling_frequency_min_hertz{cpu="2"} 1e+06
|
||||||
node_cpu_scaling_frequency_min_hertz{cpu="3"} 1e+06
|
node_cpu_scaling_frequency_min_hertz{cpu="3"} 1e+06
|
||||||
|
# HELP node_cpu_scaling_governor Current enabled CPU frequency governor.
|
||||||
|
# TYPE node_cpu_scaling_governor gauge
|
||||||
|
node_cpu_scaling_governor{cpu="0",governor="performance"} 0
|
||||||
|
node_cpu_scaling_governor{cpu="0",governor="powersave"} 1
|
||||||
|
node_cpu_scaling_governor{cpu="1",governor="performance"} 0
|
||||||
|
node_cpu_scaling_governor{cpu="1",governor="powersave"} 1
|
||||||
|
node_cpu_scaling_governor{cpu="2",governor="performance"} 0
|
||||||
|
node_cpu_scaling_governor{cpu="2",governor="powersave"} 1
|
||||||
|
node_cpu_scaling_governor{cpu="3",governor="performance"} 0
|
||||||
|
node_cpu_scaling_governor{cpu="3",governor="powersave"} 1
|
||||||
# HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.
|
# HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.
|
||||||
# TYPE node_cpu_seconds_total counter
|
# TYPE node_cpu_seconds_total counter
|
||||||
node_cpu_seconds_total{cpu="0",mode="idle"} 10870.69
|
node_cpu_seconds_total{cpu="0",mode="idle"} 10870.69
|
||||||
|
Loading…
Reference in New Issue
Block a user