summaryrefslogtreecommitdiffstats
path: root/meta/classes/buildstats.bbclass
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-16 12:24:57 +0000
commitf17c9d3b3832d65543e582dec5d5518e41f08772 (patch)
tree16ae48254ff3d7427919eecff83c4e0c6da002e6 /meta/classes/buildstats.bbclass
parent18fe75dd84a40ed3e76f20f4ba5419d3167330e6 (diff)
downloadpoky-f17c9d3b3832d65543e582dec5d5518e41f08772.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) Signed-off-by: Jean-François Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/buildstats.bbclass')
-rw-r--r--meta/classes/buildstats.bbclass25
1 files changed, 15 insertions, 10 deletions
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 4cd8fe6936..9690a04100 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -61,11 +61,13 @@ 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 except:
70 pass
69 file = open(e.data.getVar('DEVFILE', True), "w") 71 file = open(e.data.getVar('DEVFILE', True), "w")
70 file.write(rdev) 72 file.write(rdev)
71 file.close() 73 file.close()
@@ -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