Crash on startup: KeyError: 'hz_actual_raw' on Raspbian 9.1 #1170

This commit is contained in:
nicolargo 2017-10-27 22:36:52 +02:00
parent 5568278752
commit 9d16fbb74c
2 changed files with 6 additions and 3 deletions

1
NEWS
View File

@ -19,6 +19,7 @@ Bugs corrected:
* glances_plugin.py has a problem with specific docker output #1160
* Key error 'address' in the IP plugin #1176
* NameError: name 'mode' is not defined in case of interrupt shortly after starting the server mode #1175
* Crash on startup: KeyError: 'hz_actual_raw' on Raspbian 9.1 #1170
Backward-incompatible changes:

View File

@ -81,9 +81,11 @@ class Plugin(GlancesPlugin):
cpu_info = cpuinfo.get_cpu_info()
# Check cpu_info (issue #881)
if cpu_info is not None:
self.stats['cpu_name'] = cpu_info['brand']
self.stats['cpu_hz_current'] = cpu_info['hz_actual_raw'][0]
self.stats['cpu_hz'] = cpu_info['hz_advertised_raw'][0]
self.stats['cpu_name'] = cpu_info.get('brand', 'CPU')
if 'hz_actual_raw' in cpu_info:
self.stats['cpu_hz_current'] = cpu_info['hz_actual_raw'][0]
if 'hz_advertised_raw' in cpu_info:
self.stats['cpu_hz'] = cpu_info['hz_advertised_raw'][0]
return self.stats