[フレーム]
Last Updated: February 25, 2016
·
2.966K
· banjer

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’],
}

AltStyle によって変換されたページ (->オリジナル) /