How to make global variable with summary value

Michal Švamberg <[email protected]>
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <CAFgL0Wi0df3pOnEE4kW_KEgYaUBO94tSEwx2YF6=scZf4d2oQw@mail.gmail.com>
Hello all,
I know that is a very bad idea for cfengine but I want counting
modifications by cfengine. I prepared small testing example:

bundle common success_add(value) {
vars:
  "sum" string => eval("${sum} + ${value}", "math", "infix"),
    if => isvariable("sum");

  "sum" string => "${value}",
    unless => isvariable("sum");

reports:
  "success: add=${value}, total=${sum}";
}

bundle agent summary {
reports:
  "SUMMARY: ${success_add.sum}";
}

bundle agent __main__ {
methods:
  "add_100" usebundle => success_add("100");
  "add_010" usebundle => success_add("10");
  "add_001" usebundle => success_add("1");
  "summary";
}


I expect SUMMARY=111 but i get very different result:

R: success: add=100, total=400.000000
R: success: add=100, total=500.000000
R: success: add=100, total=600.000000
R: success: add=10, total=630.000000
R: success: add=10, total=640.000000
R: success: add=10, total=650.000000
R: success: add=1, total=653.000000
R: success: add=1, total=654.000000
R: success: add=1, total=655.000000
R: SUMMARY: 655.000000

OK, cfengine runs every bundle 3 times. Does there exist any solution
to get the total value 111? Why is the result 655 and not 666?

Thanks for any ideas.
Michal Svamberg

-- 
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/CAFgL0Wi0df3pOnEE4kW_KEgYaUBO94tSEwx2YF6%3DscZf4d2oQw%40mail.gmail.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.