Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added simple ping plugin

  • Loading branch information...
commit 894f13b746f279d82337cfa4f4fe05693df6b1bb 1 parent 60702f4
Andre Lewis authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 ping/ping.rb
View
19 ping/ping.rb
@@ -0,0 +1,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.
Something went wrong with that request. Please try again.