Created
February 7, 2011 17:14
-
-
Save andre/814749 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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