diff options
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/event.py | 17 | ||||
-rw-r--r-- | bitbake/lib/bb/monitordisk.py | 8 |
2 files changed, 25 insertions, 0 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index cacbac8f56..5491914752 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -451,6 +451,23 @@ class DiskFull(Event): | |||
451 | self._free = freespace | 451 | self._free = freespace |
452 | self._mountpoint = mountpoint | 452 | self._mountpoint = mountpoint |
453 | 453 | ||
454 | class DiskUsageSample: | ||
455 | def __init__(self, available_bytes, free_bytes, total_bytes): | ||
456 | # Number of bytes available to non-root processes. | ||
457 | self.available_bytes = available_bytes | ||
458 | # Number of bytes available to root processes. | ||
459 | self.free_bytes = free_bytes | ||
460 | # Total capacity of the volume. | ||
461 | self.total_bytes = total_bytes | ||
462 | |||
463 | class MonitorDiskEvent(Event): | ||
464 | """If BB_DISKMON_DIRS is set, then this event gets triggered each time disk space is checked. | ||
465 | Provides information about devices that are getting monitored.""" | ||
466 | def __init__(self, disk_usage): | ||
467 | Event.__init__(self) | ||
468 | # hash of device root path -> DiskUsageSample | ||
469 | self.disk_usage = disk_usage | ||
470 | |||
454 | class NoProvider(Event): | 471 | class NoProvider(Event): |
455 | """No Provider for an Event""" | 472 | """No Provider for an Event""" |
456 | 473 | ||
diff --git a/bitbake/lib/bb/monitordisk.py b/bitbake/lib/bb/monitordisk.py index d3d2106841..833cd3d344 100644 --- a/bitbake/lib/bb/monitordisk.py +++ b/bitbake/lib/bb/monitordisk.py | |||
@@ -205,6 +205,7 @@ class diskMonitor: | |||
205 | """ Take action for the monitor """ | 205 | """ Take action for the monitor """ |
206 | 206 | ||
207 | if self.enableMonitor: | 207 | if self.enableMonitor: |
208 | diskUsage = {} | ||
208 | for k, attributes in self.devDict.items(): | 209 | for k, attributes in self.devDict.items(): |
209 | path, action = k | 210 | path, action = k |
210 | dev, minSpace, minInode = attributes | 211 | dev, minSpace, minInode = attributes |
@@ -214,6 +215,11 @@ class diskMonitor: | |||
214 | # The available free space, integer number | 215 | # The available free space, integer number |
215 | freeSpace = st.f_bavail * st.f_frsize | 216 | freeSpace = st.f_bavail * st.f_frsize |
216 | 217 | ||
218 | # Send all relevant information in the event. | ||
219 | freeSpaceRoot = st.f_bfree * st.f_frsize | ||
220 | totalSpace = st.f_blocks * st.f_frsize | ||
221 | diskUsage[dev] = bb.event.DiskUsageSample(freeSpace, freeSpaceRoot, totalSpace) | ||
222 | |||
217 | if minSpace and freeSpace < minSpace: | 223 | if minSpace and freeSpace < minSpace: |
218 | # Always show warning, the self.checked would always be False if the action is WARN | 224 | # Always show warning, the self.checked would always be False if the action is WARN |
219 | if self.preFreeS[k] == 0 or self.preFreeS[k] - freeSpace > self.spaceInterval and not self.checked[k]: | 225 | if self.preFreeS[k] == 0 or self.preFreeS[k] - freeSpace > self.spaceInterval and not self.checked[k]: |
@@ -257,4 +263,6 @@ class diskMonitor: | |||
257 | self.checked[k] = True | 263 | self.checked[k] = True |
258 | rq.finish_runqueue(True) | 264 | rq.finish_runqueue(True) |
259 | bb.event.fire(bb.event.DiskFull(dev, 'inode', freeInode, path), self.configuration) | 265 | bb.event.fire(bb.event.DiskFull(dev, 'inode', freeInode, path), self.configuration) |
266 | |||
267 | bb.event.fire(bb.event.MonitorDiskEvent(diskUsage), self.configuration) | ||
260 | return | 268 | return |