New developer-console
This commit is contained in:
committed by
Marco Pesenti Gritti
parent
9a7518f230
commit
d51031d882
@@ -0,0 +1,4 @@
|
||||
SUBDIRS = clean_size cpu dirty_size memphis_init
|
||||
|
||||
sugardir = $(pkgdatadir)/shell/console/plugins
|
||||
sugar_PYTHON =
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
sugardir = $(pkgdatadir)/shell/console/plugins/clean_size
|
||||
sugar_PYTHON = \
|
||||
README \
|
||||
__init__.py \
|
||||
info.py
|
||||
@@ -0,0 +1,2 @@
|
||||
This plugin give support to get the clean size memory usage
|
||||
by process using the /proc/PID/maps file.
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
import info
|
||||
|
||||
INTERNALS = {
|
||||
# Basic information
|
||||
'PLGNAME': "Clean Size",
|
||||
'TABNAME': None,
|
||||
'AUTHOR': "Eduardo Silva",
|
||||
'DESC': "Print the approx real memory usage",
|
||||
|
||||
# Plugin API
|
||||
'Plg': None, # Plugin object
|
||||
|
||||
'top_data': [int], # Top data types needed by memphis core plugin
|
||||
'top_cols': ["Approx Real Usage (kb)"]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
###########################################################
|
||||
# Main function:
|
||||
# -----------------
|
||||
# self: self plugin object
|
||||
# mself: memphis object / principal class
|
||||
# pinfo: row with information about current tracing process
|
||||
############################################################
|
||||
|
||||
def plg_on_top_data_refresh(self, pinfo):
|
||||
|
||||
# Get clean size
|
||||
maps = self.INTERNALS['Plg'].proc_get_maps(pinfo['pid'])
|
||||
|
||||
size = (maps.clean_size/1024)
|
||||
return [size]
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
sugardir = $(pkgdatadir)/shell/console/plugins/cpu
|
||||
sugar_PYTHON = \
|
||||
README \
|
||||
__init__.py \
|
||||
info.py
|
||||
@@ -0,0 +1,2 @@
|
||||
This plugin give support to draw the Virtual Memory Size
|
||||
usage by the current tracing process.
|
||||
@@ -0,0 +1,23 @@
|
||||
import os
|
||||
import info
|
||||
|
||||
INTERNALS = {
|
||||
'PLGNAME': "cpu",
|
||||
'TABNAME': None,
|
||||
'AUTHOR': "Eduardo Silva",
|
||||
'DESC': "Print CPU usage",
|
||||
|
||||
# Plugin API
|
||||
'Plg': None, # Plugin object
|
||||
'current_plg': None, # Current plugin object
|
||||
'current_page': None, # Current page number
|
||||
|
||||
# Top process view requirements
|
||||
'top_data': [int], # Top data types needed by memphis core plugin
|
||||
'top_cols': ["%CPU "] # Column names
|
||||
}
|
||||
|
||||
# Get CPU frequency
|
||||
cpu_hz = os.sysconf(2)
|
||||
|
||||
pids_ujiffies = {}
|
||||
@@ -0,0 +1,48 @@
|
||||
###########################################################
|
||||
# Main function:
|
||||
# -----------------
|
||||
# self: self plugin object
|
||||
# mself: memphis object / principal class
|
||||
# pinfo: row with information about current tracing process
|
||||
############################################################
|
||||
|
||||
def plg_on_top_data_refresh(self, pinfo):
|
||||
PI = self.INTERNALS['Plg'].proc
|
||||
|
||||
pid = pinfo['pid']
|
||||
|
||||
# Get JIFFIES CPU usage
|
||||
used_jiffies = pinfo['utime'] + pinfo['stime']
|
||||
last_ujiffies = get_pid_ujiffies(self, pid)
|
||||
|
||||
cpu_usage = PI.get_CPU_usage(self.cpu_hz, used_jiffies, pinfo['start_time'])
|
||||
|
||||
# Get PERCENT CPU usage
|
||||
if last_ujiffies == 0.0:
|
||||
pcpu = 0.0
|
||||
set_pid_ujiffies(self, pid, cpu_usage['used_jiffies'])
|
||||
data = [int(pcpu)]
|
||||
return data
|
||||
|
||||
used_jiffies = cpu_usage['used_jiffies'] - last_ujiffies
|
||||
|
||||
# Available jiffies are
|
||||
avail_jiffies = (500/1000.0)*self.cpu_hz # 500 = 0.5 second
|
||||
pcpu = ((used_jiffies*100)/avail_jiffies)
|
||||
|
||||
set_pid_ujiffies(self, pid, cpu_usage['used_jiffies'])
|
||||
|
||||
data = [int(pcpu)]
|
||||
return data
|
||||
|
||||
def get_pid_ujiffies(self, pid):
|
||||
|
||||
if pid in self.pids_ujiffies:
|
||||
return self.pids_ujiffies[pid]
|
||||
else:
|
||||
set_pid_ujiffies(self, pid, 0)
|
||||
return self.pids_ujiffies[pid]
|
||||
|
||||
def set_pid_ujiffies(self, pid, ujiffies):
|
||||
self.pids_ujiffies[pid] = ujiffies
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
sugardir = $(pkgdatadir)/shell/console/plugins/dirty_size
|
||||
sugar_PYTHON = \
|
||||
README \
|
||||
__init__.py \
|
||||
info.py
|
||||
@@ -0,0 +1,2 @@
|
||||
This plugin give support to get the public and shared dirty memory usage
|
||||
by process using the /proc/PID/smaps file.
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
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)"]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
###########################################################
|
||||
# Main function:
|
||||
# -----------------
|
||||
# self: self plugin object
|
||||
# mself: memphis object / principal class
|
||||
# pinfo: row with information about current tracing process
|
||||
############################################################
|
||||
|
||||
|
||||
def plg_on_top_data_refresh(self, ppinfo):
|
||||
|
||||
dirty_sizes = get_dirty(self, ppinfo['pid'])
|
||||
|
||||
# memhis need an array
|
||||
return [dirty_sizes['private']]
|
||||
|
||||
def get_dirty(pself, pid):
|
||||
ProcAnalysis = pself.INTERNALS['Plg'].proc_analysis(pid)
|
||||
|
||||
return ProcAnalysis.DirtyRSS()
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
sugardir = $(pkgdatadir)/shell/console/plugins/memphis_init
|
||||
sugar_PYTHON = \
|
||||
README \
|
||||
__init__.py \
|
||||
info.py
|
||||
@@ -0,0 +1,2 @@
|
||||
This plugin give support to draw the Virtual Memory Size
|
||||
usage by the current tracing process.
|
||||
@@ -0,0 +1,15 @@
|
||||
import info
|
||||
|
||||
INTERNALS = {
|
||||
'PLGNAME': "memphis",
|
||||
'TABNAME': None,
|
||||
'AUTHOR': "Eduardo Silva",
|
||||
'DESC': "Print basic process information",
|
||||
|
||||
# Plugin API
|
||||
'Plg': None, # Plugin object
|
||||
|
||||
# Top process view requirements
|
||||
'top_data': [int, str, str], # Top data types needed by memphis core plugin
|
||||
'top_cols': ["PID", "Process Name", "Status"] # Column names
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
###########################################################
|
||||
# Main function:
|
||||
# -----------------
|
||||
# self: self plugin object
|
||||
# mself: memphis object / principal class
|
||||
# pinfo: row with information about current tracing process
|
||||
############################################################
|
||||
|
||||
def plg_on_top_data_refresh(self, ppinfo):
|
||||
|
||||
data = [ppinfo['pid'], ppinfo['name'], ppinfo['state_name']]
|
||||
|
||||
return data
|
||||
Reference in New Issue
Block a user