# Having Problems with mailer.rb

**URL:** <https://discourse.sensu.io/t/having-problems-with-mailer-rb/406>\
**Category:** Sensu Classic (EOL)\
**Created:** [March 20, 2015, 8:14pm UTC](https://discourse.sensu.io/t/having-problems-with-mailer-rb/406 "2015-03-20T20:14:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@Tony](https://discourse.sensu.io/u/Tony)\
**Post date:** [March 20, 2015, 8:14pm UTC](https://discourse.sensu.io/t/having-problems-with-mailer-rb/406/1 "2015-03-20T20:14:21Z")

</div>

Hi All,

I wonder if anyone can help me. I am trying to setup mailer.rb as per this document: [http://sensuapp.org/docs/0.16/adding\_a\_handler](http://sensuapp.org/docs/0.16/adding_a_handler)

Configuration

OS: CentOS 7 x86\_64

SENSU VERSION 0.17.0

I have followed the steps but cant seem to get it to work without an error. I have set sensu to use the embedded ruby version in /etc/sensu/default and dowloaded the mail gem to embedded ruby.

I have created a test log entry and am seeing the following:

> [root@ln01 ~]# cat ./test.log | /opt/sensu/embedded/bin/ruby -d/etc/sensu/handlers/mailer.rb  
> Exception `RuntimeError' at /opt/sensu/embedded/bin/ruby - invalid option -/ (-h will show valid options) /opt/sensu/embedded/bin/ruby: invalid option -/ (-h will show valid options) (RuntimeError) [root@ln01 ~]# cat ./test.log | /opt/sensu/embedded/bin/ruby -d /etc/sensu/handlers/mailer.rb Exception `LoadError’ at /opt/sensu/embedded/lib/ruby/2.0.0/rubygems.rb:1087 - cannot load such file – rubygems/defaults/operating\_system  
> Exception `LoadError' at /opt/sensu/embedded/lib/ruby/2.0.0/rubygems.rb:1096 - cannot load such file -- rubygems/defaults/ruby Exception `LoadError’ at /opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core\_ext/kernel\_require.rb:53 - cannot load such file – sensu-handler  
> Using Ext extension for JSON.  
> Exception `LoadError' at /opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53 - cannot load such file -- mail Exception `NameError’ at /opt/sensu/embedded/lib/ruby/2.0.0/psych/core\_ext.rb:16 - method `to_yaml' not defined in Object Exception `NameError’ at /opt/sensu/embedded/lib/ruby/2.0.0/psych/core\_ext.rb:29 - method `yaml_as' not defined in Module Exception `NameError’ at /opt/sensu/embedded/lib/ruby/2.0.0/psych/deprecated.rb:80 - undefined method `to_yaml_properties' for class `Object’  
> /etc/sensu/handlers/mailer.rb:26: warning: method redefined; discarding old call  
> /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/mail-2.6.3/lib/mail/network/delivery\_methods/exim.rb:44: warning: previous definition of call was here  
> /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/mixlib-cli-1.5.0/lib/mixlib/cli.rb:50: warning: instance variable @separate\_default\_options not initialized  
> Exception `Errno::ENOENT' at /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-plugin/utils.rb:14 - No such file or directory - /etc/sensu/config.json Exception `TypeError’ at /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:125 - no implicit conversion of nil into String  
> /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:125:in `+': no implicit conversion of nil into String (TypeError) from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:125:in `filter\_silenced’  
> from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:31:in `filter' from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:54:in `block in class:Handler’

I hope someone can help as this is driving me up the wall. I am also not overly familiar with Ruby. Thanks for any replies in advance!

---

<div class="post-metadata">

**Author:** ![Kyle\_Anderson](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@Kyle\_Anderson](https://discourse.sensu.io/u/Kyle_Anderson)\
**Post date:** [March 21, 2015, 2:09pm UTC](https://discourse.sensu.io/t/having-problems-with-mailer-rb/406/2 "2015-03-21T14:09:57Z")

</div>

The -d debug flag is giving you (probably) more information than you  
want. Most of that is red-herrings.

But the test.log file probably doesn't have valid event data to  
operate on. The handler isn't doing good input validation at this  
stage, so it is blowing up on the lack of @event['client']['name']

Can you pastebin your test.log? Better yet can you paste an error  
"closer" to the real-life working of the handler, like from the  
sensu-server log?

> **···**
>
> On Fri, Mar 20, 2015 at 1:14 PM, Tony \<tonyintermodesystems@gmail.com\> wrote:
> 
> > Hi All,
> > 
> > I wonder if anyone can help me. I am trying to setup mailer.rb as per this  
> > document: [http://sensuapp.org/docs/0.16/adding\_a\_handler](http://sensuapp.org/docs/0.16/adding_a_handler)
> > 
> > Configuration  
> > OS: CentOS 7 x86\_64  
> > SENSU VERSION 0.17.0
> > 
> > I have followed the steps but cant seem to get it to work without an error.  
> > I have set sensu to use the embedded ruby version in /etc/sensu/default and  
> > dowloaded the mail gem to embedded ruby.
> > 
> > I have created a test log entry and am seeing the following:
> > 
> > > [root@ln01 ~]# cat ./test.log | /opt/sensu/embedded/bin/ruby  
> > > -d/etc/sensu/handlers/mailer.rb  
> > > Exception `RuntimeError' at /opt/sensu/embedded/bin/ruby - invalid option  
> > > -/ (-h will show valid options)  
> > > /opt/sensu/embedded/bin/ruby: invalid option -/ (-h will show valid  
> > > options) (RuntimeError)  
> > > [root@ln01 ~]# cat ./test.log | /opt/sensu/embedded/bin/ruby -d  
> > > /etc/sensu/handlers/mailer.rb  
> > > Exception `LoadError' at  
> > > /opt/sensu/embedded/lib/ruby/2.0.0/rubygems.rb:1087 - cannot load such file  
> > > -- rubygems/defaults/operating\_system  
> > > Exception `LoadError' at  
> > > /opt/sensu/embedded/lib/ruby/2.0.0/rubygems.rb:1096 - cannot load such file  
> > > -- rubygems/defaults/ruby  
> > > Exception `LoadError' at  
> > > /opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core\_ext/kernel\_require.rb:53 -  
> > > cannot load such file -- sensu-handler  
> > > Using Ext extension for JSON.  
> > > Exception `LoadError' at  
> > > /opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core\_ext/kernel\_require.rb:53 -  
> > > cannot load such file -- mail  
> > > Exception `NameError' at  
> > > /opt/sensu/embedded/lib/ruby/2.0.0/psych/core\_ext.rb:16 - method `to\_yaml'  
> > > not defined in Object  
> > > Exception `NameError' at  
> > > /opt/sensu/embedded/lib/ruby/2.0.0/psych/core\_ext.rb:29 - method `yaml\_as'  
> > > not defined in Module  
> > > Exception `NameError' at  
> > > /opt/sensu/embedded/lib/ruby/2.0.0/psych/deprecated.rb:80 - undefined method  
> > > `to_yaml_properties' for class `Object'  
> > > /etc/sensu/handlers/mailer.rb:26: warning: method redefined; discarding  
> > > old call
> > > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/mail-2.6.3/lib/mail/network/delivery\_methods/exim.rb:44:  
> > > warning: previous definition of call was here
> > > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/mixlib-cli-1.5.0/lib/mixlib/cli.rb:50:  
> > > warning: instance variable @separate\_default\_options not initialized  
> > > Exception `Errno::ENOENT' at  
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-plugin/utils.rb:14  
> > > - No such file or directory - /etc/sensu/config.json  
> > > Exception `TypeError' at  
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:125  
> > > - no implicit conversion of nil into String
> > > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:125:in  
> > > `+': no implicit conversion of nil into String (TypeError)  
> > > from  
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:125:in  
> > > `filter\_silenced'  
> > > from  
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:31:in  
> > > `filter'  
> > > from  
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:54:in  
> > > `block in \<class:Handler\>'
> > 
> > I hope someone can help as this is driving me up the wall. I am also not  
> > overly familiar with Ruby. Thanks for any replies in advance!
