Re: How to make global variable with summary value

Nick Anderson <[email protected]>
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
Why is this not in my inbox?

On Thursday, August 5, 2021 at 7:13:15 AM UTC-5 [email protected] wrote:

> 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/eaff4048-6ada-4a58-82c5-ee1dba800492n%40googlegroups.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.