From d2a35e980c016b52e041ea722ebe59b268f996c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20M=E4kinen?= Date: Fri, 4 Dec 2009 09:26:33 +0200 Subject: [PATCH] Improved puppet check cron job to check memory consumption. --- puppet/files/puppet-check | 13 +++++++++++++ puppet/manifests/init.pp | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 puppet/files/puppet-check diff --git a/puppet/files/puppet-check b/puppet/files/puppet-check new file mode 100755 index 0000000..22958fb --- /dev/null +++ b/puppet/files/puppet-check @@ -0,0 +1,13 @@ +#!/bin/sh + +PID="`pgrep -f 'puppetd'`" +if [ $? -ne 0 ]; then + echo "puppetd not running on host `hostname`" + exit 1 +fi + +MEMUSAGE=`ps -p ${PID} -o rss | tail -1` +if [ ${MEMUSAGE} -gt 262144 ]; then + echo "puppetd process size is over 256 MB (${MEMUSAGE} KB), restart recommended" + exit 1 +fi diff --git a/puppet/manifests/init.pp b/puppet/manifests/init.pp index 16aeb97..6cd3c27 100644 --- a/puppet/manifests/init.pp +++ b/puppet/manifests/init.pp @@ -60,12 +60,23 @@ class puppet::client { } } + file { "/usr/local/sbin/puppet-check": + ensure => present, + source => "puppet:///puppet/puppet-check", + mode => 0755, + owner => root, + group => $operatingsystem ? { + openbsd => wheel, + default => root, + }, + } cron { "puppet-check": ensure => present, - command => "pgrep -f 'puppetd' > /dev/null || echo 'puppetd not running on host ${fqdn}'", + command => "/usr/local/sbin/puppet-check", user => root, hour => 5, minute => 0, + require => File["/usr/local/sbin/puppet-check"], } }