summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/buildstats.bbclass4
-rw-r--r--meta/lib/buildstats.py22
2 files changed, 19 insertions, 7 deletions
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 9c0c37dcdd..c6b77e6a2a 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -204,11 +204,11 @@ python runqueue_stats () {
204 if system_stats: 204 if system_stats:
205 # Ensure that we sample at important events. 205 # Ensure that we sample at important events.
206 done = isinstance(e, bb.event.BuildCompleted) 206 done = isinstance(e, bb.event.BuildCompleted)
207 system_stats.sample(force=done) 207 system_stats.sample(e, force=done)
208 if done: 208 if done:
209 system_stats.close() 209 system_stats.close()
210 d.delVar('_buildstats_system_stats') 210 d.delVar('_buildstats_system_stats')
211} 211}
212 212
213addhandler runqueue_stats 213addhandler runqueue_stats
214runqueue_stats[eventmask] = "bb.runqueue.sceneQueueTaskStarted bb.runqueue.runQueueTaskStarted bb.event.HeartbeatEvent bb.event.BuildCompleted" 214runqueue_stats[eventmask] = "bb.runqueue.sceneQueueTaskStarted bb.runqueue.runQueueTaskStarted bb.event.HeartbeatEvent bb.event.BuildCompleted bb.event.MonitorDiskEvent"
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