Sensu修复:无法在客户端上触发


0

我是Sensu补救的新手。我尝试使用自定义脚本重新启动过程。

Senario:如果我的http链接断开了,那么我想手动运行脚本并启动它。

我尝试对sensu进行补救,如果您的监视工作因自定义脚本而导致该监视检查发生故障,则可以自动运行脚本。但是我面临的问题是所有检查和连接都很好,但是当我的链接断开时,sensu修复程序不会触发客户端。我已经发布了日志和配置,请告诉我我要去哪里了..

这是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
    }
}

我在此链接中使用过的sensu.rb

我有什么想念的吗?

如果发生任何故障,是否还有其他监视系统可以在其中运行脚本或命令?

我已经尝试过nagios花蜜和monit。


来吧,人编辑岗位不会给出答案...如果你知道我的问题,那么回答它不要编辑我的文件...
Vinood NK Maheshwari

Answers:


0

我在您的修复文件上看到错误。您缺少“检查”键。

应该是这样

{
    "checks": {
        "remediate-zubron": {
            "command": "sudo /bin/bash ~/zubron/home/moofwd-zubron-server/bin/start-moofwd.sh",
            "handlers": [],
            "subscribers": [
                "zubron"
            ],
            "standalone": false,
            "publish": false
        }
    }
}
  1. 其他几个可能的问题是您的客户端配置应该订阅您的名称,即名称university应该在订阅者university中订阅。

    {
        "client": {
            "name": "university",
            "address": "IP ADDRESS",
            "subscriptions": [
              "linux", "web-server", "system", "university"
            ]
        }
    }
    
  2. 另一个问题可能与remedediator.rb或sensu.rb中的api_request(:POST)有关,following方法应与下面给出的完全一样。在某些旧代码中,它'/checks/request'代替了'/request'并导致损坏。

    def trigger_remediation(check, subscribers)
        api_request(:POST, '/request') do |req|
            req.body = JSON.dump('check' => check, 'subscribers' => subscribers)
        end
    end
    
  3. 在某些情况下,您需要同时修复案例2和案例3。

以下是参考链接。为了使您更加清楚这个问题。

https://github.com/sensu/sensu-community-plugins/issues/1162

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.