Puppet service status check for multiple processes
I had a situation where a single init.d script fires off multiple processes. In order for puppet to check that this service was running, I had to grep ps aux for the two processes.
The status declaration below greps ps aux for “foobar” or “foocat” and pipes it to wc -l to get the number of lines, which should be at least 2. “egrep -v egrep” excludes the actual egrep process so it does not accidentally get counted.
service { ‘foo’:
ensure => running,
enable => true,
hasstatus => false,
# checks both foobar and foocat are running
status => “test `ps aux | egrep ‘foobar|foocat’ | egrep -v egrep | wc -l` -gt 1”,
require => File[‘/etc/init.d/foo’],
}
Written by Jason Ashby
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Puppet
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#