Unify ps table column names in class KernelConfig
This commit is contained in:
parent
26610a709e
commit
2d55b800dc
@ -77,6 +77,14 @@ def show_notifybox(prefix, msg):
|
|||||||
notify_box.appendChild(notification)
|
notify_box.appendChild(notification)
|
||||||
|
|
||||||
|
|
||||||
|
class KernelConfig(object):
|
||||||
|
"""Kernel configuration"""
|
||||||
|
|
||||||
|
ps_table_items = ['pid', 'uid', 'tgid', 'total_vm_pages', 'rss_pages', 'nr_ptes_pages', 'swapents_pages',
|
||||||
|
'oom_score_adj']
|
||||||
|
"""Elements of the process table"""
|
||||||
|
|
||||||
|
|
||||||
class OOMEntity(object):
|
class OOMEntity(object):
|
||||||
"""Hold whole OOM message block and provide access"""
|
"""Hold whole OOM message block and provide access"""
|
||||||
|
|
||||||
@ -364,11 +372,14 @@ class OOMAnalyser(object):
|
|||||||
lines = []
|
lines = []
|
||||||
"""All lines of an OOM without leading timestamps"""
|
"""All lines of an OOM without leading timestamps"""
|
||||||
|
|
||||||
|
kernel_cfg = KernelConfig()
|
||||||
|
"""Kernel configuration"""
|
||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
"""Extracted result"""
|
"""Extracted result"""
|
||||||
|
|
||||||
# Reference to the OOMEntity object
|
|
||||||
oom_entity = None
|
oom_entity = None
|
||||||
|
"""Reference to the OOMEntity object"""
|
||||||
|
|
||||||
GFP_FLAGS = {
|
GFP_FLAGS = {
|
||||||
'GFP_ATOMIC': {'value': '__GFP_HIGH | __GFP_ATOMIC | __GFP_KSWAPD_RECLAIM'},
|
'GFP_ATOMIC': {'value': '__GFP_HIGH | __GFP_ATOMIC | __GFP_KSWAPD_RECLAIM'},
|
||||||
@ -595,8 +606,9 @@ class OOMAnalyser(object):
|
|||||||
for pid_str in ps.keys():
|
for pid_str in ps.keys():
|
||||||
converted = {}
|
converted = {}
|
||||||
process = ps[pid_str]
|
process = ps[pid_str]
|
||||||
for item in ['uid', 'tgid', 'total_vm_pages', 'rss_pages', 'nr_ptes_pages', 'swapents_pages',
|
for item in self.kernel_cfg.ps_table_items:
|
||||||
'oom_score_adj']:
|
if item == 'pid':
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
converted[item] = int(process[item])
|
converted[item] = int(process[item])
|
||||||
except:
|
except:
|
||||||
@ -734,6 +746,9 @@ class OOMAnalyser(object):
|
|||||||
class OOMDisplay(object):
|
class OOMDisplay(object):
|
||||||
"""Display the OOM analysis"""
|
"""Display the OOM analysis"""
|
||||||
|
|
||||||
|
kernel_cfg = KernelConfig()
|
||||||
|
"""Kernel configuration"""
|
||||||
|
|
||||||
oom_details = {}
|
oom_details = {}
|
||||||
"""Extracted result"""
|
"""Extracted result"""
|
||||||
|
|
||||||
@ -1041,9 +1056,14 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
|
|||||||
|
|
||||||
def set_sort_triangle(self):
|
def set_sort_triangle(self):
|
||||||
"""Set the sorting symbols for all columns in the process table"""
|
"""Set the sorting symbols for all columns in the process table"""
|
||||||
for column_name in ['pid', 'uid', 'tgid', 'total_vm_pages', 'rss_pages', 'nr_ptes_pages', 'swapents_pages',
|
# TODO Check operator overloading
|
||||||
'oom_score_adj', 'name', 'notes']:
|
# Operator overloading (Pragma opov) does not work in this context.
|
||||||
|
# self.kernel_cfg.ps_table_items + ['notes'] will compile to a string
|
||||||
|
# "pid,uid,tgid,total_vm_pages,rss_pages,nr_ptes_pages,swapents_pages,oom_score_adjNotes" and not to an
|
||||||
|
# array
|
||||||
|
ps_table_and_notes = self.kernel_cfg.ps_table_items[:]
|
||||||
|
ps_table_and_notes.append('notes')
|
||||||
|
for column_name in ps_table_and_notes:
|
||||||
element_id = "pstable_sort_{}".format(column_name)
|
element_id = "pstable_sort_{}".format(column_name)
|
||||||
element = document.getElementById(element_id)
|
element = document.getElementById(element_id)
|
||||||
if not element:
|
if not element:
|
||||||
@ -1214,6 +1234,8 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
|
|||||||
# analyse
|
# analyse
|
||||||
analyser = OOMAnalyser(self.oom)
|
analyser = OOMAnalyser(self.oom)
|
||||||
self.oom_details = analyser.analyse()
|
self.oom_details = analyser.analyse()
|
||||||
|
# Update kernel configuration
|
||||||
|
self.kernel_cfg = analyser.kernel_cfg
|
||||||
|
|
||||||
# display results
|
# display results
|
||||||
self.show()
|
self.show()
|
||||||
@ -1302,8 +1324,14 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
|
|||||||
|
|
||||||
def sort_pstable(self, column_name):
|
def sort_pstable(self, column_name):
|
||||||
"""Sort process table by the values in the given column"""
|
"""Sort process table by the values in the given column"""
|
||||||
if column_name not in ['pid', 'uid', 'tgid', 'total_vm_pages', 'rss_pages', 'nr_ptes_pages', 'swapents_pages',
|
# TODO Check operator overloading
|
||||||
'oom_score_adj', 'name', 'notes']:
|
# Operator overloading (Pragma opov) does not work in this context.
|
||||||
|
# self.kernel_cfg.ps_table_items + ['notes'] will compile to a string
|
||||||
|
# "pid,uid,tgid,total_vm_pages,rss_pages,nr_ptes_pages,swapents_pages,oom_score_adjNotes" and not to an
|
||||||
|
# array
|
||||||
|
ps_table_and_notes = self.kernel_cfg.ps_table_items[:]
|
||||||
|
ps_table_and_notes.append('notes')
|
||||||
|
if column_name not in ps_table_and_notes:
|
||||||
internal_error('Can not sort process table with an unknown column name "{}"'.format(column_name))
|
internal_error('Can not sort process table with an unknown column name "{}"'.format(column_name))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user