buildstats: tolerate absence of /proc/diskstats
In OpenVZ containers (and probably lx containers as well), the diskstats entry is not even present. Use the "NoLogicalDrive" introduced by Elizabeth Flanagan in such case. This allows the bitbaking to occure within such containers. (From OE-Core rev: 16e09b850dcb44cb1afe411439e40a4bae7e8002) (From OE-Core rev: 84bd443d82d8022027180b6ef1f7b7cfc7d06420) Signed-off-by: Jean-François Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
75f253d7d2
commit
726f3bce5a
|
@ -61,12 +61,14 @@ def set_device(e):
|
|||
# we do not collect diskstats as the method to collect meaningful statistics
|
||||
# for these fs types requires a bit more research.
|
||||
############################################################################
|
||||
for line in open("/proc/diskstats", "r"):
|
||||
if majordev == int(line.split()[0]) and minordev == int(line.split()[1]):
|
||||
rdev=line.split()[2]
|
||||
else:
|
||||
rdev="NoLogicalDevice"
|
||||
file = open(bb.data.getVar('DEVFILE', e.data, True), "w")
|
||||
rdev="NoLogicalDevice"
|
||||
try:
|
||||
for line in open("/proc/diskstats", "r"):
|
||||
if majordev == int(line.split()[0]) and minordev == int(line.split()[1]):
|
||||
rdev=line.split()[2]
|
||||
except:
|
||||
pass
|
||||
file = open(e.data.getVar('DEVFILE', True), "w")
|
||||
file.write(rdev)
|
||||
file.close()
|
||||
|
||||
|
@ -82,12 +84,15 @@ def get_diskstats(dev):
|
|||
# For info on what these are, see kernel doc file iostats.txt
|
||||
############################################################################
|
||||
DSTAT_KEYS = ['ReadsComp', 'ReadsMerged', 'SectRead', 'TimeReads', 'WritesComp', 'SectWrite', 'TimeWrite', 'IOinProgress', 'TimeIO', 'WTimeIO']
|
||||
for x in open("/proc/diskstats", "r"):
|
||||
if dev in x:
|
||||
diskstats_val = x.rstrip().split()[4:]
|
||||
diskstats = dict(itertools.izip(DSTAT_KEYS, diskstats_val))
|
||||
try:
|
||||
for x in open("/proc/diskstats", "r"):
|
||||
if dev in x:
|
||||
diskstats_val = x.rstrip().split()[4:]
|
||||
except IOError as e:
|
||||
return
|
||||
diskstats = dict(itertools.izip(DSTAT_KEYS, diskstats_val))
|
||||
return diskstats
|
||||
|
||||
|
||||
def set_diskdata(var, dev, data):
|
||||
data.setVar(var, get_diskstats(dev))
|
||||
|
||||
|
|
Loading…
Reference in New Issue