1

I'm trying to execute a scheduled task on a large-ish pool of virtual servers, but I want to minimize the resulting performance impact on the hypervisor, ideally executing it on one server at a time.

Think something like this:

    Hr07.Min01.host_1::
        "scheduled_service_restart"    usebundle   =>  service_restart;
    Hr07.Min02.host_2::
        "scheduled_service_restart"    usebundle   =>  service_restart;
    Hr07.Min03.host_3::
        "scheduled_service_restart"    usebundle   =>  service_restart;
    ...

Now, this works; but the list will grow significantly, and isn't exactly pretty to look at.

Can I match the hostname sequence number (or sequence number of any general class) against the integer in the MinXY hardclass somehow?

lubomir.brindza
  • 256
  • 3
  • 10

1 Answers1

1

I would not recommend using the 1 minute resolution classes like Min01 unless you are running the agent on a 1 minute interval. That class will only be defined during that one minute. By default the agent runs every 5 minutes, and even with large policy sets a complete policy run usually completes within a minute.

You might want to take a look at the splayclass function. You can define a class deterministically over an hourly or daily period. For example:

bundle agent example
{
  classes:
    Hr07::
      "service_restart"
        expression => splayclass("$(sys.fqhost)", "hourly"),
        comment => "So that we only perform restarts during the 7 oclock 
                    hour, and so that not all hosts restart at the same time 
                    we splay the restart class over an hour. Each host will 
                    define some 5 minute time slot during the hour.";

  methods:
    service_restart::
      "scheduled_service_restart" usebundle => service_restart;
}

#cfengine on irc.freenode.net and the help-cfengine are also great places to ask CFEngine related questions.

Nick Anderson
  • 679
  • 2
  • 5
  • 11