From 3df7bf7cd55ac9d676fa384440558cea44667a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20M=E4kinen?= Date: Thu, 17 Feb 2011 09:42:54 +0200 Subject: [PATCH] Added automatic restart to puppet-check if puppet memory consumption is over 256MB. --- puppet/files/puppet-check | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/puppet/files/puppet-check b/puppet/files/puppet-check index fe1db2b..813b17d 100755 --- a/puppet/files/puppet-check +++ b/puppet/files/puppet-check @@ -24,6 +24,15 @@ end # check that process is still alive begin Process.kill(0, pid) + + # check memory usage and restart if over 256M + rss = `ps -o rss= -p '#{pid}'`.to_i / 1024 + if rss > 256 + printf("puppetd memory usage too high (%d MB), on host '%s' sending HUP\n", + rss, Socket.gethostname) + Process.kill("HUP", pid) + end + exit rescue Errno::ESRCH nil