dstat_top_bio_adv.py (dstat-0.7.3) | : | dstat_top_bio_adv.py (dstat-0.7.4) | ||
---|---|---|---|---|
skipping to change at line 17 | skipping to change at line 17 | |||
def __init__(self): | def __init__(self): | |||
self.name = 'most expensive block i/o process' | self.name = 'most expensive block i/o process' | |||
self.vars = ('process pid read write cpu',) | self.vars = ('process pid read write cpu',) | |||
self.type = 's' | self.type = 's' | |||
self.width = 40 | self.width = 40 | |||
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') | |||
return True | return True | |||
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] = {'read_bytes:': 0, 'write_bytes:': 0, 'c putime:': 0, 'cpuper:': 0} | self.pidset2[pid] = {'read_bytes:': 0, 'write_bytes:': 0, 'c putime:': 0, 'cpuper:': 0} | |||
if not self.pidset1.has_key(pid): | if pid not in self.pidset1: | |||
self.pidset1[pid] = {'read_bytes:': 0, 'write_bytes:': 0, 'c putime:': 0, 'cpuper:': 0} | self.pidset1[pid] = {'read_bytes:': 0, 'write_bytes:': 0, 'c putime:': 0, 'cpuper:': 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]) | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |