Fix cpufreq statistics by converting kHz to Hz

This commit is contained in:
Rene Treffer 2017-06-27 11:05:55 +02:00
parent 182810056f
commit bcc3cd92b8
2 changed files with 13 additions and 12 deletions

View file

@ -104,20 +104,21 @@ func (c *cpuCollector) updateCPUfreq(ch chan<- prometheus.Metric) error {
if _, err := os.Stat(filepath.Join(cpu, "cpufreq")); os.IsNotExist(err) {
log.Debugf("CPU %q is missing cpufreq", cpu)
} else {
// cpufreq values are kHz, multiply by 1000 for hz
if value, err = readUintFromFile(filepath.Join(cpu, "cpufreq/scaling_cur_freq")); err != nil {
return err
}
ch <- prometheus.MustNewConstMetric(c.cpuFreq, prometheus.GaugeValue, float64(value), cpuname)
ch <- prometheus.MustNewConstMetric(c.cpuFreq, prometheus.GaugeValue, float64(value)*1000.0, cpuname)
if value, err = readUintFromFile(filepath.Join(cpu, "cpufreq/scaling_min_freq")); err != nil {
return err
}
ch <- prometheus.MustNewConstMetric(c.cpuFreqMin, prometheus.GaugeValue, float64(value), cpuname)
ch <- prometheus.MustNewConstMetric(c.cpuFreqMin, prometheus.GaugeValue, float64(value)*1000.0, cpuname)
if value, err = readUintFromFile(filepath.Join(cpu, "cpufreq/scaling_max_freq")); err != nil {
return err
}
ch <- prometheus.MustNewConstMetric(c.cpuFreqMax, prometheus.GaugeValue, float64(value), cpuname)
ch <- prometheus.MustNewConstMetric(c.cpuFreqMax, prometheus.GaugeValue, float64(value)*1000.0, cpuname)
}
if _, err := os.Stat(filepath.Join(cpu, "thermal_throttle")); os.IsNotExist(err) {

View file

@ -215,19 +215,19 @@ node_cpu_core_throttles_total{cpu="cpu1"} 0
node_cpu_core_throttles_total{cpu="cpu2"} 40
# HELP node_cpu_frequency_hertz Current cpu thread frequency in hertz.
# TYPE node_cpu_frequency_hertz gauge
node_cpu_frequency_hertz{cpu="cpu0"} 1.699981e+06
node_cpu_frequency_hertz{cpu="cpu1"} 1.699981e+06
node_cpu_frequency_hertz{cpu="cpu3"} 8000
node_cpu_frequency_hertz{cpu="cpu0"} 1.699981e+09
node_cpu_frequency_hertz{cpu="cpu1"} 1.699981e+09
node_cpu_frequency_hertz{cpu="cpu3"} 8e+06
# HELP node_cpu_frequency_max_hertz Maximum cpu thread frequency in hertz.
# TYPE node_cpu_frequency_max_hertz gauge
node_cpu_frequency_max_hertz{cpu="cpu0"} 3.7e+06
node_cpu_frequency_max_hertz{cpu="cpu1"} 3.7e+06
node_cpu_frequency_max_hertz{cpu="cpu3"} 4.2e+06
node_cpu_frequency_max_hertz{cpu="cpu0"} 3.7e+09
node_cpu_frequency_max_hertz{cpu="cpu1"} 3.7e+09
node_cpu_frequency_max_hertz{cpu="cpu3"} 4.2e+09
# HELP node_cpu_frequency_min_hertz Minimum cpu thread frequency in hertz.
# TYPE node_cpu_frequency_min_hertz gauge
node_cpu_frequency_min_hertz{cpu="cpu0"} 800000
node_cpu_frequency_min_hertz{cpu="cpu1"} 800000
node_cpu_frequency_min_hertz{cpu="cpu3"} 1000
node_cpu_frequency_min_hertz{cpu="cpu0"} 8e+08
node_cpu_frequency_min_hertz{cpu="cpu1"} 8e+08
node_cpu_frequency_min_hertz{cpu="cpu3"} 1e+06
# HELP node_cpu_package_throttles_total Number of times this cpu package has been throttled.
# TYPE node_cpu_package_throttles_total counter
node_cpu_package_throttles_total{cpu="cpu0"} 30