Ping hosts and do things.
Add multipinger to your Gemfile:
gem 'multipinger', github: 'jibi/multipinger'and use it:
require 'multipinger'
PingerRunner.single_runner('name') do
host 'my_host'
probe_interval 10
cooldown 600
on_up do
puts 'Host went up'
end
is_up do
puts 'Host is up'
end
on_down do
puts 'Host went down'
end
is_down do
puts 'Host is down'
end
endIf you want to run multiple pingers:
require 'multipinger'
p1 = Pinger.new('..') do
# ..
end
p2 = Pinger.new('..') do
# ..
end
r = PingerRunner.new
r.add(p1, p2).run