"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/dstat_top_int.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_int.py  (dstat-0.7.3):dstat_top_int.py  (dstat-0.7.4)
skipping to change at line 15 skipping to change at line 15
Top interrupt Top interrupt
Displays the name of the most frequent interrupt Displays the name of the most frequent interrupt
""" """
def __init__(self): def __init__(self):
self.name = 'most frequent' self.name = 'most frequent'
self.vars = ('interrupt',) self.vars = ('interrupt',)
self.type = 's' self.type = 's'
self.width = 20 self.width = 20
self.scale = 0 self.scale = 0
self.intset1 = [ 0 ] * 1024 self.intset1 = [ ]
self.open('/proc/stat') self.open('/proc/stat')
self.names = self.names() self.names = self.names()
def names(self): def names(self):
ret = {} ret = {}
for line in dopen('/proc/interrupts'): for line in dopen('/proc/interrupts'):
l = line.split() l = line.split()
if len(l) <= cpunr: continue if len(l) <= cpunr: continue
l1 = l[0].split(':')[0] l1 = l[0].split(':')[0]
### Cleanup possible names from /proc/interrupts ### Cleanup possible names from /proc/interrupts
l2 = ' '.join(l[cpunr+2:]) l2 = ' '.join(l[cpunr+3:])
l2 = l2.replace('_hcd:', '/') l2 = l2.replace('_hcd:', '/')
l2 = re.sub('@pci[:\d+\.]+', '', l2) l2 = re.sub('@pci[:\d+\.]+', '', l2)
l2 = re.sub('ahci\[[:\da-z\.]+\]', 'ahci', l2)
ret[l1] = l2 ret[l1] = l2
return ret return ret
def extract(self): def extract(self):
self.output = '' self.output = ''
self.val['total'] = 0.0 self.val['total'] = 0.0
for line in self.splitlines(): for line in self.splitlines():
if line[0] == 'intr': if line[0] == 'intr':
self.intset2 = [ long(int) for int in line[3:] ] self.intset2 = [ int(i) for i in line[3:] ]
if not self.intset1:
self.intset1 = [ 0 for i in self.intset2 ]
for i in range(len(self.intset2)): for i in range(len(self.intset2)):
total = (self.intset2[i] - self.intset1[i]) * 1.0 / elapsed total = (self.intset2[i] - self.intset1[i]) * 1.0 / elapsed
### Put the highest value in self.val ### Put the highest value in self.val
if total > self.val['total']: if total > self.val['total']:
if str(i+1) in self.names.keys(): if str(i+1) in self.names:
self.val['name'] = self.names[str(i+1)] self.val['name'] = self.names[str(i+1)]
else: else:
self.val['name'] = 'int ' + str(i+1) self.val['name'] = 'int ' + str(i+1)
self.val['total'] = total self.val['total'] = total
if step == op.delay: if step == op.delay:
self.intset1 = self.intset2 self.intset1 = self.intset2
if self.val['total'] != 0.0: if self.val['total'] != 0.0:
self.output = '%-15s%s' % (self.val['name'], cprint(self.val['total' ], 'd', 5, 1000)) self.output = '%-15s%s' % (self.val['name'], cprint(self.val['total' ], 'd', 5, 1000))
 End of changes. 5 change blocks. 
4 lines changed or deleted 8 lines changed or added

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