import repository from arizona
[raven.git] / publish / smbaker-experiment / build / pingbench / etc / owl / scripts.d / pingbench
1 #!/usr/bin/python
2
3 import socket
4 import time
5
6 HOSTADDR = ("quake.cs.arizona.edu", 4321)
7 TIMEOUT = 5
8
9 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
10 s.settimeout(TIMEOUT)
11
12 s.sendto("PING", 0, HOSTADDR)
13 tStart = time.time()
14 try:
15     (data, remoteAddr) = s.recvfrom(4096)
16     tStop = time.time()
17     tElapsed = int ((tStop-tStart) * 1000);
18 except socket.timeout:
19     tElapsed = -1
20
21 print "[ravenpingbench]"
22 print "elapsed=", tElapsed