def __netdev(self, netdev): netdevinfo = extract(self.data, ['net', netdev]) queues = sum( len(extract(netdevinfo, ['queues', x])) for x in ('rx', 'rxtx')) buffers = netdevinfo.get('buffers') or {} return self.folding.fold( { 'queues': Grade.int(queues, 2, 8), 'driver': { 'mlx5_core': 10, # 7500 mbit/s 'mlx4_en': 9, # 6500 mbit/s 'i40e': 8, # 6000 mbit/s 'ixgbe': 7, # 4000 mbit/s 'igb': 6, # 400 mbit/s 'bnx2x': 4, # 100 mbit/s 'e1000e': 3, # 80 mbit/s 'e1000': 3, # 50 mbit/s 'r8169': 1, 'ATL1E': 1, '8139too': 1, # real trash, you should never use it }.get(netdevinfo.get('driver').get('driver'), 2), 'buffers': self.folding.fold( { 'cur': Grade.int(buffers.get('cur'), 256, 4096), 'max': Grade.int(buffers.get('max'), 256, 4096), }, self.folding.DEVICE) }, self.folding.DEVICE)
def assess_memory_size(self, size): return self.fold( { 'MemTotal': Grade.int(size.get('MemTotal'), 2 * (1024**2), 16 * (1024**2)), 'SwapTotal': Grade.int(size.get('SwapTotal'), 512 * 1024, 4 * (1024**2)), }, FOLDING_DEVICE)
def __size(self, size): return self.folding.fold( { 'MemTotal': Grade.int(size.get('MemTotal'), 2 * (1024**2), 16 * (1024**2)), 'SwapTotal': Grade.int(size.get('SwapTotal'), 512 * 1024, 4 * (1024**2)), }, self.folding.DEVICE) if size else 1
def assess_memory(self): meminfo = self.data.get('memory') if meminfo: return { 'MemTotal': Grade.int(meminfo.get('MemTotal'), 2 * (1024**2), 16 * (1024**2)), 'SwapTotal': Grade.int(meminfo.get('SwapTotal'), 512 * 1024, 4 * (1024**2)), }
def test_grade_int(self): self.longMessage = True self.assertEqual(Grade.int(2000, 2000, 4000), 1) self.assertEqual(Grade.int(1000, 2000, 4000), 1) self.assertEqual(Grade.int(-1000, 2000, 4000), 1) self.assertEqual(Grade.int(2200, 2000, 4000), 2) self.assertEqual(Grade.int(3000, 2000, 4000), 6) self.assertEqual(Grade.int(3999, 2000, 4000), 10) self.assertEqual(Grade.int(4000, 2000, 4000), 10) self.assertEqual(Grade.int(5000, 2000, 4000), 10) self.assertEqual(Grade.int(5000, 2000, 4000, 15), 15) self.assertEqual(Grade.int(4000, 2000, 4000, 15), 15)
def assess_memory_device(self, device): return self.fold( { 'size': Grade.int(device.get('size', 0), 512, 8196), 'type': Grade.known_values(device.get('type', 'RAM'), { 'DDR1': 2, 'DDR2': 3, 'DDR3': 6, 'DDR4': 10, }), 'speed': Grade.int(device.get('speed', 0), 200, 4000), }, FOLDING_DEVICE)
def assess_disk(self, disk): diskinfo = extract(self.data, ['disk', disk]) return { 'type': Grade.str(diskinfo.get('type'), ['SDD'], ['HDD']), # 50Gb - good, 1Tb - good enough 'size': Grade.int(diskinfo.get('size'), 50 * (1000**3), 1000**4), }
def rate_disk(self, disk): diskinfo = extract(self.data, ['disk', disk]) return self.folding.fold( { 'type': Grade.str(diskinfo.get('type'), ['SDD'], ['HDD']), # 50Gb - good, 1Tb - good enough 'size': Grade.int(diskinfo.get('size'), 50 * (1000**3), 1000**4), }, self.folding.DEVICE)
def assess_cpu(self): cpuinfo = extract(self.data, ['cpu', 'info']) if cpuinfo: return { 'CPU MHz': Grade.int(cpuinfo.get('CPU MHz'), 2000, 4000), 'BogoMIPS': Grade.int(cpuinfo.get('BogoMIPS'), 4000, 8000), 'CPU(s)': Grade.int(cpuinfo.get('CPU(s)'), 2, 32), 'Core(s) per socket': Grade.int(cpuinfo.get('Core(s) per socket'), 1, 2), 'Socket(s)': Grade.int(cpuinfo.get('Socket(s)'), 1, 2), 'Thread(s) per core': Grade.int(cpuinfo.get('Thread(s) per core'), 2, 1), 'L3 cache': Grade.int(cpuinfo.get('L3 cache'), 1000, 30000), 'Vendor ID': Grade.str(cpuinfo.get('Vendor ID'), good=['GenuineIntel']), }
def rate(self): cpuinfo = extract(self.data, ['cpu', 'info']) if cpuinfo: # None if no cpuinfo key return self.folding.fold( { 'CPU MHz': Grade.int(cpuinfo.get('CPU MHz'), 2000, 4000), 'BogoMIPS': Grade.int(cpuinfo.get('BogoMIPS'), 4000, 8000), 'CPU(s)': Grade.int(cpuinfo.get('CPU(s)'), 2, 32), 'Core(s) per socket': Grade.int(cpuinfo.get('Core(s) per socket'), 1, 2), 'Socket(s)': Grade.int(cpuinfo.get('Socket(s)'), 1, 2), 'Thread(s) per core': Grade.int(cpuinfo.get('Thread(s) per core'), 2, 1), 'L3 cache': Grade.int(cpuinfo.get('L3 cache'), 1000, 30000), 'Vendor ID': Grade.str(cpuinfo.get('Vendor ID'), good=['GenuineIntel']), }, self.folding.SUBSYSTEM)