This commit is contained in:
Carsten Grohmann 2017-12-13 07:31:39 +01:00
parent 91b32d63d7
commit 82249e7440

View File

@ -7,12 +7,13 @@
import re import re
DEBUG=False DEBUG = False
"""Show additional information during the development cycle""" """Show additional information during the development cycle"""
VERSION="0.1.0" VERSION = "0.1.0"
"""Version number""" """Version number"""
def hide_element(element_id): def hide_element(element_id):
"""Hide the given HTML element""" """Hide the given HTML element"""
document.getElementById(element_id).style.display = 'none' document.getElementById(element_id).style.display = 'none'
@ -341,22 +342,14 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
REC_MEMINFO_2 = re.compile( REC_MEMINFO_2 = re.compile(
r'^ slab_reclaimable:(?P<slab_reclaimable_pages>\d+) slab_unreclaimable:(?P<slab_unreclaimable_pages>\d+)' r'^ slab_reclaimable:(?P<slab_reclaimable_pages>\d+) slab_unreclaimable:(?P<slab_unreclaimable_pages>\d+)'
# next line break
r'(?:\n)' r'(?:\n)'
r'^ mapped:(?P<mapped_pages>\d+) shmem:(?P<shmem_pages>\d+) pagetables:(?P<pagetables_pages>\d+) ' r'^ mapped:(?P<mapped_pages>\d+) shmem:(?P<shmem_pages>\d+) pagetables:(?P<pagetables_pages>\d+) '
r'bounce:(?P<bounce_pages>\d+)' r'bounce:(?P<bounce_pages>\d+)'
# next line break
r'(?:\n)' r'(?:\n)'
r'^ free:(?P<free_pages>\d+) free_pcp:(?P<free_pcp_pages>\d+) free_cma:(?P<free_cma_pages>\d+)',
r'^ free:(?P<free_pages>\d+) free_pcp:(?P<free_pcp_pages>\d+) free_cma:(?P<free_cma_pages>\d+)' re.MULTILINE
, re.MULTILINE
) )
REC_MEM_NODEINFO = re.compile(r'(^Node \d+ (DMA|Normal|hugepages).*(:?\n))+', re.MULTILINE) REC_MEM_NODEINFO = re.compile(r'(^Node \d+ (DMA|Normal|hugepages).*(:?\n))+', re.MULTILINE)
mem_modinfo_entries = ("active_anon_pages", "inactive_anon_pages", "isolated_anon_pages", mem_modinfo_entries = ("active_anon_pages", "inactive_anon_pages", "isolated_anon_pages",
@ -397,8 +390,7 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
r'score (?P<killed_proc_score>\d+) or sacrifice child' r'score (?P<killed_proc_score>\d+) or sacrifice child'
r'(?:\n)' r'(?:\n)'
r'Killed process \d+ \(.*\) total-vm:(?P<killed_proc_vm_kb>\d+)kB, anon-rss:(?P<killed_proc_anon_rss_kb>\d+)kB, ' r'Killed process \d+ \(.*\) total-vm:(?P<killed_proc_vm_kb>\d+)kB, anon-rss:(?P<killed_proc_anon_rss_kb>\d+)kB, '
r'file-rss:(?P<killed_proc_file_rss_kb>\d+)kB, shmem-rss:(?P<killed_proc_shmem_rss_kb>\d+)kB' r'file-rss:(?P<killed_proc_file_rss_kb>\d+)kB, shmem-rss:(?P<killed_proc_shmem_rss_kb>\d+)kB',
,
re.MULTILINE) re.MULTILINE)
lines = [] lines = []
@ -436,7 +428,7 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
print("ERROR: HTML element not found: ", item) print("ERROR: HTML element not found: ", item)
return return
content = self.details.get(item, '') content = self.details.get(item, '')
if type(content) is str: if isinstance(content, str):
content = content.strip() content = content.strip()
element.textContent = content element.textContent = content
if DEBUG: if DEBUG:
@ -610,7 +602,7 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
# TODO Add to HTML # TODO Add to HTML
#match = self.REC_PAGEINFO.search(self.oom.text) #match = self.REC_PAGEINFO.search(self.oom.text)
#if match: # if match:
# self.details.update(match.groupdict()) # self.details.update(match.groupdict())
match = self.REC_PROCESSES.search(self.oom.text) match = self.REC_PROCESSES.search(self.oom.text)
@ -635,7 +627,7 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
if item.endswith('_kb') or item.endswith('_pages'): if item.endswith('_kb') or item.endswith('_pages'):
try: try:
self.details[item] = int(self.details[item]) self.details[item] = int(self.details[item])
except: except BaseException:
error('Converting item {}: {} to integer failed'. format(item, self.details[item])) error('Converting item {}: {} to integer failed'. format(item, self.details[item]))
kernel_version = self.details.get('kernel_version', '') kernel_version = self.details.get('kernel_version', '')