"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/dstat_top_cputime_avg.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_avg.py  (dstat-0.7.3):dstat_top_cputime_avg.py  (dstat-0.7.4)
skipping to change at line 26 skipping to change at line 26
def __init__(self): def __init__(self):
self.name = 'highest average' self.name = 'highest average'
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, 'ran': 0} self.pidset1[pid] = {'run_ticks': 0, 'ran': 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]), 'ran': long(l[2])} self.pidset2[pid] = {'run_ticks': int(l[0]), 'ran': int(l[2])}
if self.pidset2[pid]['ran'] - self.pidset1[pid]['ran'] > 0: if self.pidset2[pid]['ran'] - self.pidset1[pid]['ran'] > 0:
avgrun = (self.pidset2[pid]['run_ticks'] - self.pidset1[pid]['ru n_ticks']) * 1.0 / (self.pidset2[pid]['ran'] - self.pidset1[pid]['ran']) / elaps ed avgrun = (self.pidset2[pid]['run_ticks'] - self.pidset1[pid]['ru n_ticks']) * 1.0 / (self.pidset2[pid]['ran'] - self.pidset1[pid]['ran']) / elaps ed
else: else:
avgrun = 0 avgrun = 0
### Get the process that spends the most jiffies ### Get the process that spends the most jiffies
if avgrun > self.val['result']: if avgrun > self.val['result']:
self.val['result'] = avgrun self.val['result'] = avgrun
self.val['pid'] = pid self.val['pid'] = pid
 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)