def testFreebsdCapIostat(self, mock_subprocess): global logger checker = IO(logger) results = checker.check({}) expected = 0 for res in results: self.assertEqual(results[res]['%util'], expected)
def testSunos5CapIostat(self, mock_subprocess): global logger checker = IO(logger) results = checker.check({}) for res in results: if res == 'sd1': expected = 10 else: expected = 0 self.assertEqual(results[res]['%util'], expected)
def testDiskLatency(self): # example output from `iostat -d 1 2 -x -k` on # debian testing x86_64, from Debian package # [email protected] debian_iostat_output = """Linux 3.2.0-2-amd64 (fireflyvm) 05/29/2012 _x86_64_ (2 CPU) Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.44 2.58 5.79 2.84 105.53 639.03 172.57 0.17 19.38 1.82 55.26 0.66 0.57 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await 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 """ global logger checker = IO(logger) results = checker._parse_linux2(debian_iostat_output) self.assertTrue('sda' in results) for key in ('rrqm/s', 'wrqm/s', 'r/s', 'w/s', 'rkB/s', 'wkB/s', 'avgrq-sz', 'avgqu-sz', 'await', 'r_await', 'w_await', 'svctm', '%util'): self.assertTrue(key in results['sda'], 'key %r not in results["sda"]' % key) self.assertEqual(results['sda'][key], '0.00') # example output from `iostat -d 1 d -x -k` on # centos 5.8 x86_64, from RPM package # [email protected]; it differs from the above 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 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util sda 9.44 7.56 16.76 4.40 322.05 47.75 34.96 0.01 0.59 0.35 0.74 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await 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 """ checker = IO(logger) results = checker._parse_linux2(centos_iostat_output) self.assertTrue('sda' in results) for key in ('rrqm/s', 'wrqm/s', 'r/s', 'w/s', 'rkB/s', 'wkB/s', 'avgrq-sz', 'avgqu-sz', 'await', 'svctm', '%util'): self.assertTrue(key in results['sda'], 'key %r not in results["sda"]' % key) self.assertEqual(results['sda'][key], '0.00') # iostat -o -d -c 2 -w 1 # OS X 10.8.3 (internal SSD + USB flash attached) darwin_iostat_output = """ disk0 disk1 KB/t tps MB/s KB/t tps MB/s 21.11 23 0.47 20.01 0 0.00 6.67 3 0.02 0.00 0 0.00 """ checker = IO(logger) results = checker._parse_darwin(darwin_iostat_output) self.assertTrue("disk0" in results.keys()) self.assertTrue("disk1" in results.keys()) self.assertEqual(results["disk0"], { 'system.io.bytes_per_s': float(0.02 * 10**6), }) self.assertEqual(results["disk1"], { 'system.io.bytes_per_s': float(0), })
def testDiskLatency(self): # example output from `iostat -d 1 2 -x -k` on # debian testing x86_64, from Debian package # [email protected] debian_iostat_output = """Linux 3.2.0-2-amd64 (fireflyvm) 05/29/2012 _x86_64_ (2 CPU) Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.44 2.58 5.79 2.84 105.53 639.03 172.57 0.17 19.38 1.82 55.26 0.66 0.57 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await 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 """ global logger checker = IO(logger) results = checker._parse_linux2(debian_iostat_output) self.assertTrue('sda' in results) for key in ('rrqm/s', 'wrqm/s', 'r/s', 'w/s', 'rkB/s', 'wkB/s', 'avgrq-sz', 'avgqu-sz', 'await', 'r_await', 'w_await', 'svctm', '%util'): self.assertTrue(key in results['sda'], 'key %r not in results["sda"]' % key) self.assertEqual(results['sda'][key], '0.00') # example output from `iostat -d 1 d -x -k` on # centos 5.8 x86_64, from RPM package # [email protected]; it differs from the above 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 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util sda 9.44 7.56 16.76 4.40 322.05 47.75 34.96 0.01 0.59 0.35 0.74 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await 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 """ checker = IO(logger) results = checker._parse_linux2(centos_iostat_output) self.assertTrue('sda' in results) for key in ('rrqm/s', 'wrqm/s', 'r/s', 'w/s', 'rkB/s', 'wkB/s', 'avgrq-sz', 'avgqu-sz', 'await', 'svctm', '%util'): self.assertTrue(key in results['sda'], 'key %r not in results["sda"]' % key) self.assertEqual(results['sda'][key], '0.00') # iostat -o -d -c 2 -w 1 # OS X 10.8.3 (internal SSD + USB flash attached) darwin_iostat_output = """ disk0 disk1 KB/t tps MB/s KB/t tps MB/s 21.11 23 0.47 20.01 0 0.00 6.67 3 0.02 0.00 0 0.00 """ checker = IO(logger) results = checker._parse_darwin(darwin_iostat_output) self.assertTrue("disk0" in results.keys()) self.assertTrue("disk1" in results.keys()) self.assertEqual( results["disk0"], {'system.io.bytes_per_s': float(0.02 * 2**20),} ) self.assertEqual( results["disk1"], {'system.io.bytes_per_s': float(0),} )
def testDiskLatency(self): # example output from `iostat -d 1 2 -x -k` on # debian testing x86_64, from Debian package # [email protected] debian_iostat_output = """Linux 3.2.0-2-amd64 (fireflyvm) 05/29/2012 _x86_64_ (2 CPU) Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.44 2.58 5.79 2.84 105.53 639.03 172.57 0.17 19.38 1.82 55.26 0.66 0.57 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await 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.01 """ global logger checker = IO(logger) results = checker._parse_linux2(debian_iostat_output) self.assertTrue('sda' in results) for key in ('rrqm/s', 'wrqm/s', 'r/s', 'w/s', 'rkB/s', 'wkB/s', 'avgrq-sz', 'avgqu-sz', 'await', '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 2 -x -k` on # ubuntu 18.04 x86_64, from deb package # [email protected]; 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 # [email protected]; 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 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util sda 9.44 7.56 16.76 4.40 322.05 47.75 34.96 0.01 0.59 0.35 0.74 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util sda 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(centos_iostat_output) self.assertTrue('sda' in results) for key in ('rrqm/s', 'wrqm/s', 'r/s', 'w/s', 'rkB/s', 'wkB/s', 'avgrq-sz', 'avgqu-sz', '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) # iostat -o -d -c 2 -w 1 # OS X 10.8.3 (internal SSD + USB flash attached) darwin_iostat_output = """ disk0 disk1 KB/t tps MB/s KB/t tps MB/s 21.11 23 0.47 20.01 0 0.00 6.67 3 0.02 0.00 0 0.00 """ checker = IO(logger) results = checker._parse_darwin(darwin_iostat_output) self.assertTrue("disk0" in results.keys()) self.assertTrue("disk1" in results.keys()) self.assertEqual(results["disk0"], { 'system.io.bytes_per_s': float(0.02 * 2**20), }) self.assertEqual(results["disk1"], { 'system.io.bytes_per_s': float(0), }) linux_output_dashes = """Linux 3.13.0-32-generic (ubuntu-1204) 05/20/2016 _x86_64_ (2 CPU) Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 5.77 8.20 7.79 30.08 320.67 219.91 28.55 0.05 1.32 1.53 1.27 0.32 1.20 dm-0 0.00 0.00 11.71 37.97 313.61 219.90 21.48 0.11 2.16 2.13 2.17 0.24 1.20 dm-1 0.00 0.00 0.08 0.00 0.32 0.00 8.00 0.00 1.68 1.68 0.00 1.07 0.01 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.00 0.00 0.00 1.00 0.00 4.00 8.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-0 0.00 0.00 0.00 1.00 0.00 4.00 8.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-1 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 """ results = checker._parse_linux2(linux_output_dashes) self.assertTrue(sorted(results.keys()) == ['dm-0', 'dm-1', 'sda'])
def testLinuxCapIostat(self): # example output from `iostat -d 1 2 -x -k` on # debian testing x86_64, from Debian package # [email protected] debian_iostat_output = """Linux 3.2.0-2-amd64 (fireflyvm) 05/29/2012 _x86_64_ (2 CPU) Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.44 2.58 5.79 2.84 105.53 639.03 172.57 0.17 19.38 1.82 55.26 0.66 0.57 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await 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 100.01 """ global logger checker = IO(logger) results = checker._parse_linux2(debian_iostat_output) self.assertTrue('sda' in results) # Ensure that value is capped and return to 0 if it surpasses 100 expected = 0 self.assertEqual(results['sda']['%util'], expected) # example output from `iostat -d 1 2 -x -k` on # ubuntu 18.04 x86_64, from deb package # [email protected]; 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 99.99 """ checker = IO(logger) results = checker._parse_linux2(newer_iostat_output) self.assertTrue('sda' in results) expected = 99.99 self.assertEqual(results['sda']['%util'], expected) # example output from `iostat -d 1 d -x -k` on # centos 5.8 x86_64, from RPM package # [email protected]; 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 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util sda 9.44 7.56 16.76 4.40 322.05 47.75 34.96 0.01 0.59 0.35 0.74 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 102.01 """ checker = IO(logger) results = checker._parse_linux2(centos_iostat_output) self.assertTrue('sda' in results) # %util value is over 100, and value is set to 0 expected = 0 self.assertEqual(results['sda']['%util'], expected)
def testDiskLatency(self): # example output from `iostat -d 1 2 -x -k` on # debian testing x86_64, from Debian package # [email protected] debian_iostat_output = """Linux 3.2.0-2-amd64 (fireflyvm) 05/29/2012 _x86_64_ (2 CPU) Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.44 2.58 5.79 2.84 105.53 639.03 172.57 0.17 19.38 1.82 55.26 0.66 0.57 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await 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.01 """ global logger checker = IO(logger) results = checker._parse_linux2(debian_iostat_output) self.assertTrue('sda' in results) for key in ('rrqm/s', 'wrqm/s', 'r/s', 'w/s', 'rkB/s', 'wkB/s', 'avgrq-sz', 'avgqu-sz', 'await', '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 2 -x -k` on # ubuntu 18.04 x86_64, from deb package # [email protected]; 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 # [email protected]; 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 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util sda 9.44 7.56 16.76 4.40 322.05 47.75 34.96 0.01 0.59 0.35 0.74 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util sda 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(centos_iostat_output) self.assertTrue('sda' in results) for key in ('rrqm/s', 'wrqm/s', 'r/s', 'w/s', 'rkB/s', 'wkB/s', 'avgrq-sz', 'avgqu-sz', '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) # iostat -o -d -c 2 -w 1 # OS X 10.8.3 (internal SSD + USB flash attached) darwin_iostat_output = """ disk0 disk1 KB/t tps MB/s KB/t tps MB/s 21.11 23 0.47 20.01 0 0.00 6.67 3 0.02 0.00 0 0.00 """ checker = IO(logger) results = checker._parse_darwin(darwin_iostat_output) self.assertTrue("disk0" in results.keys()) self.assertTrue("disk1" in results.keys()) self.assertEqual( results["disk0"], {'system.io.bytes_per_s': float(0.02 * 2**20),} ) self.assertEqual( results["disk1"], {'system.io.bytes_per_s': float(0),} ) linux_output_dashes = """Linux 3.13.0-32-generic (ubuntu-1204) 05/20/2016 _x86_64_ (2 CPU) Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 5.77 8.20 7.79 30.08 320.67 219.91 28.55 0.05 1.32 1.53 1.27 0.32 1.20 dm-0 0.00 0.00 11.71 37.97 313.61 219.90 21.48 0.11 2.16 2.13 2.17 0.24 1.20 dm-1 0.00 0.00 0.08 0.00 0.32 0.00 8.00 0.00 1.68 1.68 0.00 1.07 0.01 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.00 0.00 0.00 1.00 0.00 4.00 8.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-0 0.00 0.00 0.00 1.00 0.00 4.00 8.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-1 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 """ results = checker._parse_linux2(linux_output_dashes) self.assertTrue(sorted(results.keys()) == ['dm-0', 'dm-1', 'sda'])