This repository has been archived by the owner on Nov 26, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new set of disk plugins (cfr. iostat statistics)
- Loading branch information
Showing
6 changed files
with
252 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
### Author: Dag Wieers <dag$wieers,com> | ||
|
||
class dstat_plugin(dstat): | ||
""" | ||
The average queue length of the requests that were issued to the device. | ||
""" | ||
|
||
def __init__(self): | ||
self.version = 2 | ||
self.nick = ('avgqu',) | ||
self.type = 'f' | ||
self.width = 4 | ||
self.scale = 10 | ||
self.diskfilter = re.compile('^(dm-\d+|md\d+|[hsv]d[a-z]+\d+)$') | ||
self.open('/proc/diskstats') | ||
self.cols = 1 | ||
self.struct = dict( rq_ticks=0 ) | ||
|
||
def discover(self, *objlist): | ||
ret = [] | ||
for l in self.splitlines(): | ||
if len(l) < 13: continue | ||
if l[3:] == ['0',] * 11: continue | ||
name = l[2] | ||
ret.append(name) | ||
for item in objlist: ret.append(item) | ||
if not ret: | ||
raise Exception, "No suitable block devices found to monitor" | ||
return ret | ||
|
||
def vars(self): | ||
ret = [] | ||
if op.disklist: | ||
varlist = op.disklist | ||
else: | ||
varlist = [] | ||
blockdevices = [os.path.basename(filename) for filename in glob.glob('/sys/block/*')] | ||
for name in self.discover: | ||
if self.diskfilter.match(name): continue | ||
if name not in blockdevices: continue | ||
varlist.append(name) | ||
varlist.sort() | ||
for name in varlist: | ||
if name in self.discover: | ||
ret.append(name) | ||
return ret | ||
|
||
def name(self): | ||
return self.vars | ||
|
||
def extract(self): | ||
for l in self.splitlines(): | ||
if len(l) < 13: continue | ||
if l[3:] == ['0',] * 11: continue | ||
if l[3] == '0' and l[7] == '0': continue | ||
name = l[2] | ||
if name not in self.vars or name == 'total': continue | ||
self.set2[name] = dict( | ||
rq_ticks = long(l[13]), | ||
) | ||
|
||
for name in self.vars: | ||
self.val[name] = ( ( self.set2[name]['rq_ticks'] - self.set1[name]['rq_ticks'] ) * 1.0 / elapsed / 1000, ) | ||
|
||
if step == op.delay: | ||
self.set1.update(self.set2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
### Author: Dag Wieers <dag$wieers,com> | ||
|
||
class dstat_plugin(dstat): | ||
""" | ||
The average size (in sectors) of the requests that were issued | ||
to the device. | ||
""" | ||
|
||
def __init__(self): | ||
self.version = 2 | ||
self.nick = ('avgrq',) | ||
self.type = 'f' | ||
self.width = 4 | ||
self.scale = 10 | ||
self.diskfilter = re.compile('^(dm-\d+|md\d+|[hsv]d[a-z]+\d+)$') | ||
self.open('/proc/diskstats') | ||
self.cols = 1 | ||
self.struct = dict( nr_ios=0, rd_sect=0, wr_sect=0 ) | ||
|
||
def discover(self, *objlist): | ||
ret = [] | ||
for l in self.splitlines(): | ||
if len(l) < 13: continue | ||
if l[3:] == ['0',] * 11: continue | ||
name = l[2] | ||
ret.append(name) | ||
for item in objlist: ret.append(item) | ||
if not ret: | ||
raise Exception, "No suitable block devices found to monitor" | ||
return ret | ||
|
||
def vars(self): | ||
ret = [] | ||
if op.disklist: | ||
varlist = op.disklist | ||
else: | ||
varlist = [] | ||
blockdevices = [os.path.basename(filename) for filename in glob.glob('/sys/block/*')] | ||
for name in self.discover: | ||
if self.diskfilter.match(name): continue | ||
if name not in blockdevices: continue | ||
varlist.append(name) | ||
varlist.sort() | ||
for name in varlist: | ||
if name in self.discover: | ||
ret.append(name) | ||
return ret | ||
|
||
def name(self): | ||
return self.vars | ||
|
||
def extract(self): | ||
for l in self.splitlines(): | ||
if len(l) < 13: continue | ||
if l[3:] == ['0',] * 11: continue | ||
if l[3] == '0' and l[7] == '0': continue | ||
name = l[2] | ||
if name not in self.vars or name == 'total': continue | ||
self.set2[name] = dict( | ||
nr_ios = long(l[3])+long(l[7]), | ||
rd_sect = long(l[9]), | ||
wr_sect = long(l[11]), | ||
) | ||
|
||
for name in self.vars: | ||
tput = ( self.set2[name]['nr_ios'] - self.set1[name]['nr_ios'] ) | ||
if tput: | ||
ticks = self.set2[name]['rd_sect'] - self.set1[name]['rd_sect'] + \ | ||
self.set2[name]['wr_sect'] - self.set1[name]['wr_sect'] | ||
self.val[name] = ( ticks * 1.0 / tput, ) | ||
else: | ||
self.val[name] = ( 0.0, ) | ||
|
||
if step == op.delay: | ||
self.set1.update(self.set2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
### Author: David Nicklay <david-d$nicklay,com> | ||
### Modified from disk-util: Dag Wieers <dag$wieers,com> | ||
|
||
class dstat_plugin(dstat): | ||
""" | ||
The average service time (in milliseconds) for I/O requests that were | ||
issued to the device. | ||
Warning! Do not trust this field any more. | ||
""" | ||
|
||
def __init__(self): | ||
self.version = 2 | ||
self.nick = ('svctm',) | ||
self.type = 'f' | ||
self.width = 4 | ||
self.scale = 1 | ||
self.diskfilter = re.compile('^(dm-\d+|md\d+|[hsv]d[a-z]+\d+)$') | ||
self.open('/proc/diskstats') | ||
self.cols = 1 | ||
self.struct = dict( nr_ios=0, tot_ticks=0 ) | ||
|
||
def discover(self, *objlist): | ||
ret = [] | ||
for l in self.splitlines(): | ||
if len(l) < 13: continue | ||
if l[3:] == ['0',] * 11: continue | ||
name = l[2] | ||
ret.append(name) | ||
for item in objlist: ret.append(item) | ||
if not ret: | ||
raise Exception, "No suitable block devices found to monitor" | ||
return ret | ||
|
||
def vars(self): | ||
ret = [] | ||
if op.disklist: | ||
varlist = op.disklist | ||
else: | ||
varlist = [] | ||
blockdevices = [os.path.basename(filename) for filename in glob.glob('/sys/block/*')] | ||
for name in self.discover: | ||
if self.diskfilter.match(name): continue | ||
if name not in blockdevices: continue | ||
varlist.append(name) | ||
varlist.sort() | ||
for name in varlist: | ||
if name in self.discover: | ||
ret.append(name) | ||
return ret | ||
|
||
def name(self): | ||
return self.vars | ||
|
||
def extract(self): | ||
for l in self.splitlines(): | ||
if len(l) < 13: continue | ||
if l[3:] == ['0',] * 11: continue | ||
if l[3] == '0' and l[7] == '0': continue | ||
name = l[2] | ||
if name not in self.vars or name == 'total': continue | ||
self.set2[name] = dict( | ||
nr_ios = long(l[3])+long(l[7]), | ||
tot_ticks = long(l[12]), | ||
) | ||
|
||
for name in self.vars: | ||
tput = ( self.set2[name]['nr_ios'] - self.set1[name]['nr_ios'] ) | ||
if tput: | ||
util = ( self.set2[name]['tot_ticks'] - self.set1[name]['tot_ticks'] ) | ||
self.val[name] = ( util * 1.0 / tput, ) | ||
else: | ||
self.val[name] = ( 0.0, ) | ||
|
||
if step == op.delay: | ||
self.set1.update(self.set2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters