Sensu客户端check-memory示例无法工作

9
我正在尝试让Sensu正常工作。
以下是"sensu-client.log"的内容。
ubuntu@ip:~$ sudo tail -f  /var/log/sensu/sensu-client.log 
{"timestamp":"2016-09-27T16:07:37.628182-0400","level":"info","message":"completing checks in progress","checks_in_progress":[]}
{"timestamp":"2016-09-27T16:07:38.128912-0400","level":"info","message":"closing client tcp and udp sockets"}
{"timestamp":"2016-09-27T16:07:38.129275-0400","level":"warn","message":"stopping reactor"}
{"timestamp":"2016-09-27T16:07:39.224377-0400","level":"warn","message":"loading config file","file":"/etc/sensu/config.json"}
{"timestamp":"2016-09-27T16:07:39.224487-0400","level":"warn","message":"loading config files from directory","directory":"/etc/sensu/conf.d"}
{"timestamp":"2016-09-27T16:07:39.224528-0400","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/check_mem.json"}
{"timestamp":"2016-09-27T16:07:39.224573-0400","level":"warn","message":"config file applied changes","file":"/etc/sensu/conf.d/check_mem.json","changes":{}}
{"timestamp":"2016-09-27T16:07:39.224618-0400","level":"warn","message":"applied sensu client overrides","client":{"name":"localhost","address":"127.0.0.1","subscriptions":["test","client:localhost"]}}
{"timestamp":"2016-09-27T16:07:39.230963-0400","level":"warn","message":"loading extension files from directory","directory":"/etc/sensu/extensions"}
{"timestamp":"2016-09-27T16:07:39.231048-0400","level":"info","message":"configuring sensu spawn","settings":{"limit":12}}

/etc/sensu/client.json 包含了

{
"rabbitmq": {
    "host": "ipaddressofsensuserver",
    "port": 5672,
    "user": "username",
    "password": "password",
    "vhost": "/sensu"
  },
  "api": {
    "host": "localhost",
    "port": 4567
  },
  "checks": {
    "test": {
      "command": "echo -n OK",
      "subscribers": [
        "test"
      ],
      "interval": 60
    },
    "memory-percentage": {
      "command": "check-memory-percent.sh -w 50 -c 70",
      "interval": 10,
      "subscribers": [
        "test"
      ]
     }
  },
  "client": {
    "name": "localhost",
    "address": "127.0.0.1",
    "subscriptions": [
      "test"
    ]
  }
}

我已将check-memory-present.sh复制到/etc/sensu/conf.d文件夹中。
我希望日志文件每10秒运行check-memory-percent,但结果并非如此。我错过了什么吗?

请注明您需要一个独立的检查而不是订阅。 - Kobbe
2个回答

4

Sensu客户端不能完全独立于服务器运行,但它可以安排自己的检查任务并通过传输(例如RabbitMQ)将其发送到服务器。您需要在检查配置中添加"standalone": true才能使此功能生效,然后重新启动sensu-client服务。

因此,文件/etc/sensu/conf.d/check_mem.json应该类似于:

"checks": {
  "memory-percentage": {
    "command": "/etc/sensu/conf.d/check-memory-percent.sh -w 50 -c 70",
    "interval": 10,
    "standalone": true
  }
}

记得从/etc/sensu/client.json中删除该块,因为如果定义了多个相同的检查名称,可能会导致意外的结果。


是的,我已经备份了client.json并且按照你建议的修改了它。运行得很好。谢谢。 - Siddharth

0
在 Client.json 文件中,在 "client" 下,您需要添加订阅。就像这个例子 here 一样。它应该与您的检查的 "subscribers" 定义相匹配。

但是我不希望服务器发送任何请求。我希望客户端独立运行。我是否缺少一些基础知识? - Siddharth
是的,看起来您可能缺少一些基础知识。您所说的“我希望客户端独立运行”是什么意思?您可能需要再次阅读客户端 https://sensuapp.org/docs/latest/reference/clients.html 和检查 https://sensuapp.org/docs/latest/reference/checks.html 文档。特别是订阅/订阅者部分。 - Enrique Arriaga
@Siddharth,你没有说明你想要它独立。不管怎样,有什么原因吗?结果需要发送到sensu,所以并没有那么多的独立性.. - Kobbe

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接