sensu-plugins / sensu-plugins-mailer

This plugin is an email handler for Sensu.
http://sensu-plugins.io
MIT License
17 stars 37 forks source link

New issues comes yesterday for handler-mailer.rb #109

Closed xiaoman-w closed 4 years ago

xiaoman-w commented 4 years ago

I'm building the sensu go email handler, with the ruby 2.3.1, sensu-plugin(3.0.0) and sensu-plugins-mailer(3.0.0).

this handler-mailer.rb script working the day before yesterday, and without any change when yesterday I login to the server and trying the same command (event.json is an event in sensu go schema), it returns the error:

$ cat event.json | /usr/local/lib/ruby/gems/2.3.0/gems/sensu-plugins-mailer-3.0.0/bin/handler-mailer.rb -j mailer -c html -s '[Sensu]' --map-go-event-into-ruby

/usr/local/lib/ruby/gems/2.3.0/gems/sensu-plugins-mailer-3.0.0/bin/handler-mailer.rb:213:in `build_body': undefined method `[]' for nil:NilClass (NoMethodError)
    from /usr/local/lib/ruby/gems/2.3.0/gems/sensu-plugins-mailer-3.0.0/bin/handler-mailer.rb:240:in `handle'
    from /usr/local/lib/ruby/gems/2.3.0/gems/sensu-plugin-3.0.0/lib/sensu-handler.rb:89:in `block in <class:Handler>'

https://github.com/sensu-plugins/sensu-plugins-mailer/blob/269be819cd499c53c665d9dd437eb4dcc6161f21/bin/handler-mailer.rb#L213

I've checked with couple files: The mailer config json file exists here defining the smtp_domain and mail_from, mail_to, admin_gui. etc: /etc/sensu/conf.d/sensu-plugins-mailer.json { "mailer": { "smtp_domain": "xxx.com", "mail_from": "sensu@xxx.com", "mail_to": "xxx@xxx.com", "admin_gui": "http://sensu.xxx.com:3000", "template": “/etc/sensu/plugins/mail-template.erb", "smtp_address": "xxxx", "smtp_port": 2525 } }

mail templates exists here: /etc/sensu/plugins/mail-template.erb

Does anyone meet with this issue? What changes make this issue happen suddenly and how can I solve it