Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

Monit

https://mmonit.com/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 などで実行すること

スラック投稿するスクリプト
- そこらへんにいっぱいあるので適当に拾ってくる
- 実行したいスクリプト経由で実行させておいたほうが良い

tanoshim
モバイルゲームの企画、開発、運営およびソリューション事業を生業とした、Ruby on RailsとUnityな会社です。
https://www.tanoshim.co.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした