想查看某個 IP 是否活著,或者 ICMP 的回應時間,可以使用 ping,但是 Web Server 也想要 ping 可以怎麼做呢?
httping 測試網站的 Latency 和 Throughput
Web server 走 HTTP,有 HEAD 指令可以做簡單的回應,httping 也就用此方法來達成。
- httping - measure the latency and throughput of a webserver
Debian / Ubuntu Linux 安裝
- apt-get install httping
httping 使用方式
- $ httping -g https://blog.longwin.com.tw -l -c 5 -Y
- -g:測試網址
- -l:使用 SSL
- -c:ping 的次數
- -Y:輸出要有顏色
- httping blog.longwin.com.tw -S -Y -Z -s # 沒有 https 會遇到 301 redirect
- httping blog.longwin.com.tw -l -S -Y -Z -s
會秀出如下:
PING blog.longwin.com.tw:443 (/): connected to 123.1.1.1:443 (279 bytes), seq=0 time=195.16 ms connected to 123.1.1.1:443 (279 bytes), seq=1 time=199.98 ms connected to 123.1.1.1:443 (279 bytes), seq=2 time=191.79 ms connected to 123.1.1.1:443 (279 bytes), seq=3 time=183.49 ms connected to 123.1.1.1:443 (279 bytes), seq=4 time=240.24 ms --- https://blog.longwin.com.tw/ ping statistics --- 5 connects, 5 ok, 0.00% failed, time 6014ms round-trip min/avg/max = 183.5/202.1/240.2 ms
httping 到底做什麼事情呢?access.log 可以看到詳細資訊
123.1.1.1 - - [16/Oct/2020:16:55:42 +0800] "HEAD / HTTP/1.0" 200 6631 "-" "HTTPing v2.5" 123.1.1.1 - - [16/Oct/2020:16:57:00 +0800] "HEAD / HTTP/1.0" 200 6935 "-" "HTTPing v2.5" 123.1.1.1 - - [16/Oct/2020:16:57:01 +0800] "HEAD / HTTP/1.0" 200 6935 "-" "HTTPing v2.5" 123.1.1.1 - - [16/Oct/2020:16:57:03 +0800] "HEAD / HTTP/1.0" 200 6935 "-" "HTTPing v2.5"