cf-profile.pl rocks!

95 views
Skip to first unread message

Aleksey Tsalolikhin

unread,
Sep 10, 2015, 11:46:27 PM9/10/15
to help-cfengine, jonh...@cfengineers.net
Hi.  I just want to put a plug in for Jon Hernik's cf-profile.pl (https://github.com/cfengineers-net/cf-profile)

It uses perl Time::HiRes to analyze verbose output from cf-agent and then gives the Execution Tree (which bundle calls which, which is something I was looking for earlier) complete with how long (wall clock time) each bundle takes to execute.  Very useful!! I cut my policy execution time by nearly a quarter thanks to identifying two bundles that were taking seconds to execute and fixing those.  Thanks, Jon Henrik!

It's a nice alternative to cf-profiler, which is also great.  (Thanks, Lois!)

--
Aleksey Tsalolikhin
CFEngine Training & Consulting
Vertical Sysadmin, Inc.

Christian Linden

unread,
Sep 11, 2015, 5:20:08 AM9/11/15
to help-cfengine, jonh...@cfengineers.net
Does it work with the same benchmark values found in the mission portal?

Chris

Marco Marongiu

unread,
Sep 11, 2015, 6:04:31 AM9/11/15
to help-c...@googlegroups.com
On 11/09/15 05:46, Aleksey Tsalolikhin wrote:
> Hi. I just want to put a plug in for Jon Hernik's cf-profile.pl

Interesting!

I get some warnings and, below them, some wrong values. Does it happen
to you, too?

E.g.:


> |----------------> Bundle install_rsyslog:
> | Elapsed: 0.14857 s
> |
> Use of uninitialized value in subtraction (-) at /usr/local/bin/cf-profile.pl line 83, <STDIN> line 81176.
> Use of uninitialized value in subtraction (-) at /usr/local/bin/cf-profile.pl line 85, <STDIN> line 81176.
> Use of uninitialized value in repeat (x) at /usr/local/bin/cf-profile.pl line 86, <STDIN> line 81176.
> Use of uninitialized value in repeat (x) at /usr/local/bin/cf-profile.pl line 88, <STDIN> line 81176.
> |> Bundle edit_rsyslog_config:
> |Elapsed: -1441965603.04161 s
> |
> Use of uninitialized value in subtraction (-) at /usr/local/bin/cf-profile.pl line 83, <STDIN> line 81176.
> Use of uninitialized value in subtraction (-) at /usr/local/bin/cf-profile.pl line 85, <STDIN> line 81176.
> Use of uninitialized value in repeat (x) at /usr/local/bin/cf-profile.pl line 86, <STDIN> line 81176.
> Use of uninitialized value in repeat (x) at /usr/local/bin/cf-profile.pl line 88, <STDIN> line 81176.
> |> Bundle temp_cf_bundle__var_cfengine_inputs_services_rsyslog_templates_rsyslog_config_tmpl:
> |Elapsed: -1441965603.19442 s
> |

It's CFE 3.6.6 and the command line is

cf-agent -v --legacy-output | cf-profile.pl -a

Ciao!
-- bronto

Aleksey Tsalolikhin

unread,
Sep 11, 2015, 8:25:34 AM9/11/15
to Marco Marongiu, help-cfengine
On Fri, Sep 11, 2015 at 3:04 AM, Marco Marongiu <bront...@gmail.com> wrote:

I get some warnings and, below them, some wrong values. Does it happen
to you, too?


Nope!  I get clean output with 3.6.6, except the Summary section at the bottom is blank, and I opened an issue about that.

Do you have the Time::HiRes CPAN module?
 
E.g.:




It's CFE 3.6.6 and the command line is

cf-agent -v --legacy-output | cf-profile.pl -a


That's the same command line I used, bronto.

Best,

Aleksey Tsalolikhin

unread,
Sep 11, 2015, 8:28:25 AM9/11/15
to Christian Linden, help-cfengine, jonh...@cfengineers.net
On Fri, Sep 11, 2015 at 2:20 AM, Christian Linden <lindo...@gmail.com> wrote:
Does it work with the same benchmark values found in the mission portal?

I'll have to review the  "Benchmarks" report; I remember it has the overall time for promises.cf but I don't remember if it i has the times for each bundle.  And it certainly doesn't have the Execution Tree!
 

Nick Anderson

unread,
Sep 11, 2015, 8:58:55 AM9/11/15
to help-c...@googlegroups.com
On 09/11/2015 07:28 AM, Aleksey Tsalolikhin wrote:
> I'll have to review the "Benchmarks" report; I remember it has the overall
> time for promises.cf but I don't remember if it i has the times for each
> bundle. And it certainly doesn't have the Execution Tree!

You can add individual promises to the benchmarks report by attaching a
measurement_class to them.

https://docs.cfengine.com/latest/reference-promise-types.html#measurement_class

"Some Thing"
handle => "some_thing_my_bundle"
usebundle => my_bundle,
measure_promise_time("time_some_thing_my_bundle");

https://github.com/cfengine/masterfiles/blob/3.7.1/lib/3.7/common.cf#L91-L97

Marco Marongiu

unread,
Sep 11, 2015, 9:46:13 AM9/11/15
to Aleksey Tsalolikhin, help-cfengine
On 11/09/15 14:25, Aleksey Tsalolikhin wrote:
> I get some warnings and, below them, some wrong values. Does it happen
> to you, too?
>
>
> Nope! I get clean output with 3.6.6, except the Summary section at the
> bottom is blank, and I opened an issue about that.

Crap...


> Do you have the Time::HiRes CPAN module?

Sure thing!

root@cf-test-v05:/var/cfengine/inputs# perl -MTime::HiRes -e exit
root@cf-test-v05:/var/cfengine/inputs# perl -MNon::Existent -e exit
Can't locate Non/Existent.pm in @INC (you may need to install the
Non::Existent module) (@INC contains: /etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2
/usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.20 /usr/share/perl/5.20
/usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.
root@cf-test-v05:/var/cfengine/inputs#



> It's CFE 3.6.6 and the command line is
>
> cf-agent -v --legacy-output | cf-profile.pl <http://cf-profile.pl> -a
>
>
> That's the same command line I used, bronto.

Double crap :-(

Thanks
-- M

Aleksey Tsalolikhin

unread,
Sep 11, 2015, 1:54:54 PM9/11/15
to Marco Marongiu, help-cfengine

Nick Anderson

unread,
Sep 11, 2015, 1:55:51 PM9/11/15
to Aleksey Tsalolikhin, Marco Marongiu, help-cfengine
working link: https://github.com/cfengineers-net/cf-profile/issues

On 09/11/2015 12:54 PM, Aleksey Tsalolikhin wrote:
> Here you go... https://github./cfengineers-net/cf-profile/issues =)

Aleksey Tsalolikhin

unread,
Sep 12, 2015, 4:56:40 PM9/12/15
to Nick Anderson, help-cfengine
Ok, looked into it, seems to be a "new in 3.7" thing, and you trigger it through an action attribute.  Thanks!

"Some Thing"
  ...
  action => measure_promise_time("time_some_thing_my_bundle");


--
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 help-cfengin...@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.

in...@cfengineers.net

unread,
Nov 5, 2015, 7:04:59 AM11/5/15
to help-cfengine
Hi all,

I have finally been able to make cf-profile.pl compatible with the 3.7 verbose output. Sorry for the delay, I have been quite busy the past months. Also tagged it for release 0.1.0.


Please register any issues you might come across here: https://github.com/cfengineers-net/cf-profile/issues

Hope you will find it useful :)

With regards,

Jon Henrik Bjørnstad

Aleksey Tsalolikhin

unread,
Apr 17, 2017, 11:44:12 AM4/17/17
to help-cfengine, in...@cfengineers.net


On Thursday, November 5, 2015 at 4:04:59 AM UTC-8, in...@cfengineers.net wrote:
Hi all,

I have finally been able to make cf-profile.pl compatible with the 3.7 verbose output. Sorry for the delay, I have been quite busy the past months. Also tagged it for release 0.1.0.


Please register any issues you might come across here: https://github.com/cfengineers-net/cf-profile/issues

Hope you will find it useful :)

With regards,

Jon Henrik Bjørnstad

Dear Jon Henrik,

I tried to use https://github.com/cfengineers-net/cf-profile/blob/master/cf-profile.pl with 3.7.3.  I ran it as instructed in the README:

```
 cf-agent -v --legacy-output | ./cf-profile.pl -a
```

and I got the error message from cf-agent that it does not know the "legacy-output" option.


Then I dug up this thread and tried removing "legacy-output" and it worked.  So thanks for keeping cf-profile.pl up to date, really appreciate it!!

Is that the intended usage?  If so I can send a merge request for the README if you'd like.  =)

Best,
Aleksey
Reply all
Reply to author
Forward
0 new messages