$ 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 的環境來說很重要。
真的不错,ubuntu源中就有:
$ aptitude show httping
Package: httping
State: not installed
Version: 1.2.5-1
Priority: optional
Section: universe/net
Maintainer: Ubuntu MOTU Developers
Uncompressed Size: 81.9k
Depends: libc6 (>= 2.6.1-1), libssl0.9.8 (>= 0.9.8e-1), openssl
Replaces: httping-nossl
Description: ping-like program for http-requests
httping show you how long it takes to connect to a hostname or remote url; send
a request and retrieve the reply (only the headers).
Homepage: http://www.vanheusden.com/httping