Skip to content

Commit

Permalink
[IO] Fix for newer iostat output format
Browse files Browse the repository at this point in the history
Along with test changes.

Newer iostat versions also expose slightly different fields. I don't
think we need to take care of these differences now.
  • Loading branch information
olivielpeau committed May 15, 2018
1 parent b5302c1 commit bfc3057
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion checks/system/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _cap_io_util_value(self, val):
return val

def _parse_linux2(self, output):
recentStats = output.split('Device:')[2].split('\n')
recentStats = output.split('Device')[2].split('\n')
header = recentStats[0]
headerNames = re.findall(self.header_re, header)
device = None
Expand Down
28 changes: 27 additions & 1 deletion tests/checks/mock/test_sysstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,35 @@ def testDiskLatency(self):
expected = '0.00'
self.assertEqual(results['sda'][key], expected)

# example output from `iostat -d 1 2 -x -k` on
# ubuntu 18.04 x86_64, from deb package
# sysstat@11.6.1-1; main breaking change is
# that header starts with `Device` instead of `Device:`.
newer_iostat_output = """Linux 4.9.60-linuxkit-aufs (f3cf72f6fb4d) 05/09/18 _x86_64_ (2 CPU)
Device r/s w/s rkB/s wkB/s rrqm/s wrqm/s %rrqm %wrqm r_await w_await aqu-sz rareq-sz wareq-sz svctm %util
sda 0.07 0.08 0.64 5.44 0.00 0.23 0.41 72.99 2.42 19.91 0.00 8.92 65.13 0.38 0.01
Device r/s w/s rkB/s wkB/s rrqm/s wrqm/s %rrqm %wrqm r_await w_await aqu-sz rareq-sz wareq-sz svctm %util
sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01
"""

checker = IO(logger)
results = checker._parse_linux2(newer_iostat_output)
self.assertTrue('sda' in results)
for key in ('rrqm/s', 'wrqm/s', 'r/s', 'w/s', 'rkB/s', 'wkB/s',
'r_await', 'w_await', 'svctm', '%util'):
self.assertTrue(key in results['sda'], 'key %r not in results["sda"]' % key)
if key == r'%util':
expected = 0.01
else:
expected = '0.00'
self.assertEqual(results['sda'][key], expected)

# example output from `iostat -d 1 d -x -k` on
# centos 5.8 x86_64, from RPM package
# sysstat@7.0.2; it differs from the the above by
# sysstat@7.0.2; it differs from the first one by
# not having split-out r_await and w_await fields
centos_iostat_output = """Linux 2.6.18-308.el5 (localhost.localdomain) 05/29/2012
Expand Down

0 comments on commit bfc3057

Please sign in to comment.