Imagine having the power to identify the exact lines of your CFEngine policy that are slowing down your executions. In this episode, we’ll guide you through the art of profiling CFEngine policy for improved performance.
In Episode 30 of “The agent is in,” Nick and team dives into the topic of profiling CFEngine policy. We explore tools and techniques to identify performance bottlenecks and optimize CFEngine deployments. The episode covers the following main points:
-
Introduction to
cf-profile
: A useful tool for identifying long-running bundles in CFEngine policy.cf-profile
analyzes the verbose log messages and provides a summary of the most time-consuming bundles. -
Using
cf-profile
: Demonstration of how to install and usecf-profile
interactively withcf-agent
. By runningcf-profile
with the execution tree and summary options, users can get a high-level overview of bundle execution time and identify areas that require further investigation. -
Fine-Grained Analysis: To dig deeper into individual promises within a bundle using the
timestamp
option ofcf-agent
. This allows users to track the execution time of each promise and pinpoint any performance issues. -
Profiling in CFEngine Enterprise: For CFEngine Enterprise users, the benchmarks table, provides execution time and standard deviation metrics. Nick explains how to access this table through the Mission portal and highlight the usefulness of attaching an
action
body with themeasurement_class
to measure specific promises. -
Demonstrating Custom Measurement: Nick shows an example of attaching an
action
body using themeasurement_class
attribute on a command’s promise and demonstrates how the measurement appears in the benchmarks table.
The episode caters to both new and experienced CFEngine users, providing tips and tools for analyzing and optimizing CFEngine policies.
Video
The video recording is available on YouTube:
Links
- Connect on LinkedIn w/ Cody or Nick
cf-profile
https://github.com/cfengine/core/tree/master/contrib/cf-profile- All Episodes
Notes
cf-profile
Provides high level summary of execution time in policy surfacing the bundles in
which the most time was spent. Find it in contrib/cf-profile
of the core
repository.
curl -s https://raw.githubusercontent.com/cfengine/core/master/contrib/cf-profile/cf-profile.pl --output /var/cfengine/bin/cf-profile
chmod 755 /var/cfengine/bin/cf-profile
cf-agent -Kv | /var/cfengine/bin/cf-profile -t -s
Note: The script requires perl
, and the POSIX
, Time::HiRes
, Data::Dumper
, and
Getopt::Std
modules.
--timestamp
options adds a timestamp to CFEngine logs
Useful for digging down into the execution time of individual promises.
cf-agent -Kv --timestamp
Note: it does not prefix lines emitted by reports
promises with a timestamp.
CFEngine Enterprise benchmarks table
Provides last, average, and standard deviation for execution times of various
things, including the Agent execution time per policy entry as well as the
promise execution time for any promise using an action
body with the
measurement_class
attribute defined.
body action measure_promise_time(identifier)
# @brief Performance will be measured and recorded under identifier
#
# @param identifier Measurement name.
{
measurement_class => "$(identifier)";
}
commands:
"sleep $(i)"
inform => "false",
contain => in_shell,
handle => "bundle_agent_two_sleep",
action => measure_promise_time("measure_my_command_that_is_slow");
Post show discussion
At the end of every webinar, we stop the recording for a nice and relaxed, off-the-record chat with attendees. Join the next webinar to not miss this discussion.
Config Management Camp CFP is open
- Don’t forget to submit your talks!
- If you can help sponsor this free event, please do.
Where is the CFEngine Merch Shop?
Need some CFEngine swag? Contact us.
History of CFEngine & differences in level of publicity with other tools
We discussed the history of CFEngine, covering the software, the company (now Northern.tech), user personalities (both individual and organization), as well as differences in company strategy in comparison to other products.