2

I have some daemon scripts that run in an infinite loop that do some action if a detected node has failed. For example; in AWS to move an Elastic IP.

How can I integrate this script that runs in an infinite loop to push an alert to sensu? The traditional Sensu documentation about checks does not apply (this script runs forever). I need a way to send a custom event directly to sensu. I thought the API might be it, but it doesn't seem like I can push an event.

1 Answers1

2

Sensu has documentation on how to do this here: https://sensuapp.org/docs/latest/clients#client-socket-input

Basically, each sensu client (client.json) has an internal socket that you can send external data to; by default this socket only listens on 127.0.0.1:3030 so the config for the client has to be adjusted:

{
  "client": {
    "name": "my.host",
    "address": "x.x.x.x",
    "subscriptions": [
      "all"
    ],
    "socket": {
      "bind": "0.0.0.0",
      "port": 3030
    }
  }
}

The external script then needs to send data to that clients socket via TCP or UDP in JSON using the following format:

{
  "name": "some_name",
  "output": "ITS DOWN OH NO!",
  "status": 2
}