Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding dmidecode support in server-info for better view of memory subsystem #178

Merged
merged 18 commits into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added(server-info): memory device's type, speed and size rating in -r…
…ate.
  • Loading branch information
strizhechenko committed Dec 17, 2017
commit df8928a978c7dce43052243998c5a49c7e6cfc50
25 changes: 23 additions & 2 deletions netutils_linux_hardware/assessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,33 @@ def assess_cpu(self):
'Vendor ID': Grade.str(cpuinfo.get('Vendor ID'), good=['GenuineIntel']),
}

def assess_memory_device(self, device):
return {
'size': Grade.int(device.get('size', 0), 512, 8196),
'type': Grade.dict(device.get('type', 'RAM'), {
'DDR1': 2,
'DDR2': 3,
'DDR3': 6,
'DDR4': 10,
}),
'speed': Grade.int(device.get('speed', 0), 200, 4000),
}

def assess_memory_devices(self, devices):
return dict((handle, self.assess_memory_device(device)) for handle, device in devices.items())

def assess_memory_size(self, size):
return {
'MemTotal': Grade.int(size.get('MemTotal'), 2 * (1024 ** 2), 16 * (1024 ** 2)),
'SwapTotal': Grade.int(size.get('SwapTotal'), 512 * 1024, 4 * (1024 ** 2)),
}

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)),
'devices': self.assess_memory_devices(meminfo.get('devices')),
'size': self.assess_memory_size(meminfo.get('size')),
}

def assess_system(self):
Expand Down
3 changes: 3 additions & 0 deletions netutils_linux_hardware/grade.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ def str(value, good=None, bad=None):
@staticmethod
def fact(value, mode=False):
return 10 if (value is None) != mode else 1

def dict(value, _dict):
return _dict.get(value, 1)