Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 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

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

reports:
    ohno::
       "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

 
discard

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.