
Sensu 修復は初めてです。カスタム スクリプトを使用してプロセスを再起動しようとしました。
シナリオ: http リンクがダウンした場合、スクリプトを手動で実行して起動します。
sensu で修復を試みました。これにより、監視チェック用のカスタム スクリプトを使用して、監視対象がダウンした場合にスクリプトを自動的に実行できます。しかし、すべてのチェックと接続は良好ですが、リンクがダウンすると sensu remediator がクライアントをトリガーしないという問題が発生しています。ログと構成を投稿しましたが、どこが間違っているのか教えてください。
これはSensuサーバーのログです
{"timestamp":"2016-05-16T09:44:52.768622+0000","level":"info","message":"processing event","event":{"id":"9a9f66c2-e70e-45fb-87fb-c9e9085c8e05","client":{"name":"zubron","address":"10.0.0.110","subscriptions":["zubron"],"version":"0.20.3","timestamp":1463391880},"check":{"command":"/etc/sensu/plugins/check_http -H 10.0.0.110 -p 7077","interval":60,"occurrences":2,"handlers":["remediator"],"subscribers":["zubron"],"standalone":false,"remediation":{"remediate-zubron":{"occurrences":[1,3],"severities":[2]},"trigger_on":["zubron"]},"name":"check-zubron-port","issued":1463391892,"executed":1463391892,"duration":0.002,"output":"connect to address 10.0.0.110 and port 7077: Connection refused\nHTTP CRITICAL - Unable to open TCP socket\n","status":2,"history":["0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total_state_change":4},"occurrences":18,"action":"create","timestamp":1463391892}}
{"timestamp":"2016-05-16T09:44:52.864908+0000","level":"info","message":"handler output","handler":{"command":"/etc/sensu/handlers/sensu.rb","type":"pipe","severities":["critical"],"name":"remediator"},"output":["/etc/sensu/handlers/sensu.rb:108:in `[]': can't convert String into Integer (TypeError)\n","\tfrom /etc/sensu/handlers/sensu.rb:108:in `block in parse_remediations'\n","\tfrom /etc/sensu/handlers/sensu.rb:106:in `each'\n","\tfrom /etc/sensu/handlers/sensu.rb:106:in `parse_remediations'\n","\tfrom /etc/sensu/handlers/sensu.rb:90:in `handle'\n","\tfrom /var/lib/gems/1.9.1/gems/sensu-plugin-1.2.0/lib/sensu-handler.rb:55:in `block in <class:Handler>'\n","REMEDIATION: Evaluating remediation: zubron {\"remediate-zubron\"=>{\"occurrences\"=>[1, 3], \"severities\"=>[2]}, \"trigger_on\"=>[\"zubron\"]} #=18 sev=2\n"]}
これは Sensu サーバー上の私のチェック ファイルです...
{
"checks": {
"check-zubron-port": {
"command": "/etc/sensu/plugins/check_http -H 10.0.0.110 -p 7077",
"interval": 60,
"occurrences": 2,
"handlers": [
"remediator"
],
"subscribers": [
"zubron"
],
"standalone": false,
"remediation": {
"remediate-zubron": {
"occurrences": [
1,
3
],
"severities": [
2
]
},
"trigger_on": [
"zubron"
]
}
}
}
}
そしてこれが私の修復ファイルです...
{
"remediate-zubron": {
"command": "sudo /bin/bash ~/zubron/home/moofwd-zubron-server/bin/start-moofwd.sh",
"handlers": [],
"subscribers": [
"zubron"
],
"standalone": false,
"publish": false
}
}
ここから使用したRest sensu.rbリンク
何か見落としているものはありますか?
何か問題が発生した場合にスクリプトやコマンドを実行できる他の監視システムはありますか?
私はすでにnagios nectarとmonitを試しました。
答え1
修復ファイルにエラーがあります。「checks」キーがありません。
こうなるはずです、
{
"checks": {
"remediate-zubron": {
"command": "sudo /bin/bash ~/zubron/home/moofwd-zubron-server/bin/start-moofwd.sh",
"handlers": [],
"subscribers": [
"zubron"
],
"standalone": false,
"publish": false
}
}
}
他に考えられる問題としては、クライアント構成が自分の名前にサブスクライブされる必要がある、つまり、名前がサブスクライバー
university
にサブスクライブされる必要があることが挙げられます。university
{ "client": { "name": "university", "address": "IP ADDRESS", "subscriptions": [ "linux", "web-server", "system", "university" ] } }
もう 1 つの問題は、remedediator.rb または sensu.rb の api_request(:POST) にある可能性があります。次のメソッドは、以下のとおりです。一部の古いコードでは、
'/checks/request'
の代わりにが使用され'/request'
、破損の原因になります。def trigger_remediation(check, subscribers) api_request(:POST, '/request') do |req| req.body = JSON.dump('check' => check, 'subscribers' => subscribers) end end
場合によっては、ケース 2 とケース 3 の両方を修正する必要があります。
以下は参考リンクです。問題をより明確にするためです。
https://github.com/sensu/sensu-community-plugins/issues/1162