From f065ac17d0031dca6309ddbff18c8792630de865 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 29 Nov 2016 17:47:45 +0100 Subject: monitordisk: add event The current disk usage is interesting and may be worth logging over time as part of the build statistics. Instead of re-implementing the code and the configuration option (BB_DISKMON_DIRS), the information gathered by monitordisk.py is made available to buildstats.bbclass via a new event. This has pros and cons: - there is already a useful default configuration for "interesting" directories - no code duplication - on the other hand, users cannot configure recording separately from monitoring (probably not that important) Signed-off-by: Patrick Ohly Signed-off-by: Richard Purdie --- lib/bb/event.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/bb/event.py') diff --git a/lib/bb/event.py b/lib/bb/event.py index cacbac8f5..549191475 100644 --- a/lib/bb/event.py +++ b/lib/bb/event.py @@ -451,6 +451,23 @@ class DiskFull(Event): self._free = freespace self._mountpoint = mountpoint +class DiskUsageSample: + def __init__(self, available_bytes, free_bytes, total_bytes): + # Number of bytes available to non-root processes. + self.available_bytes = available_bytes + # Number of bytes available to root processes. + self.free_bytes = free_bytes + # Total capacity of the volume. + self.total_bytes = total_bytes + +class MonitorDiskEvent(Event): + """If BB_DISKMON_DIRS is set, then this event gets triggered each time disk space is checked. + Provides information about devices that are getting monitored.""" + def __init__(self, disk_usage): + Event.__init__(self) + # hash of device root path -> DiskUsageSample + self.disk_usage = disk_usage + class NoProvider(Event): """No Provider for an Event""" -- cgit 1.2.3-korg