Skip to content

Instantly share code, notes, and snippets.

@andre
Created February 7, 2011 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andre/814749 to your computer and use it in GitHub Desktop.
Save andre/814749 to your computer and use it in GitHub Desktop.
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment