LoginSignup
23
20

More than 5 years have passed since last update.

Excelをいじる感覚でお手軽ヘルスチェック

Last updated at Posted at 2016-05-11

Google Apps ScriptとGoogle Sheetsを使えば、誰でもExcelをいじる感覚でお手軽にヘルスチェックを登録、編集することができます。

screenshot1.gif

github.com

具体的には次のようなことが出来ます。

  • インターネット上に公開されていて、http(s)でアクセスできるWebサイト・Webサービスの死活監視
  • HTTPメソッドはGET, POST, PUT, DELETEのいずれかを指定可能
  • 任意のContent-Type, Header, およびbodyを指定可能
  • 期待する結果(HTTPステータスコードとbody)を指定可能
  • リクエストと期待する結果が異なる場合、 Slackに通知(Google Apps Script自体の失敗はメールで通知可能)
  • シートを閉じても(PCをシャットダウンしても)定期的にチェック

インストール

  1. git clone https://github.com/kei-sato/gas-health-check && cd gas-health-check && pbcopy < main.js
  2. Google Drive > NEW > Google Sheets 適当な名前でスプレッドシートを作成
  3. Tools > Script editor... Google Apps Scriptを開く
  4. main.jsをペーストして保存
  5. Select function > onOpenを指定して、実行(この時求められるパーミッションを許可しないと動作しません)
  6. シートに戻ると、メニューバーにCustom Menuが追加されている
  7. pbcopy < sample-sheet.txtでサンプルシートの内容をコピーしてシートに貼り付ける
  8. Custom Menu > check right now 正常に動作することを確かめる

定期実行

  1. Google Apps Script(Tools > Script editor...)側で、Resources > Current project's triggers > Add a new triggerを選択して、実行関数にhealthCheckを指定
  2. 実行感覚はお好みで
  3. notificationsから、以上終了時のメール通知を設定することも出来ます

Slack通知設定

リクエストの結果が期待と異なる場合に、Slackに通知するよう設定することが出来ます。

  1. https://slack.com/apps > Build > Make a custom integration > Incoming Webhooksを選択して、画面にしたがって、入力する
  2. 得られたWebhook URLをコピーする
  3. Custom Menu > Slack notificationsを選択して、Webhook URLを貼り付ける
  4. ルーム名は必要に応じて

以上で設定は完了です

23
20
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
23
20