mirror of
https://github.com/prometheus/node_exporter.git
synced 2025-02-21 03:25:57 -08:00
only publish metrics for isolated cpus
Signed-off-by: david <davidventura27@gmail.com>
This commit is contained in:
parent
698670bb6e
commit
9ea9a5f029
|
@ -299,34 +299,11 @@ func (c *cpuCollector) updateThermalThrottle(ch chan<- prometheus.Metric) error
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func contains(s []uint16, e uint16) bool {
|
|
||||||
for _, a := range s {
|
|
||||||
if a == e {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// updateStat reads /proc/stat through procfs and exports CPU-related metrics.
|
// updateStat reads /proc/stat through procfs and exports CPU-related metrics.
|
||||||
func (c *cpuCollector) updateIsolated(ch chan<- prometheus.Metric) error {
|
func (c *cpuCollector) updateIsolated(ch chan<- prometheus.Metric) error {
|
||||||
stats, err := c.fs.Stat()
|
for _, cpu := range c.isolatedCpus {
|
||||||
if err != nil {
|
cpuNum := strconv.Itoa(int(cpu))
|
||||||
return err
|
ch <- prometheus.MustNewConstMetric(c.cpuIsolated, prometheus.GaugeValue, 1.0, cpuNum)
|
||||||
}
|
|
||||||
|
|
||||||
c.updateCPUStats(stats.CPU)
|
|
||||||
|
|
||||||
// Acquire a lock to read the stats.
|
|
||||||
c.cpuStatsMutex.Lock()
|
|
||||||
defer c.cpuStatsMutex.Unlock()
|
|
||||||
for cpuID, _ := range c.cpuStats {
|
|
||||||
cpuNum := strconv.Itoa(cpuID)
|
|
||||||
isIsolated := 0.0
|
|
||||||
if contains(c.isolatedCpus, uint16(cpuID)) {
|
|
||||||
isIsolated = 1.0
|
|
||||||
}
|
|
||||||
ch <- prometheus.MustNewConstMetric(c.cpuIsolated, prometheus.GaugeValue, isIsolated, cpuNum)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -321,14 +321,11 @@ node_cpu_info{cachesize="8192 KB",core="3",cpu="3",family="6",microcode="0xb4",m
|
||||||
node_cpu_info{cachesize="8192 KB",core="3",cpu="7",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
node_cpu_info{cachesize="8192 KB",core="3",cpu="7",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
||||||
# HELP node_cpu_isolated Whether each core is isolated, information from /sys/devices/system/cpu/isolated.
|
# HELP node_cpu_isolated Whether each core is isolated, information from /sys/devices/system/cpu/isolated.
|
||||||
# TYPE node_cpu_isolated gauge
|
# TYPE node_cpu_isolated gauge
|
||||||
node_cpu_isolated{cpu="0"} 0
|
|
||||||
node_cpu_isolated{cpu="1"} 1
|
node_cpu_isolated{cpu="1"} 1
|
||||||
node_cpu_isolated{cpu="2"} 0
|
|
||||||
node_cpu_isolated{cpu="3"} 1
|
node_cpu_isolated{cpu="3"} 1
|
||||||
node_cpu_isolated{cpu="4"} 1
|
node_cpu_isolated{cpu="4"} 1
|
||||||
node_cpu_isolated{cpu="5"} 1
|
node_cpu_isolated{cpu="5"} 1
|
||||||
node_cpu_isolated{cpu="6"} 0
|
node_cpu_isolated{cpu="9"} 1
|
||||||
node_cpu_isolated{cpu="7"} 0
|
|
||||||
# HELP node_cpu_package_throttles_total Number of times this CPU package has been throttled.
|
# HELP node_cpu_package_throttles_total Number of times this CPU package has been throttled.
|
||||||
# TYPE node_cpu_package_throttles_total counter
|
# TYPE node_cpu_package_throttles_total counter
|
||||||
node_cpu_package_throttles_total{package="0"} 30
|
node_cpu_package_throttles_total{package="0"} 30
|
||||||
|
|
Loading…
Reference in a new issue