diff options
author | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:45 +0000 |
---|---|---|
committer | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:45 +0000 |
commit | 7ee3962eaca4214264964ae32c86de457a90e382 (patch) | |
tree | 5a784485351593ac6d74fa9fd9bbd8fe7c9c3fe0 /python.d/cpufreq.chart.py | |
parent | maintscript eludes me (diff) | |
parent | New upstream version 1.8.0+dfsg (diff) | |
download | netdata-7ee3962eaca4214264964ae32c86de457a90e382.tar.xz netdata-7ee3962eaca4214264964ae32c86de457a90e382.zip |
Updated version 1.8.0+dfsg from 'upstream/1.8.0+dfsg'
with Debian dir 412de09d9bca38fe00146ef090f9e53f76493882
Diffstat (limited to 'python.d/cpufreq.chart.py')
-rw-r--r-- | python.d/cpufreq.chart.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/python.d/cpufreq.chart.py b/python.d/cpufreq.chart.py index d5544b7ba..01cc22b02 100644 --- a/python.d/cpufreq.chart.py +++ b/python.d/cpufreq.chart.py @@ -38,20 +38,31 @@ class Service(SimpleService): data = {} if self.accurate_exists: - elapsed = time.time() - self.timetable['last'] - accurate_ok = True for name, paths in self.assignment.items(): last = self.accurate_last[name] - current = 0 + + current = {} + deltas = {} + ticks_since_last = 0 + for line in open(paths['accurate'], 'r'): line = list(map(int, line.split())) - current += (line[0] * line[1]) / 100 - delta = current - last - data[name] = delta + current[line[0]] = line[1] + ticks = line[1] - last.get(line[0], 0) + ticks_since_last += ticks + deltas[line[0]] = line[1] - last.get(line[0], 0) + + avg_freq = 0 + if ticks_since_last != 0: + for frequency, ticks in deltas.items(): + avg_freq += frequency * ticks + avg_freq /= ticks_since_last + + data[name] = avg_freq self.accurate_last[name] = current - if delta == 0 or abs(delta) > 1e7: + if avg_freq == 0 or ticks_since_last == 0: # Delta is either too large or nonexistent, fall back to # less accurate reading. This can happen if we switch # to/from the 'schedutil' governor, which doesn't report @@ -60,9 +71,6 @@ class Service(SimpleService): if accurate_ok: return data - else: - self.alert("accurate method failed, falling back") - self.accurate_exists = False for name, paths in self.assignment.items(): @@ -84,7 +92,7 @@ class Service(SimpleService): if cpu not in self.assignment: self.assignment[cpu] = {} self.assignment[cpu]['accurate'] = path - self.accurate_last[cpu] = 0 + self.accurate_last[cpu] = {} if len(self.assignment) == 0: self.accurate_exists = False |