Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to set a class in cfengine3 so I can perform an action if the disk is almost full.

share|improve this question

You can use the function diskfree that return the available space on the partition

Here is a simple example (yes, I have a lot of free space) :

body common control {
    bundlesequence => { "test_free_space" };

bundle agent test_free_space {
        "free" int => diskfree("/home");
        "min_free_space" int  => "200000000";
        "not_enough_size" expression => isgreaterthan("$(min_free_space)", "$(free)");

            "There is not enough space left on /home";


share|improve this answer
up vote 2 down vote accepted

Here's how I did it. The repair_failed mnemonic doesn't really fit the "we detected there was less free disk space than you wanted" since it attempts no repair, but it seems to be the way to add a class as a result. It gives a perfectly fine explanation of the free disk space without the extra ohno class, but eventually I want to clear temp directories, vacuum databases, etc. as a reaction to the condition...

bundle agent storage
    "/" volume => low_disk_space;

       "Oh noes!";

body volume low_disk_space {
        freespace => "10%";
        repair_failed => { "ohno" };
share|improve this answer
Indeed, the storage is a better solution than mine. – Nicolas Charles Mar 19 '10 at 20:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.