"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/dstat_top_io.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_io.py  (dstat-0.7.3):dstat_top_io.py  (dstat-0.7.4)
skipping to change at line 19 skipping to change at line 19
def __init__(self): def __init__(self):
self.name = 'most expensive' self.name = 'most expensive'
self.vars = ('i/o process',) self.vars = ('i/o process',)
self.type = 's' self.type = 's'
self.width = 22 self.width = 22
self.scale = 0 self.scale = 0
self.pidset1 = {} self.pidset1 = {}
def check(self): def check(self):
if not os.access('/proc/self/io', os.R_OK): if not os.access('/proc/self/io', os.R_OK):
raise Exception, 'Kernel has no per-process I/O accounting [CONFIG_T ASK_IO_ACCOUNTING], use at least 2.6.20' raise Exception('Kernel has no per-process I/O accounting [CONFIG_TA SK_IO_ACCOUNTING], use at least 2.6.20')
def extract(self): def extract(self):
self.output = '' self.output = ''
self.pidset2 = {} self.pidset2 = {}
self.val['usage'] = 0.0 self.val['usage'] = 0.0
for pid in proc_pidlist(): for pid in proc_pidlist():
try: try:
### Reset values ### Reset values
if not self.pidset2.has_key(pid): if pid not in self.pidset2:
self.pidset2[pid] = {'rchar:': 0, 'wchar:': 0} self.pidset2[pid] = {'rchar:': 0, 'wchar:': 0}
if not self.pidset1.has_key(pid): if pid not in self.pidset1:
self.pidset1[pid] = {'rchar:': 0, 'wchar:': 0} self.pidset1[pid] = {'rchar:': 0, 'wchar:': 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
for l in proc_splitlines('/proc/%s/io' % pid): for l in proc_splitlines('/proc/%s/io' % pid):
if len(l) != 2: continue if len(l) != 2: continue
self.pidset2[pid][l[0]] = int(l[1]) self.pidset2[pid][l[0]] = int(l[1])
except IOError: except IOError:
continue continue
except IndexError: except IndexError:
continue continue
read_usage = (self.pidset2[pid]['rchar:'] - self.pidset1[pid]['rchar :']) * 1.0 / elapsed read_usage = (self.pidset2[pid]['rchar:'] - self.pidset1[pid]['rchar :']) * 1.0 / elapsed
write_usage = (self.pidset2[pid]['wchar:'] - self.pidset1[pid]['wcha r:']) * 1.0 / elapsed write_usage = (self.pidset2[pid]['wchar:'] - self.pidset1[pid]['wcha r:']) * 1.0 / elapsed
usage = read_usage + write_usage usage = read_usage + write_usage
# if usage > 0.0: # if usage > 0.0:
# print '%s %s:%s' % (pid, read_usage, write_usage) # print('%s %s:%s' % (pid, read_usage, write_usage))
### Get the process that spends the most jiffies ### Get the process that spends the most jiffies
if usage > self.val['usage']: if usage > self.val['usage']:
self.val['usage'] = usage self.val['usage'] = usage
self.val['read_usage'] = read_usage self.val['read_usage'] = read_usage
self.val['write_usage'] = write_usage self.val['write_usage'] = write_usage
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. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added

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