2

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

2 Answers 2

3

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
{
storage:
    "/" volume => low_disk_space;

reports:
    ohno::
       "Oh noes!";
}

body volume low_disk_space {
        freespace => "10%";
        repair_failed => { "ohno" };
}
1
  • Indeed, the storage is a better solution than mine. Mar 19, 2010 at 20:41
2

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 {
    vars:
        "free" int => diskfree("/home");
        "min_free_space" int  => "200000000";
    classes:
        "not_enough_size" expression => isgreaterthan("$(min_free_space)", "$(free)");

    reports:
        not_enough_size::
            "There is not enough space left on /home";
}

Regards

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .