summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-François Dagenais <dagenaisj@sonatest.com>2012-01-15 20:11:05 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-30 16:49:48 +0000
commit726f3bce5abafa514978a984806814c800cb23d3 (patch)
treeadeb8917cf99706c1ba3586dd496a38fa936d99a
parent75f253d7d277c7ebe750ccb0015f12b027fb5ace (diff)
downloadpoky-726f3bce5abafa514978a984806814c800cb23d3.tar.gz
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>
-rw-r--r--meta/classes/buildstats.bbclass27
1 files changed, 16 insertions, 11 deletions
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 96c98d409f..f174964cc0 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -61,12 +61,14 @@ def set_device(e):
61 # we do not collect diskstats as the method to collect meaningful statistics 61 # we do not collect diskstats as the method to collect meaningful statistics
62 # for these fs types requires a bit more research. 62 # for these fs types requires a bit more research.
63 ############################################################################ 63 ############################################################################
64 for line in open("/proc/diskstats", "r"): 64 rdev="NoLogicalDevice"
65 if majordev == int(line.split()[0]) and minordev == int(line.split()[1]): 65 try:
66 rdev=line.split()[2] 66 for line in open("/proc/diskstats", "r"):
67 else: 67 if majordev == int(line.split()[0]) and minordev == int(line.split()[1]):
68 rdev="NoLogicalDevice" 68 rdev=line.split()[2]
69 file = open(bb.data.getVar('DEVFILE', e.data, True), "w") 69 except:
70 pass
71 file = open(e.data.getVar('DEVFILE', True), "w")
70 file.write(rdev) 72 file.write(rdev)
71 file.close() 73 file.close()
72 74
@@ -82,12 +84,15 @@ def get_diskstats(dev):
82 # For info on what these are, see kernel doc file iostats.txt 84 # For info on what these are, see kernel doc file iostats.txt
83 ############################################################################ 85 ############################################################################
84 DSTAT_KEYS = ['ReadsComp', 'ReadsMerged', 'SectRead', 'TimeReads', 'WritesComp', 'SectWrite', 'TimeWrite', 'IOinProgress', 'TimeIO', 'WTimeIO'] 86 DSTAT_KEYS = ['ReadsComp', 'ReadsMerged', 'SectRead', 'TimeReads', 'WritesComp', 'SectWrite', 'TimeWrite', 'IOinProgress', 'TimeIO', 'WTimeIO']
85 for x in open("/proc/diskstats", "r"): 87 try:
86 if dev in x: 88 for x in open("/proc/diskstats", "r"):
87 diskstats_val = x.rstrip().split()[4:] 89 if dev in x:
88 diskstats = dict(itertools.izip(DSTAT_KEYS, diskstats_val)) 90 diskstats_val = x.rstrip().split()[4:]
91 except IOError as e:
92 return
93 diskstats = dict(itertools.izip(DSTAT_KEYS, diskstats_val))
89 return diskstats 94 return diskstats
90 95
91def set_diskdata(var, dev, data): 96def set_diskdata(var, dev, data):
92 data.setVar(var, get_diskstats(dev)) 97 data.setVar(var, get_diskstats(dev))
93 98