Skip to content

Commit 4496bde

Browse files
committed
fix huge pages info in report tool
1 parent cc866bf commit 4496bde

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

mamonsu/tools/report/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __getattr__(self, name):
3333

3434
# int (bytes) => str (human readable)
3535
def humansize_bytes(nbytes):
36-
fmt = '{0:6} {1}'
36+
fmt = '{0:>6} {1}'
3737
if not isinstance(nbytes, int):
3838
return 'ERROR'
3939
if nbytes == 0:

mamonsu/tools/report/os_linux.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def printable_info(self):
5757
out += key_val_h1('Cached', humansize_bytes(self.meminfo['_CACHED']))
5858
out += key_val_h1('Buffers', humansize_bytes(self.meminfo['_BUFFERS']))
5959
out += key_val_h1('Dirty', humansize_bytes(self.meminfo['_DIRTY']))
60-
out += key_val_h1('HugePages', humansize_bytes(self.meminfo['_HUGEPAGES']))
60+
out += key_val_h1('HP Total', humansize_bytes(self.meminfo['_HUGEPAGES_SIZE']))
61+
out += key_val_h1('HP Free', humansize_bytes(self.meminfo['_HUGEPAGES_FREE']))
6162
out += key_val_h1('SwapTotal', humansize_bytes(self.meminfo['_SWAPTOTAL']))
6263
out += key_val_h1('SwapUsed', humansize_bytes(self.meminfo['_SWAPUSED']))
6364
out += header_h1('TOP (by memory)')

mamonsu/tools/sysinfo/linux.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ def _meminfo(self):
319319
'_RAW', '_TOTAL', '_COMMITED', '_COMMITEDLIMIT',
320320
'_FREE', '_SWAPUSED', '_SLAB'
321321
'_SWAPTOTAL', '_CACHED', '_DIRTY', '_BUFFERS',
322-
'_HUGEPAGES', '_SHMEM', '_PAGETABLES']:
322+
'_HUGEPAGES_SIZE', '_HUGEPAGES_FREE',
323+
'_SHMEM', '_PAGETABLES']:
323324
result[key] = NA
324325

325326
if self.is_empty(data):
@@ -328,6 +329,8 @@ def _meminfo(self):
328329
result['_RAW'] = data
329330
for info in re.findall(r'^(\S+)\:\s+(\d+)\s+kB$', data, re.M):
330331
result[info[0]] = int(info[1]) * 1024
332+
for info in re.findall(r'^(\S+)\:\s+(\d+)$', data, re.M):
333+
result[info[0]] = int(info[1])
331334
if 'MemTotal' in result:
332335
result['_TOTAL'] = result['MemTotal']
333336
if 'CommitLimit' in result:
@@ -340,8 +343,11 @@ def _meminfo(self):
340343
result['_SWAPTOTAL'] = result['SwapTotal']
341344
if 'SwapTotal' in result and 'SwapFree' in result:
342345
result['_SWAPUSED'] = result['SwapTotal'] - result['SwapFree']
343-
if 'HugePages_Total' in result:
344-
result['_HUGEPAGES'] = result['HugePages_Total']
346+
if 'Hugepagesize' in result:
347+
if 'HugePages_Total' in result:
348+
result['_HUGEPAGES_SIZE'] = result['Hugepagesize'] * result['HugePages_Total']
349+
if 'HugePages_Free' in result:
350+
result['_HUGEPAGES_FREE'] = result['Hugepagesize'] * result['HugePages_Free']
345351
if 'Cached' in result:
346352
result['_CACHED'] = result['Cached']
347353
if 'Dirty' in result:

0 commit comments

Comments
 (0)