Skip to content

Commit 894f13b

Browse files
author
Andre Lewis
committed
added simple ping plugin
1 parent 60702f4 commit 894f13b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ping/ping.rb

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

0 commit comments

Comments
 (0)