sensu-client check-memory sample work working
Asked Answered
M

2

9

I am trying to get sensu working.

The following is the 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 contains

{
"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"
    ]
  }
}

I have copied check-memory-present.sh into /etc/sensu/conf.d folder

I was expecting the log file to run check-memory-percent every 10 seconds. What am I missing here ?

Mccarley answered 22/9, 2016 at 5:39 Comment(1)
Please add that you want a standalone check and not a subscription.Axiom
T
4

The Sensu client cannot operate entirely independent of the server, but it can schedule its own checks to run and have them be sent to the server through the transport (RabbitMQ in this case). You'll have to add "standalone": true to the check configuration in order to have this take effect, and then restart the sensu-client service.

So, the file /etc/sensu/conf.d/check_mem.json should look something like:

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

Remember to remove the block from /etc/sensu/client.json as well, as you may get unexpected results if you have the same check name defined multiple times.

Tricycle answered 28/9, 2016 at 2:13 Comment(1)
yes i have backed up the client.json and made the changes you have recommended. works well. Thanks..Mccarley
W
0

In Client.json, under "client", you need to add the subscriptions. Like in the example here. It should match the definition of "subscribers" for your check.

Wrightson answered 22/9, 2016 at 17:27 Comment(3)
But I dont want the server to send any requests. I want the client to operate independent. Am I missing some fundamentals ?Mccarley
Yes, it seems you may be missing some fundamentals. What do you mean by "I want the client to operate independent"? You may need to read again both the Client sensuapp.org/docs/latest/reference/clients.html and Checks sensuapp.org/docs/latest/reference/checks.html documentation. Specially the subscription/subscribers sections.Wrightson
@Mccarley You did not specify that you wanted it independently. Anyway, any reason for that? The result needs to be sent to sensu anyway so there is not so much independency..Axiom

© 2022 - 2024 — McMap. All rights reserved.