sstarcher / docker-sensu

Dockerized Sensu - Client, Server, Api
MIT License
103 stars 72 forks source link

server container not executing handlers #39

Closed slwst closed 7 years ago

slwst commented 7 years ago

Loading a check which intentionally fails yields expected client output, but it doesn't appear that the server container sees the failure or tries to invoke the correct handler.

I have this check:

{

"checks": { "proc-fail": { "command": "check-process.rb -p idontexist -W 1", "subscribers": [ "all" ], "interval": 60 } } }

I see the sensu client log reflect that the check has failed:

{"timestamp":"2017-02-08T16:08:06.439738-0500","level":"info","message":"publishing check result","payload":{"client":"core01.private.prv","check":{"command":"check-process.rb -p idontexist -W 1","name":"proc-fail","issued":1486588086,"executed":1486588086,"duration":0.284,"output":"CheckProcess CRITICAL: Found 0 matching processes; cmd /idontexist/\n","status":2}}}

however the server log never reflects this failure, and doesn't even attempt to invoke the default handler:

{"timestamp":"2017-02-08T16:06:37.900642-0500","level":"warn","message":"loading extension files from directory","directory":"/etc/sensu/extensions"} {"timestamp":"2017-02-08T16:06:37.900801-0500","level":"warn","message":"loaded extension","type":"filter","name":"occurrences","description":"filter events using event occurrences"} {"timestamp":"2017-02-08T16:06:37.900888-0500","level":"warn","message":"loaded extension","type":"mutator","name":"json","description":"returns JSON formatted event data"} {"timestamp":"2017-02-08T16:06:37.900966-0500","level":"warn","message":"loaded extension","type":"mutator","name":"only_check_output","description":"returns check output"} {"timestamp":"2017-02-08T16:06:37.901048-0500","level":"warn","message":"loaded extension","type":"mutator","name":"ruby_hash","description":"returns ruby hash event data"} {"timestamp":"2017-02-08T16:06:37.901121-0500","level":"warn","message":"loaded extension","type":"handler","name":"debug","description":"returns raw event data"}

my server block in docker-compose is configured as:

server: image: sstarcher/sensu:0.26 command: server links:

  • redis
  • api volumes:
  • "/opt/sensu/check.d:/etc/sensu/check.d"
  • "/opt/sensu/handlers:/etc/sensu/handlers"
  • "/etc/localtime:/etc/localtime:ro"
  • "/etc/timezone:/etc/timezone:ro"
  • "/opt/sensu/logs:/var/log/sensu" environment: RUNTIME_INSTALL: mailer

and my default handler is configured as:

{ "handlers": { "default": { "type": "pipe", "command": "/etc/sensu/handlers/mailer.rb -j /etc/sensu/handlers/mailer.json", "mail_from": "sensu@private.prv", "mail_to": "sucker@private.prv", "smtp_address": "192.168.99.99", "smtp_domain": "private.prv" } } }

the mailer.rb and mailer.json are mapped directly into the handlers directory.

What am I doing wrong? I'd be happy to extend the docker-sensu documentation to cover handlers and handler usage once I figure this out.

Thank you!

sstarcher commented 7 years ago

If I remember correctly no default handler exists and you have to specify the handler on the check. docker-sensu should support handlers identically to sensu not in docker assuming the checks and handlers exist and are configured correctly.

slwst commented 7 years ago

You're absolutely right. the "Default" handler is a concept from the chef sensu LWRP.

Made a few changes, working great now. Thank you very much!

sstarcher commented 7 years ago

@Viszeral np, glad I could help. I'm going to close this issue out.