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
Refactoring(parsers): provide optional way of init for any Parser-bas…
…ed class
  • Loading branch information
strizhechenko committed Dec 18, 2017
commit 557cbcf531914ab3c4be9cd26f6cb2e1d0828379
4 changes: 3 additions & 1 deletion netutils_linux_hardware/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@


class Parser(object):
@staticmethod
def __init__(self, filepath=None):
self.result = self.parse_file_safe(filepath) if filepath else None

def parse(text, **kwargs):
raise NotImplementedError

Expand Down
13 changes: 7 additions & 6 deletions netutils_linux_hardware/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# pylint: disable=C0111, C0103

import os

import yaml
from netutils_linux_hardware.parsers import YAMLLike, CPULayout, DiskInfo, MemInfo, MemInfoDMI

from netutils_linux_hardware.netdev import ReaderNet
from netutils_linux_hardware.parsers import YAMLLike, CPULayout, DiskInfo, MemInfo, MemInfoDMI


class Reader(object):

info = None

def __init__(self, datadir):
Expand All @@ -25,14 +26,14 @@ def gather_info(self):

self.info = {
'cpu': {
'info': YAMLLike().parse_file_safe(self.path('lscpu_info')),
'layout': CPULayout().parse_file_safe(self.path('lscpu_layout')),
'info': YAMLLike(self.path('lscpu_info')).result,
'layout': CPULayout(self.path('lscpu_layout')).result,
},
'net': ReaderNet(self.datadir, self.path).netdevs,
'disk': DiskInfo().parse(self.path('disks_types'), self.path('lsblk_sizes'), self.path('lsblk_models')),
'memory': {
'size': MemInfo().parse_file_safe(self.path('meminfo')),
'devices': MemInfoDMI().parse_file_safe(self.path('dmidecode')),
'size': MemInfo(self.path('meminfo')).result,
'devices': MemInfoDMI(self.path('dmidecode')).result,
},
}
for key in ('CPU MHz', 'BogoMIPS'):
Expand Down