public
Created

  • Download Gist
ping.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# Takes an IP or hostname. Reports 1 if it can ping the host, 0 if it can't
class Ping < Scout::Plugin
 
OPTIONS=<<-EOS
host:
name: Host
notes: the IP address or hostname to ping
EOS
 
def build_report
host = option('host')
error("You must provide an IP or host to ping") and return if !host
 
ping = `ping -c1 #{host} 2>&1`
res = ping.include?("bytes from") ? 1 : 0
report(:status=>res)
 
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.