aboutsummaryrefslogtreecommitdiff
path: root/collector/cpu_linux.go
diff options
context:
space:
mode:
authorRene Treffer <rene.treffer@soundcloud.com>2017-06-27 11:05:55 +0200
committerRene Treffer <rene.treffer@soundcloud.com>2017-06-27 11:05:55 +0200
commitbcc3cd92b8dd5b1870585dfa75b5ee2fd6a67268 (patch)
treee13afd0316a190b210f6d5d8985f3b2b60c41fdc /collector/cpu_linux.go
parent182810056fd3db63441975db385fcd387e1d1ddd (diff)
downloadprometheus_node_collector-bcc3cd92b8dd5b1870585dfa75b5ee2fd6a67268.tar.bz2
prometheus_node_collector-bcc3cd92b8dd5b1870585dfa75b5ee2fd6a67268.tar.xz
prometheus_node_collector-bcc3cd92b8dd5b1870585dfa75b5ee2fd6a67268.zip
Fix cpufreq statistics by converting kHz to Hz
Diffstat (limited to 'collector/cpu_linux.go')
-rw-r--r--collector/cpu_linux.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go
index 39db3bb..01255d7 100644
--- a/collector/cpu_linux.go
+++ b/collector/cpu_linux.go
@@ -104,20 +104,21 @@ func (c *cpuCollector) updateCPUfreq(ch chan<- prometheus.Metric) error {
104 if _, err := os.Stat(filepath.Join(cpu, "cpufreq")); os.IsNotExist(err) { 104 if _, err := os.Stat(filepath.Join(cpu, "cpufreq")); os.IsNotExist(err) {
105 log.Debugf("CPU %q is missing cpufreq", cpu) 105 log.Debugf("CPU %q is missing cpufreq", cpu)
106 } else { 106 } else {
107 // cpufreq values are kHz, multiply by 1000 for hz
107 if value, err = readUintFromFile(filepath.Join(cpu, "cpufreq/scaling_cur_freq")); err != nil { 108 if value, err = readUintFromFile(filepath.Join(cpu, "cpufreq/scaling_cur_freq")); err != nil {
108 return err 109 return err
109 } 110 }
110 ch <- prometheus.MustNewConstMetric(c.cpuFreq, prometheus.GaugeValue, float64(value), cpuname) 111 ch <- prometheus.MustNewConstMetric(c.cpuFreq, prometheus.GaugeValue, float64(value)*1000.0, cpuname)
111 112
112 if value, err = readUintFromFile(filepath.Join(cpu, "cpufreq/scaling_min_freq")); err != nil { 113 if value, err = readUintFromFile(filepath.Join(cpu, "cpufreq/scaling_min_freq")); err != nil {
113 return err 114 return err
114 } 115 }
115 ch <- prometheus.MustNewConstMetric(c.cpuFreqMin, prometheus.GaugeValue, float64(value), cpuname) 116 ch <- prometheus.MustNewConstMetric(c.cpuFreqMin, prometheus.GaugeValue, float64(value)*1000.0, cpuname)
116 117
117 if value, err = readUintFromFile(filepath.Join(cpu, "cpufreq/scaling_max_freq")); err != nil { 118 if value, err = readUintFromFile(filepath.Join(cpu, "cpufreq/scaling_max_freq")); err != nil {
118 return err 119 return err
119 } 120 }
120 ch <- prometheus.MustNewConstMetric(c.cpuFreqMax, prometheus.GaugeValue, float64(value), cpuname) 121 ch <- prometheus.MustNewConstMetric(c.cpuFreqMax, prometheus.GaugeValue, float64(value)*1000.0, cpuname)
121 } 122 }
122 123
123 if _, err := os.Stat(filepath.Join(cpu, "thermal_throttle")); os.IsNotExist(err) { 124 if _, err := os.Stat(filepath.Join(cpu, "thermal_throttle")); os.IsNotExist(err) {