diff options
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | files/munin/puppet_ | 101 | ||||
-rw-r--r-- | manifests/puppetmaster.pp | 4 | ||||
-rw-r--r-- | manifests/puppetmaster/hasdb/mysql.pp | 8 | ||||
-rw-r--r-- | manifests/puppetmaster/munin.pp | 9 |
5 files changed, 128 insertions, 3 deletions
@@ -45,6 +45,15 @@ In both cases you have to setup the appropriate frontends (apache vhost configuration/nginx vhost configuration) on your own. +Munin +----- + +If you are using munin, and have the puppet munin module installed, you can set +the variable $use_munin = true to have graphs setup for you. The graphs that +will be setup track memory usage by the running puppetmasters; track the average +compile time of clients; and if you are using postgresql/mysql then a graph to +monitor resource counts. + Reports cleanup: --------------- diff --git a/files/munin/puppet_ b/files/munin/puppet_ new file mode 100644 index 0000000..ed488be --- /dev/null +++ b/files/munin/puppet_ @@ -0,0 +1,101 @@ +#!/usr/bin/env ruby + +# returns the mem usage of a given process +def plist(psname) + counter = 0 + %x{ps h -o rss,size,vsize,pcpu -u puppet}.each do |ps| + rss,size,vsize,cpu = ps.split + counter += 1 + puts "puppetmasterd_#{counter}.value #{rss}" + + end + return +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 ") + " ?" + t.day.to_s + hour = today + 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 + puts "avg_compile.value #{(avg / count).to_s[0..3]}" unless count == 0 + puts "last5m_count.value #{count}" + puts "last24h_unique_count.value #{day_count_unique}" +end + + +case ARGV[0] + when 'config' + case $0 + when /puppetmaster_memory/ + puts "graph_title puppetmaster memory usage" + puts "graph_vlabel memory" + # find out how many mongrel process we have - if any + File.open('/etc/default/puppetmaster') do |line| + @pm_process = line.grep(/PUPPETMASTERS/).to_s.split('=')[1].to_i + end + if @pm_process > 0 + @pm_process.times do |i| + puts "puppetmasterd_#{i+1}.label puppetmasterd #{i+1}" + end + else + puts "puppetmaster.label puppetmasterd" + end + when /puppet_clients/ + puts "graph_title puppet clients usage" + puts "graph_vlabel clients" + puts "known_clients.label Known Clients" + puts "avg_compile.label Average configuration compile" + puts "last5m_count.label Clients in the last 5 minutes" + puts "last24h_unique_count.label unique clients in the last 24 hours" + end + puts "graph_category puppet" + exit 0 + when 'autoconf' + case $0 + when /puppet_mem/,/puppet_clients/ + puts "yes" + else + puts "no" + exit 0 + end + else + plist("'ruby /usr/sbin/puppetmasterd'") if $0 =~ /puppet_mem$/ + if $0 =~ /puppet_clients$/ + puts "known_clients.value #{Dir.entries('/var/lib/puppet/yaml/facts/').size-2}" + phaselog + end +end + diff --git a/manifests/puppetmaster.pp b/manifests/puppetmaster.pp index 41d8021..4d1960d 100644 --- a/manifests/puppetmaster.pp +++ b/manifests/puppetmaster.pp @@ -42,4 +42,8 @@ class puppet::puppetmaster inherits puppet { if $use_shorewall { include shorewall::rules::puppet::master } + + if $use_munin { + include puppet::puppetmaster::munin + } } diff --git a/manifests/puppetmaster/hasdb/mysql.pp b/manifests/puppetmaster/hasdb/mysql.pp index 322bf69..1ed122a 100644 --- a/manifests/puppetmaster/hasdb/mysql.pp +++ b/manifests/puppetmaster/hasdb/mysql.pp @@ -23,8 +23,10 @@ define puppet::puppetmaster::hasdb::mysql ( tag => "mysql_${dbhostfqdn}", } - munin::plugin::deploy { 'puppetresources': - source => "puppet/munin/puppetresources.mysql", - config => "env.mysqlopts --user=$dbuser --password=$dbpwd -h $dbhost\nenv.puppetdb $dbname", + if $use_munin { + munin::plugin::deploy { 'puppetresources': + source => "puppet/munin/puppetresources.mysql", + config => "env.mysqlopts --user=$dbuser --password=$dbpwd -h $dbhost\nenv.puppetdb $dbname", + } } } diff --git a/manifests/puppetmaster/munin.pp b/manifests/puppetmaster/munin.pp new file mode 100644 index 0000000..4500b74 --- /dev/null +++ b/manifests/puppetmaster/munin.pp @@ -0,0 +1,9 @@ +class puppet::puppetmaster::munin { + + munin::plugin::deploy { + [ 'puppetmaster_memory', 'puppet_clients' ]: + source => "puppet/munin/puppet_", + config => "user root" + } + +} |