dstat_vmk_hba.py (dstat-0.7.3) | : | dstat_vmk_hba.py (dstat-0.7.4) | ||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
self.nick = ('read', 'writ') | self.nick = ('read', 'writ') | |||
self.cols = 2 | self.cols = 2 | |||
def discover(self, *list): | def discover(self, *list): | |||
# discover will list all vmhba's found. | # discover will list all vmhba's found. | |||
# we might want to filter out the unused vmhba's (read stats, compare with [ '0', ] * 13) | # we might want to filter out the unused vmhba's (read stats, compare with [ '0', ] * 13) | |||
ret = [] | ret = [] | |||
try: | try: | |||
list = os.listdir('/proc/vmware/scsi/') | list = os.listdir('/proc/vmware/scsi/') | |||
except: | except: | |||
raise Exception, 'Needs VMware ESX' | raise Exception('Needs VMware ESX') | |||
for name in list: | for name in list: | |||
for line in dopen('/proc/vmware/scsi/%s/stats' % name).readlines(): | for line in dopen('/proc/vmware/scsi/%s/stats' % name).readlines(): | |||
l = line.split() | l = line.split() | |||
if len(l) < 13: continue | if len(l) < 13: continue | |||
if l[0] == 'cmds': continue | if l[0] == 'cmds': continue | |||
if l == ['0', ] * 13: continue | if l == ['0', ] * 13: continue | |||
ret.append(name) | ret.append(name) | |||
return ret | return ret | |||
def vars(self): | def vars(self): | |||
skipping to change at line 57 | skipping to change at line 57 | |||
list.sort() | list.sort() | |||
for name in list: | for name in list: | |||
if name in self.discover + ['total']: | if name in self.discover + ['total']: | |||
ret.append(name) | ret.append(name) | |||
return ret | return ret | |||
def check(self): | def check(self): | |||
try: | try: | |||
os.listdir('/proc/vmware') | os.listdir('/proc/vmware') | |||
except: | except: | |||
raise Exception, 'Needs VMware ESX' | raise Exception('Needs VMware ESX') | |||
info(1, 'The vmkhba module is an EXPERIMENTAL module.') | info(1, 'The vmkhba module is an EXPERIMENTAL module.') | |||
def extract(self): | def extract(self): | |||
self.set2['total'] = (0, 0) | self.set2['total'] = (0, 0) | |||
for name in self.vars: | for name in self.vars: | |||
self.set2[name] = (0, 0) | self.set2[name] = (0, 0) | |||
for name in os.listdir('/proc/vmware/scsi/'): | for name in os.listdir('/proc/vmware/scsi/'): | |||
for line in dopen('/proc/vmware/scsi/%s/stats' % name).readlines(): | for line in dopen('/proc/vmware/scsi/%s/stats' % name).readlines(): | |||
l = line.split() | l = line.split() | |||
if len(l) < 13: continue | if len(l) < 13: continue | |||
if l[0] == 'cmds': continue | if l[0] == 'cmds': continue | |||
if l[2] == '0' and l[4] == '0': continue | if l[2] == '0' and l[4] == '0': continue | |||
if l == ['0', ] * 13: continue | if l == ['0', ] * 13: continue | |||
self.set2['total'] = ( self.set2['total'][0] + long(l[2]), self. set2['total'][1] + long(l[4]) ) | self.set2['total'] = ( self.set2['total'][0] + int(l[2]), self.s et2['total'][1] + int(l[4]) ) | |||
if name in self.vars and name != 'total': | if name in self.vars and name != 'total': | |||
self.set2[name] = ( long(l[2]), long(l[4]) ) | self.set2[name] = ( int(l[2]), int(l[4]) ) | |||
for name in self.set2.keys(): | for name in self.set2: | |||
self.val[name] = map(lambda x, y: (y - x) * 1024.0 / elapsed, se | self.val[name] = list(map(lambda x, y: (y - x) * 1024.0 / elapse | |||
lf.set1[name], self.set2[name]) | d, self.set1[name], self.set2[name])) | |||
if step == op.delay: | if step == op.delay: | |||
self.set1.update(self.set2) | self.set1.update(self.set2) | |||
End of changes. 5 change blocks. | ||||
7 lines changed or deleted | 7 lines changed or added |