Bash
httping

httping が入っていない環境での代替bash function

More than 1 year has passed since last update.

だいたい似たようなことが bash と curl コマンドでも出来ます。

function althttping() {

local target=$1
local i=0
while true
do
curl -sI $target -o /dev/null -w "connected to %{remote_ip}:%{remote_port} (%{size_header} bytes), seq=${i} time=%{time_total}s\n";i=$((i+1))
sleep 1
done
}

実行結果

$ althttping www.google.com

connected to 183.79.75.234:80 (669 bytes), seq=0 time=0.068s
connected to 118.151.235.191:80 (669 bytes), seq=1 time=0.035s
connected to 183.79.139.228:80 (669 bytes), seq=2 time=0.064s
connected to 183.79.43.200:80 (669 bytes), seq=3 time=0.083s
connected to 183.79.75.234:80 (669 bytes), seq=4 time=0.062s

ほんものの httping の実行結果

$ httping www.yahoo.co.jp

PING www.yahoo.co.jp:80 (/):
connected to 118.151.235.191:80 (673 bytes), seq=0 time= 24.80 ms
connected to 183.79.43.200:80 (673 bytes), seq=1 time= 59.37 ms
connected to 118.151.235.191:80 (673 bytes), seq=2 time= 25.62 ms
connected to 183.79.43.200:80 (673 bytes), seq=3 time= 51.99 ms
connected to 118.151.235.191:80 (673 bytes), seq=4 time= 27.82 ms
^CGot signal 2
--- http://www.yahoo.co.jp/ ping statistics ---
5 connects, 5 ok, 0.00% failed, time 4705ms
round-trip min/avg/max = 24.8/37.9/59.4 ms