Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
commit
9c0df1c6c5
@ -130,15 +130,14 @@ class Data:
|
|||||||
treeview.set_model(self.store)
|
treeview.set_model(self.store)
|
||||||
|
|
||||||
def _start_memphis(self, button):
|
def _start_memphis(self, button):
|
||||||
|
|
||||||
# Update information every 1.5 second
|
# Update information every 1.5 second
|
||||||
button.hide()
|
button.hide()
|
||||||
self.interface.button_stop.show()
|
self.interface.button_stop.show()
|
||||||
self._running_status = True
|
self._running_status = True
|
||||||
gobject.timeout_add(1500, self.load_data, self.treeview)
|
self._gid = gobject.timeout_add(1500, self.load_data, self.treeview)
|
||||||
|
|
||||||
def _stop_memphis(self, button):
|
def _stop_memphis(self, button):
|
||||||
|
gobject.source_remove(self._gid)
|
||||||
self._running_status = False
|
self._running_status = False
|
||||||
button.hide()
|
button.hide()
|
||||||
self.interface.button_start.show()
|
self.interface.button_start.show()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SUBDIRS = clean_size cpu dirty_size memphis_init
|
SUBDIRS = clean_size cpu smaps memphis_init
|
||||||
|
|
||||||
sugardir = $(pkgdatadir)/services/console/interface/memphis/plugins
|
sugardir = $(pkgdatadir)/services/console/interface/memphis/plugins
|
||||||
sugar_PYTHON =
|
sugar_PYTHON =
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
|
|
||||||
import info
|
|
||||||
|
|
||||||
|
|
||||||
INTERNALS = {
|
|
||||||
# Basic information
|
|
||||||
'PLGNAME': "Dirty Size",
|
|
||||||
'TABNAME': None, # No tabbed plugin
|
|
||||||
'AUTHOR': "Eduardo Silva",
|
|
||||||
'DESC': "Get dirty size memory usage",
|
|
||||||
|
|
||||||
# Plugin API
|
|
||||||
'Plg': None, # Plugin object
|
|
||||||
|
|
||||||
'top_data': [int], # Top data types needed by memphis core plugin
|
|
||||||
'top_cols': ["PDRSS (kb)"]
|
|
||||||
}
|
|
@ -11,3 +11,4 @@ def plg_on_top_data_refresh(self, ppinfo):
|
|||||||
data = [ppinfo['pid'], ppinfo['name'], ppinfo['state_name']]
|
data = [ppinfo['pid'], ppinfo['name'], ppinfo['state_name']]
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
17
services/console/interface/memphis/plugins/smaps/__init__.py
Normal file
17
services/console/interface/memphis/plugins/smaps/__init__.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
import info
|
||||||
|
|
||||||
|
|
||||||
|
INTERNALS = {
|
||||||
|
# Basic information
|
||||||
|
'PLGNAME': "SMaps",
|
||||||
|
'TABNAME': None, # No tabbed plugin
|
||||||
|
'AUTHOR': "Eduardo Silva",
|
||||||
|
'DESC': "Get dirty size and reference memory usage",
|
||||||
|
|
||||||
|
# Plugin API
|
||||||
|
'Plg': None, # Plugin object
|
||||||
|
|
||||||
|
'top_data': [int, int], # Top data types needed by memphis core plugin
|
||||||
|
'top_cols': ["PDRSS (kb)", "Referenced (kb)"]
|
||||||
|
}
|
@ -8,13 +8,12 @@
|
|||||||
|
|
||||||
|
|
||||||
def plg_on_top_data_refresh(self, ppinfo):
|
def plg_on_top_data_refresh(self, ppinfo):
|
||||||
|
smaps = get_data(self, ppinfo['pid'])
|
||||||
|
|
||||||
dirty_sizes = get_dirty(self, ppinfo['pid'])
|
# memphis need an array
|
||||||
|
return [smaps['private_dirty'], smaps['referenced']]
|
||||||
|
|
||||||
# memhis need an array
|
def get_data(pself, pid):
|
||||||
return [dirty_sizes['private']]
|
|
||||||
|
|
||||||
def get_dirty(pself, pid):
|
|
||||||
ProcAnalysis = pself.INTERNALS['Plg'].proc_analysis(pid)
|
ProcAnalysis = pself.INTERNALS['Plg'].proc_analysis(pid)
|
||||||
|
|
||||||
return ProcAnalysis.DirtyRSS()
|
return ProcAnalysis.SMaps()
|
@ -7,20 +7,22 @@ class Analysis:
|
|||||||
def __init__(self, pid):
|
def __init__(self, pid):
|
||||||
self.pid = pid
|
self.pid = pid
|
||||||
|
|
||||||
def DirtyRSS(self):
|
def SMaps(self):
|
||||||
smaps = proc_smaps.ProcSmaps(self.pid)
|
smaps = proc_smaps.ProcSmaps(self.pid)
|
||||||
dirty = []
|
private_dirty = 0
|
||||||
|
shared_dirty = 0
|
||||||
private = 0
|
referenced = 0
|
||||||
shared = 0
|
|
||||||
|
|
||||||
for map in smaps.mappings:
|
for map in smaps.mappings:
|
||||||
private += map.private_dirty
|
private_dirty += map.private_dirty
|
||||||
shared += map.shared_dirty
|
shared_dirty += map.shared_dirty
|
||||||
|
referenced += map.referenced
|
||||||
|
|
||||||
dirty = {"private": int(private), "shared": int(shared)}
|
smaps = {"private_dirty": int(private_dirty), \
|
||||||
|
"shared_dirty": int(shared_dirty),\
|
||||||
|
"referenced": int(referenced)}
|
||||||
|
|
||||||
return dirty
|
return smaps
|
||||||
|
|
||||||
def ApproxRealMemoryUsage(self):
|
def ApproxRealMemoryUsage(self):
|
||||||
maps = proc_smaps.ProcMaps(self.pid)
|
maps = proc_smaps.ProcMaps(self.pid)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import sys, os
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
import string
|
import string
|
||||||
|
|
||||||
class ProcInfo:
|
class ProcInfo:
|
||||||
@ -36,10 +38,12 @@ class ProcInfo:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
# Parsing data , check 'man 5 proc' for details
|
# Parsing data , check 'man 5 proc' for details
|
||||||
data = infile.read().split()
|
stat_data = infile.read()
|
||||||
|
|
||||||
infile.close()
|
infile.close()
|
||||||
|
|
||||||
|
process_name = self._get_process_name(stat_data)
|
||||||
|
data = self._get_safe_split(stat_data)
|
||||||
|
|
||||||
state_dic = {
|
state_dic = {
|
||||||
'R': 'Running',
|
'R': 'Running',
|
||||||
'S': 'Sleeping',
|
'S': 'Sleeping',
|
||||||
@ -51,10 +55,9 @@ class ProcInfo:
|
|||||||
|
|
||||||
# user and group owners
|
# user and group owners
|
||||||
pidstat = os.stat(pidfile)
|
pidstat = os.stat(pidfile)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'pid': int(data[0]), # Process ID
|
'pid': int(data[0]), # Process ID
|
||||||
'name': data[1].strip('()'), # Process name
|
'name': process_name,
|
||||||
'state': data[2], # Process State, ex: R|S|D|Z|T|W
|
'state': data[2], # Process State, ex: R|S|D|Z|T|W
|
||||||
'state_name': state_dic[data[2]], # Process State name, ex: Running, sleeping, Zombie, etc
|
'state_name': state_dic[data[2]], # Process State name, ex: Running, sleeping, Zombie, etc
|
||||||
'ppid': int(data[3]), # Parent process ID
|
'ppid': int(data[3]), # Parent process ID
|
||||||
@ -69,6 +72,14 @@ class ProcInfo:
|
|||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
# Return the process name
|
||||||
|
def _get_process_name(self, data):
|
||||||
|
m = re.search("\(.*\)", data)
|
||||||
|
return m.string[m.start()+1:m.end()-1]
|
||||||
|
|
||||||
|
def _get_safe_split(self, data):
|
||||||
|
new_data = re.sub("\(.*\)", '()', data)
|
||||||
|
return new_data.split()
|
||||||
|
|
||||||
# Returns the CPU usage expressed in Jiffies
|
# Returns the CPU usage expressed in Jiffies
|
||||||
def get_CPU_usage(self, cpu_hz, used_jiffies, start_time):
|
def get_CPU_usage(self, cpu_hz, used_jiffies, start_time):
|
||||||
|
@ -36,6 +36,7 @@ class ProcSmaps:
|
|||||||
# Shared_Dirty: 0 kB
|
# Shared_Dirty: 0 kB
|
||||||
# Private_Clean: 8 kB
|
# Private_Clean: 8 kB
|
||||||
# Private_Dirty: 0 kB
|
# Private_Dirty: 0 kB
|
||||||
|
# Referenced: 4 kb -> Introduced in kernel 2.6.22
|
||||||
|
|
||||||
while num_lines > 0:
|
while num_lines > 0:
|
||||||
fields = lines[line_idx].split (" ", 5)
|
fields = lines[line_idx].split (" ", 5)
|
||||||
@ -51,13 +52,20 @@ class ProcSmaps:
|
|||||||
shared_dirty = self.parse_smaps_size_line (lines[line_idx + 4])
|
shared_dirty = self.parse_smaps_size_line (lines[line_idx + 4])
|
||||||
private_clean = self.parse_smaps_size_line (lines[line_idx + 5])
|
private_clean = self.parse_smaps_size_line (lines[line_idx + 5])
|
||||||
private_dirty = self.parse_smaps_size_line (lines[line_idx + 6])
|
private_dirty = self.parse_smaps_size_line (lines[line_idx + 6])
|
||||||
|
referenced = self.parse_smaps_size_line (lines[line_idx + 7])
|
||||||
name = name.strip ()
|
name = name.strip ()
|
||||||
|
|
||||||
mapping = Mapping (size, rss, shared_clean, shared_dirty, private_clean, private_dirty, permissions, name)
|
mapping = Mapping (size, rss, shared_clean, shared_dirty, \
|
||||||
|
private_clean, private_dirty, referenced, permissions, name)
|
||||||
self.mappings.append (mapping)
|
self.mappings.append (mapping)
|
||||||
|
|
||||||
num_lines -= 7
|
num_lines -= 8
|
||||||
line_idx += 7
|
line_idx += 8
|
||||||
|
|
||||||
|
self._clear_reference(pid)
|
||||||
|
|
||||||
|
def _clear_reference(self, pid):
|
||||||
|
os.system("echo 1 > /proc/%s/clear_refs" % pid)
|
||||||
|
|
||||||
# Parses a line of the form "foo: 42 kB" and returns an integer for the "42" field
|
# Parses a line of the form "foo: 42 kB" and returns an integer for the "42" field
|
||||||
def parse_smaps_size_line (self, line):
|
def parse_smaps_size_line (self, line):
|
||||||
@ -66,13 +74,15 @@ class ProcSmaps:
|
|||||||
return int(fields[1])
|
return int(fields[1])
|
||||||
|
|
||||||
class Mapping:
|
class Mapping:
|
||||||
def __init__ (self, size, rss, shared_clean, shared_dirty, private_clean, private_dirty, permissions, name):
|
def __init__ (self, size, rss, shared_clean, shared_dirty, \
|
||||||
|
private_clean, private_dirty, referenced, permissions, name):
|
||||||
self.size = size
|
self.size = size
|
||||||
self.rss = rss
|
self.rss = rss
|
||||||
self.shared_clean = shared_clean
|
self.shared_clean = shared_clean
|
||||||
self.shared_dirty = shared_dirty
|
self.shared_dirty = shared_dirty
|
||||||
self.private_clean = private_clean
|
self.private_clean = private_clean
|
||||||
self.private_dirty = private_dirty
|
self.private_dirty = private_dirty
|
||||||
|
self.referenced = referenced
|
||||||
self.permissions = permissions
|
self.permissions = permissions
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user