Jserv's blog: httping : 針對 HTTP Request 的仿 ping 程式

httping : 針對 HTTP Request 的仿 ping 程式

[httping ] 這個程式非常有意思,能夠以類似 ping 工具程式的方式,將 HTTP Request 的回應情況,呈現給操作者,簡介如下: Give it an url, and it'll show you how long it takes to connect, send a request and retrieve the reply (only the headers). Be aware that the transmission across the network also takes time! 跑個實際的例子,對象用 Google:

$ httping -g http://www.google.com -c 5
PING www.google.com:80 (http://www.google.com):
connected to www.google.com:80, seq=0 time=641.30 ms 
connected to www.google.com:80, seq=1 time=672.34 ms 
connected to www.google.com:80, seq=2 time=692.74 ms 
connected to www.google.com:80, seq=3 time=660.11 ms 
connected to www.google.com:80, seq=4 time=654.99 ms 
--- http://www.google.com ping statistics ---
5 connects, 5 ok, 0.00% failed
round-trip min/avg/max = 641.3/664.3/692.7 ms

由上可見,對著 Google 的某幾台機器的 port 80 作 HTTP request,並等待 header 的回應情況,我們可比對 ping 工具程式的輸出:

$ ping www.google.com -c 5
PING www.l.google.com (74.125.19.104) 56(84) bytes of data.
64 bytes from cf-in-f104.google.com (74.125.19.104): icmp_seq=1 ttl=241 time=258 ms
64 bytes from cf-in-f104.google.com (74.125.19.104): icmp_seq=2 ttl=241 time=258 ms
64 bytes from cf-in-f104.google.com (74.125.19.104): icmp_seq=3 ttl=241 time=257 ms
64 bytes from cf-in-f104.google.com (74.125.19.104): icmp_seq=4 ttl=241 time=257 ms
--- www.l.google.com ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4019ms
rtt min/avg/max/mdev = 257.860/258.053/258.395/0.656 ms

另外,[httping ] 支援 https (使用 OpenSSL 函式庫),也可以要求只做一次 DNS resolve,對於 roundrobin DNS 的環境來說很重要
由 jserv 發表於 July 1, 2008 11:11 AM

真的不错,ubuntu源中就有: