The column output may differ based on the locale settings.

When run from init the mpstat output is in 24 time and does not have the AM/PM column.
This change handles both possibilities.
This commit is contained in:
Jeffrey Townsend
2016-12-20 21:10:08 +00:00
parent 3a6d0e0d29
commit 6ab5f38d33

View File

@@ -22,8 +22,9 @@ out = subprocess.check_output(['mpstat','1','1'])
for line in out.split('\n'):
if "%idle" in line:
# extract keys from header line, skipping over time and AM/PM
keys = line.split()[2:]
# extract keys from header line, skipping over time and AM/PM if present
tokens = line.split()
keys = tokens[tokens.index('CPU'):]
if "Average" in line:
vals = line.split()[1:]