summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-11-30 10:50:06 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-07 10:37:59 +0000
commit25a5536a6e9ca648f881e1288a281f4f679e2bec (patch)
treec81f7afdf766fc9808c4feee772d5c60c637461e /meta/lib
parent1416bb3244696d554431cf5549c59575e9a2c045 (diff)
downloadpoky-25a5536a6e9ca648f881e1288a281f4f679e2bec.tar.gz
buildstats: record disk space usage
Hooks into the new monitordisk.py event and records the used space for each volume. That is probably the only relevant value when it comes to visualizing the build and recording more would only increase disk usage. (From OE-Core rev: 21a5b569370f47cc02291e1d8b76fe43faa04ea6) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/buildstats.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/meta/lib/buildstats.py b/meta/lib/buildstats.py
index 8ce4112c2d..7c8b3521a7 100644
--- a/meta/lib/buildstats.py
+++ b/meta/lib/buildstats.py
@@ -3,6 +3,7 @@
3# like open log files and the time of the last sampling. 3# like open log files and the time of the last sampling.
4 4
5import time 5import time
6import bb.event
6 7
7class SystemStats: 8class SystemStats:
8 def __init__(self, d): 9 def __init__(self, d):
@@ -19,8 +20,10 @@ class SystemStats:
19 # concurrently. 20 # concurrently.
20 self.proc_files.append((filename, 21 self.proc_files.append((filename,
21 open(os.path.join(bsdir, 'proc_%s.log' % filename), 'ab'))) 22 open(os.path.join(bsdir, 'proc_%s.log' % filename), 'ab')))
22 # Last time that we sampled data. 23 self.monitor_disk = open(os.path.join(bsdir, 'monitor_disk.log'), 'ab')
23 self.last = 0 24 # Last time that we sampled /proc data resp. recorded disk monitoring data.
25 self.last_proc = 0
26 self.last_disk_monitor = 0
24 # Minimum number of seconds between recording a sample. This 27 # Minimum number of seconds between recording a sample. This
25 # becames relevant when we get called very often while many 28 # becames relevant when we get called very often while many
26 # short tasks get started. Sampling during quiet periods 29 # short tasks get started. Sampling during quiet periods
@@ -32,9 +35,9 @@ class SystemStats:
32 for _, output, _ in self.proc_files: 35 for _, output, _ in self.proc_files:
33 output.close() 36 output.close()
34 37
35 def sample(self, force): 38 def sample(self, event, force):
36 now = time.time() 39 now = time.time()
37 if (now - self.last > self.min_seconds) or force: 40 if (now - self.last_proc > self.min_seconds) or force:
38 for filename, output in self.proc_files: 41 for filename, output in self.proc_files:
39 with open(os.path.join('/proc', filename), 'rb') as input: 42 with open(os.path.join('/proc', filename), 'rb') as input:
40 data = input.read() 43 data = input.read()
@@ -44,4 +47,13 @@ class SystemStats:
44 ('%.0f\n' % now).encode('ascii') + 47 ('%.0f\n' % now).encode('ascii') +
45 data + 48 data +
46 b'\n') 49 b'\n')
47 self.last = now 50 self.last_proc = now
51
52 if isinstance(event, bb.event.MonitorDiskEvent) and \
53 ((now - self.last_disk_monitor > self.min_seconds) or force):
54 os.write(self.monitor_disk.fileno(),
55 ('%.0f\n' % now).encode('ascii') +
56 ''.join(['%s: %d\n' % (dev, sample.total_bytes - sample.free_bytes)
57 for dev, sample in event.disk_usage.items()]).encode('ascii') +
58 b'\n')
59 self.last_disk_monitor = now