Skip to content

Conversation

waaeer
Copy link

@waaeer waaeer commented Nov 15, 2016

числа, большие 2Gb, в 32-битных системах long, а не int
/proc/meminfo HugePages в них имеет значение 'N/A'
None на всякий случай

@vadv
Copy link
Contributor

vadv commented Nov 15, 2016

проблема есть, но она решается другим путем, ошибочно взята HugePages_Total которая хранит кол-во страниц в pool, размер страницы храниться в Hugepagesize, см здесь

diff --git a/mamonsu/tools/report/format.py b/mamonsu/tools/report/format.py
index b595c64..bdf8d50 100644
--- a/mamonsu/tools/report/format.py
+++ b/mamonsu/tools/report/format.py
@@ -33,7 +33,7 @@ TermColor = color()

 # int (bytes) => str (human readable)
 def humansize_bytes(nbytes):
-    fmt = '{0:6} {1}'
+    fmt = '{0:>6} {1}'
     if not isinstance(nbytes, int):
         return 'ERROR'
     if nbytes == 0:
diff --git a/mamonsu/tools/report/os_linux.py b/mamonsu/tools/report/os_linux.py
index f9fca9d..cf3eeda 100644
--- a/mamonsu/tools/report/os_linux.py
+++ b/mamonsu/tools/report/os_linux.py
@@ -57,7 +57,8 @@ class SystemInfo(SysInfoLinux):
         out += key_val_h1('Cached', humansize_bytes(self.meminfo['_CACHED']))
         out += key_val_h1('Buffers', humansize_bytes(self.meminfo['_BUFFERS']))
         out += key_val_h1('Dirty', humansize_bytes(self.meminfo['_DIRTY']))
-        out += key_val_h1('HugePages', humansize_bytes(self.meminfo['_HUGEPAGES']))
+        out += key_val_h1('HP Total', humansize_bytes(self.meminfo['_HUGEPAGES_SIZE']))
+        out += key_val_h1('HP Free', humansize_bytes(self.meminfo['_HUGEPAGES_FREE']))
         out += key_val_h1('SwapTotal', humansize_bytes(self.meminfo['_SWAPTOTAL']))
         out += key_val_h1('SwapUsed', humansize_bytes(self.meminfo['_SWAPUSED']))
         out += header_h1('TOP (by memory)')
diff --git a/mamonsu/tools/sysinfo/linux.py b/mamonsu/tools/sysinfo/linux.py
index 478eb72..9053697 100644
--- a/mamonsu/tools/sysinfo/linux.py
+++ b/mamonsu/tools/sysinfo/linux.py
@@ -319,7 +319,8 @@ class SysInfoLinux(object):
                 '_RAW', '_TOTAL', '_COMMITED', '_COMMITEDLIMIT',
                 '_FREE', '_SWAPUSED', '_SLAB'
                 '_SWAPTOTAL', '_CACHED', '_DIRTY', '_BUFFERS',
-                '_HUGEPAGES', '_SHMEM', '_PAGETABLES']:
+                '_HUGEPAGES_SIZE', '_HUGEPAGES_FREE',
+                '_SHMEM', '_PAGETABLES']:
             result[key] = NA

         if self.is_empty(data):
@@ -328,6 +329,8 @@ class SysInfoLinux(object):
         result['_RAW'] = data
         for info in re.findall(r'^(\S+)\:\s+(\d+)\s+kB$', data, re.M):
             result[info[0]] = int(info[1]) * 1024
+        for info in re.findall(r'^(\S+)\:\s+(\d+)$', data, re.M):
+            result[info[0]] = int(info[1])
         if 'MemTotal' in result:
             result['_TOTAL'] = result['MemTotal']
         if 'CommitLimit' in result:
@@ -340,8 +343,11 @@ class SysInfoLinux(object):
             result['_SWAPTOTAL'] = result['SwapTotal']
         if 'SwapTotal' in result and 'SwapFree' in result:
             result['_SWAPUSED'] = result['SwapTotal'] - result['SwapFree']
-        if 'HugePages_Total' in result:
-            result['_HUGEPAGES'] = result['HugePages_Total']
+        if 'Hugepagesize' in result:
+            if 'HugePages_Total' in result:
+                result['_HUGEPAGES_SIZE'] = result['Hugepagesize'] * result['HugePages_Total']
+            if 'HugePages_Free' in result:
+                result['_HUGEPAGES_FREE'] = result['Hugepagesize'] * result['HugePages_Free']
         if 'Cached' in result:
             result['_CACHED'] = result['Cached']
         if 'Dirty' in result:

@vadv vadv closed this Nov 15, 2016
@vadv vadv reopened this Nov 15, 2016
vadv added a commit that referenced this pull request Nov 15, 2016
@vadv
Copy link
Contributor

vadv commented Nov 15, 2016

спасибо

@vadv vadv closed this Nov 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants