Mercurial > rlm
diff src/rlm/pings.clj @ 0:78a630e650d2
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 18 Oct 2011 00:57:08 -0700 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/rlm/pings.clj Tue Oct 18 00:57:08 2011 -0700 1.3 @@ -0,0 +1,26 @@ 1.4 +(ns rlm.pings) 1.5 +(rlm.ns-rlm/ns-clone rlm.light-base) 1.6 +(import 'java.net.URL) 1.7 +(use 'clojure.contrib.shell-out) 1.8 + 1.9 +(def targets 1.10 + [(URL. "http://www.csail.mit.edu") 1.11 + (URL. "http://www.berkeley.edu") 1.12 + (URL. "http://www.usyd.edu.au") 1.13 + (URL. "http://www.kyoto-u.ac.jp")]) 1.14 + 1.15 +(defn ping [num-packets packet-size #^URL address] 1.16 + (take-last 1.17 + 3 ;; just the summary information from ping 1.18 + (re-split 1.19 + #"\n" 1.20 + (sh "ping" 1.21 + "-c" (str num-packets) 1.22 + "-s" (str packet-size) 1.23 + (.getHost address))))) 1.24 + 1.25 +(defn display-pings [results] 1.26 + (dorun (map #(dorun (map println %)) (interpose "\n" results)))) 1.27 + 1.28 + 1.29 +