initial
This commit is contained in:
21
files/ganglia/.svn/text-base/puppetd_lastrun.sh.svn-base
Normal file
21
files/ganglia/.svn/text-base/puppetd_lastrun.sh.svn-base
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# $Id$
|
||||
|
||||
# plot puppetd last run
|
||||
|
||||
GMETRIC=$(which gmetric)
|
||||
[[ -x ${GMETRIC} ]] || exit 0
|
||||
|
||||
FILE="/var/lib/puppet/state/state.yaml"
|
||||
[[ -r $FILE ]] || exit 0
|
||||
## BSD and Linux have different stat commands
|
||||
if [ $(uname -s) == "Linux" ]; then
|
||||
STIME=$(stat --format="%Y" ${FILE})
|
||||
else
|
||||
STIME=$(stat -f "%m" -t "%s" ${FILE})
|
||||
fi
|
||||
|
||||
NOW=$(date +"%s")
|
||||
GMETRIC="${GMETRIC} --dmax=30000 --tmax=300 --slope=positive --units=lastrun --type=int32"
|
||||
VALUE=$[ ( ${NOW} - ${STIME} ) / 60 ]
|
||||
$GMETRIC --value=${VALUE} --name="Minutes since last Puppet run"
|
||||
72
files/ganglia/.svn/text-base/puppetmaster.rb.svn-base
Normal file
72
files/ganglia/.svn/text-base/puppetmaster.rb.svn-base
Normal file
@@ -0,0 +1,72 @@
|
||||
#! /bin/env ruby
|
||||
|
||||
# returns the mem usage of a given process
|
||||
$gmetric = %x{which gmetric}.chomp
|
||||
exit 0 unless $gmetric != ""
|
||||
|
||||
def plist(psname)
|
||||
whats = ["rss","size","vsize","cpu"]
|
||||
%x{ps h -o rss,size,vsize,pcpu,command -C ruby1.8 |grep #{psname}|cut -f 1-4 -d ' '}.each do |ps|
|
||||
#rss,size,vsize,cpu,command = ps.split
|
||||
counter = 0
|
||||
ps.split.each { |value|
|
||||
what = whats[counter]
|
||||
counter += 1
|
||||
units = counter == 4 ? "time" : "kbyte"
|
||||
# puts "#{psname}_#{counter}_#{what} V=#{value} U=#{units}"
|
||||
gmetric("#{psname}_#{counter}_#{what}",value,units)
|
||||
}
|
||||
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
def gmetric(name,value,units)
|
||||
%x{#{$gmetric} --type=float --units=#{units} --name=#{name} --value=#{value} --slope=positive --tmax=300 --dmax=300000}
|
||||
end
|
||||
|
||||
# reports how many clients compiled in the last 5 minutes
|
||||
# repotrs how many unique clients compiled since the begining of the day
|
||||
# report the average compilation time for all clients in the last 5 minutes.
|
||||
def phaselog
|
||||
logfile = ENV['puppet_logfile'] || '/var/log/daemon.log'
|
||||
count,avg,day_count_unique,day_count = 0 ,0 ,0, 0
|
||||
t = Time.now
|
||||
today = t.strftime("^%b %d")
|
||||
hour = t.strftime("%H:")
|
||||
m = t.min.to_i
|
||||
last5m = ""
|
||||
6.times do |i|
|
||||
last5m += hour
|
||||
last5m += "0" if (m-i) < 10
|
||||
last5m += (m-i).to_s
|
||||
last5m += "|" unless i==5
|
||||
end
|
||||
hosts = Array.new
|
||||
regexp = ".* for (.*) in (.*) seconds"
|
||||
File.open(logfile).grep(/#{today}/).grep(/Compiled configuration|Compiled catalog/).each do |line|
|
||||
case line
|
||||
when /#{last5m}/ then
|
||||
if line =~ /#{regexp}/
|
||||
avg += $2.to_f
|
||||
count += 1
|
||||
unless hosts.include?($1)
|
||||
hosts << $1
|
||||
end
|
||||
end
|
||||
when /#{regexp}/ then
|
||||
day_count += 1
|
||||
unless hosts.include?($1)
|
||||
hosts << $1
|
||||
day_count_unique += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
gmetric("puppetmasterd avg_compile",(avg / count).to_s[0..3],"seconds") unless count == 0
|
||||
gmetric("puppetmasterd last5m_count",count,"clients")
|
||||
gmetric("puppetmasterd last24h_unique_count", day_count_unique, "clients")
|
||||
end
|
||||
|
||||
plist("puppetmasterd")
|
||||
gmetric("puppetmasterd known_clients",Dir.entries('/var/lib/puppet/yaml/facts/').size-2,"clients")
|
||||
phaselog
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user