* [PATCH] buildstats: tolerate absence of /proc/diskstats
@ 2012-01-16 1:11 Jean-François Dagenais
2012-01-17 20:58 ` Saul Wold
0 siblings, 1 reply; 2+ messages in thread
From: Jean-François Dagenais @ 2012-01-16 1:11 UTC (permalink / raw)
To: poky; +Cc: roym, Jean-François Dagenais, marc.ferland
From: Jean-François Dagenais <dagenaisj@sonatest.com>
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.
Signed-off-by: Jean-François Dagenais <jeff.dagenais@gmail.com>
---
meta/classes/buildstats.bbclass | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 4cd8fe6..9690a04 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -61,11 +61,13 @@ 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"
+ 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))
--
1.7.8.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] buildstats: tolerate absence of /proc/diskstats
2012-01-16 1:11 [PATCH] buildstats: tolerate absence of /proc/diskstats Jean-François Dagenais
@ 2012-01-17 20:58 ` Saul Wold
0 siblings, 0 replies; 2+ messages in thread
From: Saul Wold @ 2012-01-17 20:58 UTC (permalink / raw)
To: Jean-François Dagenais
Cc: marc.ferland, Jean-François Dagenais, poky, roym
On 01/15/2012 05:11 PM, Jean-François Dagenais wrote:
> From: Jean-François Dagenais<dagenaisj@sonatest.com>
>
> 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.
>
> Signed-off-by: Jean-François Dagenais<jeff.dagenais@gmail.com>
> ---
> meta/classes/buildstats.bbclass | 25 +++++++++++++++----------
> 1 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
> index 4cd8fe6..9690a04 100644
> --- a/meta/classes/buildstats.bbclass
> +++ b/meta/classes/buildstats.bbclass
> @@ -61,11 +61,13 @@ 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"
> + 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))
>
Merged into OE-Core
For future reference, please send patches for the meta layer to
openembedded-core@lists.openembedded.org, as the meta layer is really
OE-Core
Thanks
Sau!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-17 20:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-16 1:11 [PATCH] buildstats: tolerate absence of /proc/diskstats Jean-François Dagenais
2012-01-17 20:58 ` Saul Wold
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.