diff --git a/files/ganglia/puppetd_runtime.sh b/files/ganglia/puppetd_runtime.sh new file mode 100644 index 0000000..d4f4d26 --- /dev/null +++ b/files/ganglia/puppetd_runtime.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# $Id: puppetd_lastrun.sh 2810 2009-09-02 08:37:05Z uwaechte $ + +# 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=350 --units=lastrun --type=int32" +VALUE=$[ ( ${NOW} - ${STIME} ) / 60 ] +$GMETRIC --value=${VALUE} --name="Minutes since last Puppet run" diff --git a/manifests/init.pp b/manifests/init.pp index 70ab4dd..92f2010 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -7,7 +7,7 @@ class puppet ( $run_hour = '*/1', $run_minute = '10', $run_if_ipmatch = '', - $maxsleep = '640' + $maxsleep = '640' ) { $puppet_service = $::kernel ? { 'Darwin' => 'org.macports.puppet', @@ -108,6 +108,17 @@ class puppet ( }, } } + + if defined(Class['ganglia::monitor']) { + Ganglia::Gmetric::Cron { + source => 'puppet/ganglia', + ensure => $ensure, + } + + ganglia::gmetric::cron { 'puppetd_lastrun.sh': runwhen => '5', } + ganglia::gmetric::cron { 'puppetd_runtime.sh': runwhen => '15', } + + } } } $puppet_user = $operatingsystem ? { diff --git a/manifests/puppetmaster.pp b/manifests/puppetmaster.pp index 4260b5a..ebb02a8 100644 --- a/manifests/puppetmaster.pp +++ b/manifests/puppetmaster.pp @@ -24,7 +24,7 @@ class puppet::puppetmaster ($ensure = 'present', $puppetqd = false) { } } - if defined(Class['ganglia']) { + if defined(Class['ganglia::monitor']) { Ganglia::Gmetric::Cron { source => 'puppet/ganglia', ensure => $ensure,