Skip to contentSkip to conversation

V2 Disk space monitoring

PATCH In review Robert Yang 3 participants 6 messages Jan 10, 2012

lore
Share & tools
lore
#0 lore raw

cover V2 Disk space monitoring

Changes of V2:
* Rebase the code to the up to date master branch

Here are the test info:
1) set the following variables in conf/local.conf for testing:
BB_DISKMON_DIRS = "${TMPDIR} ${DL_DIR} ${SSTATE_DIR} /home/lyang1" BB_DISKMON_MINSPACE = "200G"
BB_DISKMON_MININODES = "20M"
BB_DISKMON_INTERVAL = "30s"

The TMPDIR, DL_DIR and SSTATE_DIR are in the same disk(/dev/sdb4) in my build, so I added another direcotory /home/lyang1 to test the ability of monitoring multi mount points.

2) bitbake core-image-sato
WARNING: The free space of /dev/sdb5 is running low (25.915GB left)
WARNING: The free inode of /dev/sdb5 is running low (1788.202K left)
WARNING: The free space of /dev/sdb4 is running low (189.309GB left)
WARNING: The free inode of /dev/sdb4 is running low (18005.443K left)

3) Aalso have tested about the following items:
a) Use ctrl-c to stop the monitor
b) The monitor should stop when the build stops
c) Test the space unit G, B, K(case in-sensitive) and the time unit h, m, s(case-sensitive)

// Robert

The following changes since commit 468998cddbe1a803096c9b357e1b5daa3b7e8c2e:

command.py: add parseConfigurationFiles API (2012-01-06 16:01:44 +0000)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib robert/disk-space-monitor
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=robert/disk-space-monitor

Robert Yang (2):
Disk space monitoring
Add config sample for disk space monitoring

 bitbake/bin/bitbake               |   13 +++
 bitbake/lib/bb/monitordisk.py     |  153 +++++++++++++++++++++++++++++++++++++
 meta-yocto/conf/local.conf.sample |   28 +++++++
 3 files changed, 194 insertions(+), 0 deletions(-)
 create mode 100644 bitbake/lib/bb/monitordisk.py
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/2 V2 Disk space monitoring

Monitor disk availability and warn the user when the free disk space or amount of free inode is running low, it is enabled when BB_DISKMON_DIRS is set.

* Variable meanings(from meta-yocto/conf/local.conf.sample):

  # Set the directories to monitor for disk usage, if more than one
  # directories are in the same device, then only one directory would be
  # warned since the monitor is based on the device.
  #
  BB_DISKMON_DIRS = "${TMPDIR} ${DL_DIR} ${SSTATE_DIR}"
  #
  # Set the minimum amount of disk space to warn, the unit can be G,
  # M or K, but do not use GB, MB or KB (B is not needed).
  # The default vaule is 1G if not set.
  #
  #BB_DISKMON_MINSPACE = "1G"
  #
  # Set the minimum amount of inodes to warn, the unit can be G, M or K.
  # The default value is 1K if not set.
  #
  #BB_DISKMON_MININODES = "1K"
  #
  # Set the monitor frequency, the unit can be h(hour), m(minute) or
  # s(second), when no unit is specified, the default unit is s(second),
  # for example, "60" means 60 seconds.
  # The default value is 60s if not set.
  #
  #BB_DISKMON_INTERVAL = "60s"

* Problems:

1) The disk space monitor is running in a sub process of bin/bitbake, so it can't use the same logger as bitbake(or I don't know how to use it, I've tried to use the logger.warn('some information'), but it would print nothing in the subprocess), another solution maybe use an independent logger in the subprocess, but it seems that it doesn't worth because of the two reasons:
a) The logger of bin/bitbake can't control the monitor's independent logger
b) The monitor doesn't need print many things

It would be great if anyone could give me more instructions.

2) The code is placed in the new file lib/bb/monitordisk.py, since it seems that it is more independent.

[YOCTO #1589]
---
 bitbake/bin/bitbake           |   13 ++++
 bitbake/lib/bb/monitordisk.py |  153 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+), 0 deletions(-)
 create mode 100644 bitbake/lib/bb/monitordisk.py
bitbake/bin/bitbake +13 -0
index c2e6822..6bc34a4 100755
@@ -39,6 +39,8 @@ import bb.msg
 from bb import cooker
 from bb import ui
 from bb import server
+from bb import monitordisk
+from multiprocessing import Process
 
 __version__ = "1.15.0"
 logger = logging.getLogger("BitBake")
@@ -223,6 +225,13 @@ Default BBFILES are the .bb files in the current directory.""")
     server.saveConnectionDetails()
     server.detach(cooker_logfile)
 
+    # For disk space monitor
+    diskMonDirs = cooker.configuration.data.getVar("BB_DISKMON_DIRS", 1)
+    if diskMonDirs:
+        monitorProcess = Process(target=monitordisk.monitorDiskSpace, \
+            args=(diskMonDirs, cooker.configuration.data))
+        monitorProcess.start()
+
     # Should no longer need to ever reference cooker
     del cooker
 
@@ -237,9 +246,13 @@ Default BBFILES are the .bb files in the current directory.""")
         finally:
             bb.event.ui_queue = []
             server_connection.terminate()
+            # Stop the disk space monitor
+            if diskMonDirs:
+                monitorProcess.terminate()
     else:
         print("server address: %s, server port: %s" % (server.serverinfo.host, server.serverinfo.port))
 
+
     return 1
 
 if __name__ == "__main__":
bitbake/lib/bb/monitordisk.py new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#4 lore raw

PATCH 2/2 V2 Add config sample for disk space monitoring

In reply to Robert Yang

Add config sample for disk space monitoring to
meta-yocto/conf/local.conf.sample

[YOCTO #1589]
---
 meta-yocto/conf/local.conf.sample |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
meta-yocto/conf/local.conf.sample +28 -0
index 38507e3..c82cb7e 100644
@@ -224,3 +224,31 @@ PATCHRESOLVE = "noop"
 # track the version of this file when it was generated. This can safely be ignored if
 # this doesn't mean anything to you.
 CONF_VERSION = "1"
+
+#
+# Disk space monitor, warning when the disk space or the amount of inode
+# is running low, it is enabled when BB_DISKMON_DIRS is set.
+#
+# Set the directories to monitor for disk usage, if more than one
+# directories are in the same device, then only one directory would be
+# warned since the monitor is based on the device.
+#
+BB_DISKMON_DIRS = "${TMPDIR} ${DL_DIR} ${SSTATE_DIR}"
+#
+# Set the minimum amount of disk space to warn, the unit can be G,
+# M or K, but do not use GB, MB or KB (B is not needed).
+# The default vaule is 1G if not set.
+#
+#BB_DISKMON_MINSPACE = "1G"
+#
+# Set the minimum amount of inodes to warn, the unit can be G, M or K.
+# The default value is 1K if not set.
+#
+#BB_DISKMON_MININODES = "1K"
+#
+# Set the monitor frequency, the unit can be h(hour), m(minute) or
+# s(second), when no unit is specified, the default unit is s(second),
+# for example, "60" means 60 seconds.
+# The default value is 60s if not set.
+#
+#BB_DISKMON_INTERVAL = "60s"
Signature · 1 line
1.7.4.1
#5 lore raw
In reply to Robert Yang
Quoted 17 lines · Robert Yang

Here are the test info:
1) set the following variables in conf/local.conf for testing:
  BB_DISKMON_DIRS = "${TMPDIR} ${DL_DIR} ${SSTATE_DIR} /home/lyang1" BB_DISKMON_MINSPACE = "200G"
  BB_DISKMON_MININODES = "20M"
  BB_DISKMON_INTERVAL = "30s"

  The TMPDIR, DL_DIR and SSTATE_DIR are in the same disk(/dev/sdb4) in my build, so I added another direcotory /home/lyang1 to test the ability of monitoring multi mount points.

2) bitbake core-image-sato
  WARNING: The free space of /dev/sdb5 is running low (25.915GB left)
  WARNING: The free inode of /dev/sdb5 is running low (1788.202K left)
  WARNING: The free space of /dev/sdb4 is running low (189.309GB left)
  WARNING: The free inode of /dev/sdb4 is running low (18005.443K left)

Quoted 5 lines

3) Aalso have tested about the following items:
  a) Use ctrl-c to stop the monitor
  b) The monitor should stop when the build stops
  c) Test the space unit G, B, K(case in-sensitive) and the time unit h, m, s(case-sensitive)

I would think it'd be more useful to be able to specify the thresholds on a per-mountpoint or per-path basis. The space needed by sstate, downloads, and the rest of the build can be quite different. Further, the space requirements for DL_DIR and sstate both are dependent upon the current contents of the directories, as if we already have all our downloads, the free space there isn't much of a concern..

Signature · 1 line
Christopher Larson
#2 lore raw
In reply to Robert Yang
Quoted 12 lines · Robert Yang

* Problems:

1) The disk space monitor is running in a sub process of bin/bitbake, so it can't use the same logger as bitbake(or I don't know how to use it, I've tried to use the logger.warn('some information'), but it would print nothing in the subprocess), another solution maybe use an independent logger in the subprocess, but it seems that it doesn't worth because of the two reasons:
a) The logger of bin/bitbake can't control the monitor's independent logger
b) The monitor doesn't need print many things

Quoted 1 line

It would be great if anyone could give me more instructions.

This is an issue unfortunately since its fine to have the warnings about low space but its not much use unless bitbake can act on the warnings somehow (stop executing more tasks for example).

I agree with Chris' comments about being able to specify the warning threshold per directory being monitored too.

So I think before this can merge its going to need some further work. I can't give pointers to the right way to send log messages from the subprocess right at the moment. Perhaps you can insert yourself as an "idle" task into bitbake's "main loop" instead of running as a subprocess? This would also make it simpler to stop executing more tasks. There probably should be a way for the user to choose "immediately abort, no new tasks, show warning" as the options for running out of space.

Cheers,

Richard

#3 lore raw
Quoted 11 lines · Richard Purdie
Quoted 10 lines · Robert Yang

* Problems:

  1) The disk space monitor is running in a sub process of bin/bitbake, so it can't use the same logger as bitbake(or I don't know how to use it, I've tried to use the logger.warn('some information'), but it would print nothing in the subprocess), another solution maybe use an independent logger in the subprocess, but it seems that it doesn't worth because of the two reasons:
     a) The logger of bin/bitbake can't control the monitor's independent logger

If the monitor spawns from the bitbake server process, then it can send log messages to the standard bitbake UI process, and it wouldn't need its own log handling.

Signature · 1 line
Christopher Larson