1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

レスポンスに1秒以上かかったらbeep音を鳴らす

Last updated at Posted at 2012-12-26

引数で渡したURLをcurlで取得、取得に1秒以上かかったらビープ音を鳴らすよ。

$ check.sh http://www.yahoo.co.jp/
check.sh
# !/bin/sh

if [ $# -ne 1 ]; then
    echo "set url" 1>&2
    exit 1
fi

START=`date +%s`
curl $1 > /dev/null 2>&1
END=`date +%s`

# echo $(($END-$START))

if [ $(($END-$START)) -ge 0 ]; then
	echo \\a
fi

MacOSXの場合は echo \\a の部分を afplay /System/Library/Sounds/Submarine.aiff みたいに書き換えて、音声ファイルを再生することもできるよ。

おまけ

レスポンスタイムをマイクロ秒で出力(Linux限定)

check.sh
# !/bin/sh

if [ $# -ne 1 ]; then
    echo "set url" 1>&2
    exit 1
fi

START=1`date +%S%N`
curl $1 > /dev/null 2>&1
END=1`date +%S%N`

TIME=$(($END-$START))
echo `date '+%Y/%m/%d %H:%M:%S'`,$1,`expr $TIME / 1000000`msec
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?