2
2

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.

Monitでプロセスを監視してスラックで通知する

Last updated at Posted at 2016-12-05

Monit

インストール
sudo yum install monit

起動
sudo systemctl start monit.service
停止
sudo systemctl stop monit.service
再起動
sudo systemctl restart monit.service

OS起動時に自動起動させる
sudo systemctl enable monit

確認
sudo systemctl status monit

設定ファイル
/etc/monit.d/monit.conf

プロセス名を正規表現で監視

check process XXXXXX with matching "XXXXXX"
  start program = "プロセスの開始コマンドorスクリプト"
  stop  program = "プロセスの開始コマンドorスクリプト"
  if does not exist
    then exec "実行したいスプリプト名"
  else if succeeded for 1 cycle then exec "実行したいスプリプト名"
  group XXXXXX

開始したいコマンドやスクリプトは環境変数を引き継いてくれないので
スクリプトで環境変数を設定するもしくは

/bin/su - ユーザー -c などで実行すること

スラック投稿するスクリプト

  • そこらへんにいっぱいあるので適当に拾ってくる
    • 実行したいスクリプト経由で実行させておいたほうが良い
2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?