Mercurial > rlm
view 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 source
1 (ns rlm.pings)2 (rlm.ns-rlm/ns-clone rlm.light-base)3 (import 'java.net.URL)4 (use 'clojure.contrib.shell-out)6 (def targets7 [(URL. "http://www.csail.mit.edu")8 (URL. "http://www.berkeley.edu")9 (URL. "http://www.usyd.edu.au")10 (URL. "http://www.kyoto-u.ac.jp")])12 (defn ping [num-packets packet-size #^URL address]13 (take-last14 3 ;; just the summary information from ping15 (re-split16 #"\n"17 (sh "ping"18 "-c" (str num-packets)19 "-s" (str packet-size)20 (.getHost address)))))22 (defn display-pings [results]23 (dorun (map #(dorun (map println %)) (interpose "\n" results))))