"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/dstat_top_cputime.py" between
dstat-0.7.3.tar.gz and dstat-0.7.4.tar.gz

About: dstat is a versatile resource statistic tool and a replacement for vmstat, iostat and ifstat (using Python).

dstat_top_cputime.py  (dstat-0.7.3):dstat_top_cputime.py  (dstat-0.7.4)
skipping to change at line 25 skipping to change at line 25
def __init__(self): def __init__(self):
self.name = 'highest total' self.name = 'highest total'
self.vars = ('cputime process',) self.vars = ('cputime process',)
self.type = 's' self.type = 's'
self.width = 17 self.width = 17
self.scale = 0 self.scale = 0
self.pidset1 = {} self.pidset1 = {}
def check(self): def check(self):
if not os.access('/proc/self/schedstat', os.R_OK): if not os.access('/proc/self/schedstat', os.R_OK):
raise Exception, 'Kernel has no scheduler statistics [CONFIG_SCHEDST ATS], use at least 2.6.12' raise Exception('Kernel has no scheduler statistics [CONFIG_SCHEDSTA TS], use at least 2.6.12')
def extract(self): def extract(self):
self.output = '' self.output = ''
self.pidset2 = {} self.pidset2 = {}
self.val['result'] = 0 self.val['result'] = 0
for pid in proc_pidlist(): for pid in proc_pidlist():
try: try:
### Reset values ### Reset values
if not self.pidset1.has_key(pid): if pid not in self.pidset1:
self.pidset1[pid] = {'run_ticks': 0} self.pidset1[pid] = {'run_ticks': 0}
### Extract name ### Extract name
name = proc_splitline('/proc/%s/stat' % pid)[1][1:-1] name = proc_splitline('/proc/%s/stat' % pid)[1][1:-1]
### Extract counters ### Extract counters
l = proc_splitline('/proc/%s/schedstat' % pid) l = proc_splitline('/proc/%s/schedstat' % pid)
except IOError: except IOError:
continue continue
except IndexError: except IndexError:
continue continue
if len(l) != 3: continue if len(l) != 3: continue
self.pidset2[pid] = {'run_ticks': long(l[0])} self.pidset2[pid] = {'run_ticks': int(l[0])}
totrun = (self.pidset2[pid]['run_ticks'] - self.pidset1[pid]['run_ti cks']) * 1.0 / elapsed totrun = (self.pidset2[pid]['run_ticks'] - self.pidset1[pid]['run_ti cks']) * 1.0 / elapsed
### Get the process that spends the most jiffies ### Get the process that spends the most jiffies
if totrun > self.val['result']: if totrun > self.val['result']:
self.val['result'] = totrun self.val['result'] = totrun
self.val['pid'] = pid self.val['pid'] = pid
self.val['name'] = getnamebypid(pid, name) self.val['name'] = getnamebypid(pid, name)
if step == op.delay: if step == op.delay:
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)