#!/usr/bin/env ruby # $Id: puppetmaster_compiletime.rb 4431 2011-06-21 11:23:42Z uwaechte $ # 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