sensu-plugins / sensu-plugins-twilio

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

sensu_level is not working correctly #12

Open tarvip opened 7 years ago

tarvip commented 7 years ago

Let's assume I have set recipient's sensu_level to 1 (warnings and criticals should be forwarded) and alert comes in where status is 2

There is following condition in code: candidate['sensu_level'] >= @event['check']['status'] this means 1 >= 2, which is obviously false. I think there should be <=, in this case 1<=2 is true and if OK message comes in then 1<=0 which is false.

mbbroberg commented 7 years ago

That's a smart observation @tarvip. The line is https://github.com/sensu-plugins/sensu-plugins-twilio/blob/master/bin/handler-twiliosms.rb#L46 I believe. The only thing I can't tell is whether that is intended to return false here or true. I leave that to people who know this plugin 😄

This is one of those moments when we feel the pain of limited test coverage. Two things if you have the time:

Tagging @Evesy as well since he recently worked on this plugin too. Cheers to you both!

Evesy commented 7 years ago

candidate['sensu_level'] >= @event['check']['status'] should return true (along with some other conditionals) for a candidate to be sent an SMS.

Assuming I'm correct in thinking that a sensu_level of 2 is supposed to represent 'critical only' alerts, and 1 represents both critical and warning alerts; then it makes sense that it should be <= rather than >=