This repository has been archived on 2025-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
Files
puppet/files/ganglia/.svn/text-base/puppetmaster_compiletime.rb.svn-base
2013-02-02 14:35:50 +01:00

21 lines
880 B
Ruby

#!/usr/bin/env ruby
# $Id$
# returns the mem usage of a given process
gmetric = %x{which gmetric}.chomp
exit 0 unless gmetric != ""
gmetric = "#{gmetric} --type=float --units=seconds --slope=positive --tmax=3600 --dmax=300000"
debug = ARGV[0].nil? ? false : true
test = debug ? "-t ": ""
puts "DEBUG" if debug
vals = %x{logtail2 #{test}/var/log/daemon.log |awk '/puppet-master.*Compiled catalog for/ {print $14}'|sort -n}.chomp.split(/\n/).collect { |v| v.to_f }
puts vals if debug
if vals.length > 0
min = vals[0]
max = vals[-1]
mean = sprintf("%.2f",(vals.inject(0) { |r,v| r += v } / vals.length))
out = %x{#{gmetric} --name="puppetmaster MIN compile time" --value=#{min}}
out += %x{#{gmetric} --name="puppetmaster MAX compile time" --value=#{max}}
out += %x{#{gmetric} --name="puppetmaster MEAN compile time" --value=#{mean}}
puts out if debug
end