Skip to content

Instantly share code, notes, and snippets.

@TJM
Last active August 5, 2019 22:14
Show Gist options
  • Save TJM/0d85fa22e6f1f1adc401f1408654c371 to your computer and use it in GitHub Desktop.
Save TJM/0d85fa22e6f1f1adc401f1408654c371 to your computer and use it in GitHub Desktop.
Average Puppet Catalog compile time
awk '/Compiled static catalog for/ { x=$(NF-1); sum+=x; total++ }; END { print "Average Compile Time: " sum / total }' /var/log/puppetlabs/puppetserver/puppetserver.log
# USAGE: awk [-v host=(CERTNAME)] [-v ignore=2] -f compile_time.awk /var/log/puppetlabs/puppetserver/puppetserver.log
BEGIN {
min=999
}
/Compiled static catalog for/ && $10 ~ host {
x=$(NF-1)
if (x>ignore) { # Exclude agent only runs?
sum+=x
total++
if (x<min) {min=x; min_host=$10}
if (x>max) {max=x; max_host=$10}
if (x>60) { print $0 }
} else {
excl++
}
}
END {
print "Puppet Catalog Compile Time Stats:"
print "Average: " sum / total " (" total " runs)"
print "Minimum: " min " (" min_host ")"
print "Maximum: " max " (" max_host ")"
if (excl>0) { print "Excluded: " excl " runs (ignored)" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment