sensu-plugins / sensu-plugins-twilio

Sensu Twilio Plugins
http://sensu-plugins.io
MIT License
0 stars 9 forks source link

Only 'Resolved' messages received and not other alerts. #9

Open krishnadurai opened 7 years ago

krishnadurai commented 7 years ago

Twilio SMS plugin is just sending just resolved messages for all checks except 'keepalive' checks, i.e. Keep Alive checks are behaving normally. Here's my handler configuration:

/etc/sensu/conf.d/handlers/sms.json

{
  "handlers":
  {
    "twiliosms": {
      "type": "pipe",
      "command": "handler-twiliosms.rb"
    }
  },
  "twiliosms":{
    "token":"xxxxxxxxxxxx",
    "number":"+xxxxxxxxxx",
    "sid":"xxxxxxxxxxxxxxxxxxxxxxx",
    "recipients":{
      "+xxxxxxxxxxxx": {
        "sensu_roles":["all"],
        "sensu_checks":[],
        "sensu_level": 1
      },
      "+xxxxxxxxxxxx": {
        "sensu_roles":["all"],
        "sensu_checks":[],
        "sensu_level": 1
      }
    }
  }
}

Relevant server logs:

For keepalive alerts:

{"timestamp":"2017-03-23T07:53:07.952277+0000","level":"info","message":"handler output","handler":{"type":"pipe","command":"handler-twiliosms.rb","name":"twiliosms"},"output":["warning: event filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nwarning: occurrence filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nonly handling every 60 occurrences: server2/keepalive\n"]}
{"timestamp":"2017-03-23T07:53:37.954842+0000","level":"info","message":"handler output","handler":{"type":"pipe","command":"handler-twiliosms.rb","name":"twiliosms"},"output":["warning: event filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nwarning: occurrence filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nonly handling every 60 occurrences: server2/keepalive\n"]}

For other alerts:

{"timestamp":"2017-03-23T07:53:32.450606+0000","level":"info","message":"processing event","event":{"client":{"name":"DevelopmentServer","address":"sensu.server.com","subscriptions":["test","client:DevelopmentServer"],"version":"0.26.5","timestamp":1490255604},"check":{"interval":60,"command":"check-process.rb -p mongod","standalone":true,"name":"mongo_process","issued":1490255612,"executed":1490255612,"duration":0.118,"output":"CheckProcess CRITICAL: Found 0 matching processes; cmd /mongod/\n","status":2,"type":"standard","history["2","2","2","2","2","2","2"],"total_state_change":0},"occurreces":7,"occurrences_watermark":7,"action":"create","timestamp":1490255612,"id":"d97045bc-f655-4064-aed0b8c8b8853f30","last_state_change":1490255252,"last_ok":1490255252,"silenced":false,"silenced_by":[]}}
{"timestamp":"2017-03-23T07:53:33.817668+0000","level":"info","message":"handler output","handler":{"type":"pipe","command":"handler-twiliosms.rb","name":"twiliosms"},"output":["warning: event filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nwarning: occurrence filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nonly handling every 30 occurrences: DevelopmentServer/mongo_process\n"]}

Relevant links: https://groups.google.com/forum/#!topic/sensu-users/d08ccWOviac

majormoses commented 7 years ago

This looks like it is at least partially due to the event deprecation outlined here: https://blog.sensuapp.org/deprecating-event-filtering-in-sensu-plugin-b60c7c500be3

trisell commented 6 years ago

I just put up a PR that resolves this issue. You have to remove these lines https://github.com/sensu-plugins/sensu-plugins-twilio/blob/dd320f1cdb4955523501ba93955f53daa61debcf/bin/handler-twiliosms.rb#L41-L46 And then checks will go through. Until this PR is merged you will have to manually remove them every time you install the plugin. You will also need to set up your checks to use the occurrences, refresh variables as well as configure twiliosms as a handler. See the README of the my PR to see the settings needed in a check.