LoginSignup
1
3

More than 5 years have passed since last update.

トラブルで500を返すサーバを curl で監視し、治った瞬間にメッセージを送る

Posted at

5秒ごとに、Curlで監視し、500以外を返すようになったら、メッセージを送ります。
以下では、IFTTT の Maker チャンネルと Line チャンネルで、Lineにメッセージを送るようにしています。

while :; do
  RESPONSE=`curl -H 'Content-Type: application/json' 'http://XXX' -d '"json body"' -w '%{http_code}' -s`;
  echo $RESPONSE;
  if [ $RESPONSE != '500' ]; then
     curl -X POST https://maker.ifttt.com/trigger/notify/with/key/XXXX;
     break;
  fi;
  sleep 5;
done
1
3
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
3