-
Notifications
You must be signed in to change notification settings - Fork 0
Using the Built in Conditions
Gurpartap edited this page Dec 25, 2012
·
9 revisions
Here are a few examples of how to implement checks provided by default in Cognizant:
Restart every 6 seconds.
process.check(:always_true, :every => 2.seconds, :times => 3) do |p|
# do something here every 2 seconds such as polling an external uptime monitoring tool.
end
Restart process if cpu usage is above 60 percent in 3 out of 5 times from checks run every 3 seconds.
process.check(:cpu_usage, :every => 3.seconds, :above => 60, :times => [3, 5], :do => :restart) # or use a block
Restart process if memory usage is above 100 megabytes in 3 out of 5 times from checks run every 5 seconds.
process.check(:memory_usage, :every => 5.seconds, :above => 100.megabytes, :times => [3, 5]) do |p|
p.restart
end
Stop the process, if it constantly restarts for 5 times within the last 30 seconds, and try (start) again after waiting for 60 seconds.
process.check(:flapping, :times => 5, :within => 30.seconds, :retry_after => 60.seconds)