Changed all tabs to 4 spaces for python style
This commit is contained in:
@@ -2,20 +2,20 @@ import os
|
||||
import info
|
||||
|
||||
INTERNALS = {
|
||||
'PLGNAME': "cpu",
|
||||
'TABNAME': None,
|
||||
'AUTHOR': "Eduardo Silva",
|
||||
'DESC': "Print CPU usage",
|
||||
'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
|
||||
# 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
|
||||
}
|
||||
# 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)
|
||||
|
||||
@@ -7,42 +7,42 @@
|
||||
############################################################
|
||||
|
||||
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'])
|
||||
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
|
||||
# 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
|
||||
# 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]
|
||||
|
||||
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
|
||||
self.pids_ujiffies[pid] = ujiffies
|
||||
|
||||
|
||||
Reference in New Issue
Block a user