LoginSignup
5
7

More than 5 years have passed since last update.

Sensu監視設定

Last updated at Posted at 2015-01-19

以下を元に設定(※事前に、クライアント側へRubyのインストールが必要)
http://sensuapp.org/docs/0.16/adding_a_check

クライアント側 設定

sensu-pluginのインストール

# gem install sensu-plugin --no-rdoc --no-ri

監視スクリプトのダウンロード

# wget -O /etc/sensu/plugins/check-procs.rb https://raw.github.com/sensu/sensu-community-plugins/master/plugins/processes/check-procs.rb
# chmod 755 /etc/sensu/plugins/check-procs.rb

subscriptionsの設定

※name/addressは適宜修正すること

# vi /etc/sensu/conf.d/client.json
/etc/sensu/conf.d/client.json
{
  "client": {
    "name": "Sensu-Client",
    "address": "192.168.xxx.xxx",
-    "subscriptions": [ "all" ]
+    "subscriptions": [ "webservers" ]
  }
}

サーバ側 設定

監視定義設定

# vi /etc/sensu/conf.d/check_cron.json
/etc/sensu/conf.d/check_cron.json
{
  "checks": {
    "cron_check": {
      "handlers": ["default"],
      "command": "/etc/sensu/plugins/check-procs.rb -p crond -C 1 ",
      "interval": 60,
      "subscribers": [ "webservers" ]
    }
  }
}

Sensu 再起動

クライアント側

# service sensu-client restart

サーバ側

# service sensu-server restart
# service sensu-api restart

ログ確認

クライアント側

# grep cron_check /var/log/sensu/sensu-client.log
{"timestamp":"2015-01-19T21:51:48.042368+0900","level":"info","message":"received check request","check":{"name":"cron_check","issued":1421671843,"command":"/etc/sensu/plugins/check-procs.rb -p crond -C 1 "}}
{"timestamp":"2015-01-19T21:51:48.129277+0900","level":"info","message":"publishing check result","payload":{"client":"Sensu-Client","check":{"name":"cron_check","issued":1421671843,"command":"/etc/sensu/plugins/check-procs.rb -p crond -C 1 ","executed":1421671908,"duration":0.086,"output":"CheckProcs OK: Found 1 matching processes; cmd /crond/\n","status":0}}}

サーバ側

# grep cron_check /var/log/sensu/sensu-server.log
{"timestamp":"2015-01-19T21:51:43.444922+0900","level":"info","message":"publishing check request","payload":{"name":"cron_check","issued":1421671903,"command":"/etc/sensu/plugins/check-procs.rb -p crond -C 1 "},"subscribers":["webservers"]}

障害検出確認

crondを停止してみる

# service crond stop

Dashboard確認

http://<Server IP>:3000/#/events

sensu-crond-check.png

クライアント側 ログ確認

# grep cron_check /var/log/sensu/sensu-client.log | tail -2
{"timestamp":"2015-01-19T21:58:03.577208+0900","level":"info","message":"received check request","check":{"name":"cron_check","issued":1421672203,"command":"/etc/sensu/plugins/check-procs.rb -p crond -C 1 "}}
{"timestamp":"2015-01-19T21:58:03.663127+0900","level":"info","message":"publishing check result","payload":{"client":"Sensu-Client","check":{"name":"cron_check","issued":1421672203,"command":"/etc/sensu/plugins/check-procs.rb -p crond -C 1 ","executed":1421672283,"duration":0.086,"output":"CheckProcs CRITICAL: Found 0 matching processes; cmd /crond/\n","status":2}}}
5
7
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
5
7