LoginSignup
14
15

More than 5 years have passed since last update.

プロセス監視のためのmonitを設定してみる

Posted at

はじめに

自動復旧の監視ツールを探していて、monitの名前がでてきたので設定をメモ

手順

  • モジュールのインスト
yum install -y monit
  • configの設定
/etc/monit.conf
# 監視の実行タイミングを設定
set daemon 60
set logfile /var/log/monit.log

# 以下のファイルに監視対象のプロセスを記述していく
include /etc/monit.d/*
  • monitの起動
$ sudo /etc/init.d/monit start
  • Nginxを監視する
/etc/monit.d/nginx.conf
check process nginx with pidfile /var/run/nginx.pid
  start program = "/etc/init.d/nginx start" with timeout 60 seconds
  stop program  = "/etc/init.d/nginx stop"
  if failed port 80 protocol http
    then restart
  group nginx
  • 止めてみる
$ sudo /etc/init.d/nginx stop
  • 自動復旧されていることを確認
$ sudo tail -f /var/log/monit
[UTC Aug 25 08:02:39] info     : monit: generated unique Monit id c03c45bb368fcf0f98753f10facc3692 and stored to '/root/.monit.id'
[UTC Aug 25 08:02:39] info     : 'system_ip-10-0-131-120' Monit started
[UTC Aug 25 08:04:39] error    : 'nginx' process is not running
[UTC Aug 25 08:04:39] info     : 'nginx' trying to restart
[UTC Aug 25 08:04:39] info     : 'nginx' start: /etc/init.d/nginx

参考

MonitでSSH,Nginx,MySQLのサービス死活監視を行うChef Cookbook
http://easyramble.com/chef-monit-ssh-nginx-mysql.html

14
15
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
14
15