sensu-handler failing to load in mailer.rb

Hi all, I am new to Sensu, just installed it and am evaluating at the moment. As we have a need like most shops to get fairly verbose notifications via SMS/email, I also installed the mailer.rb handler from the Sensu Community Plugins. In it, it requires sensu-handler, which I thought was part of the installed gem sensu-plugin and in fact I can find it in the embedded path:

find /opt/sensu/embedded -name “sensu-handler

/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb

So the error I’m getting is:

/etc/sensu/handlers/mailer.rb:12:in `require’: no such file to load – sensu-handler (LoadError)\n"}"

But if I change to EMBEDDED_RUBY=true in /etc/init.d/sensu-service and set the shebang in mailer.rb to /opt/sensu/embedded/bin/ruby, I get errors on another required gem, mail, which I have installed along with other dependencies.

{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb",“mail_from”:“sensu@xxx”,“mail_to”:“xxx@xxx.com”,“name”:“mailer”},“output”:"/opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require’: cannot load such file – mail (LoadError)\n"}

{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb",“mail_from”:“sensu@xxx”,“mail_to”:“name@xx.com”,“name”:“mailer”},“output”:"\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require’\n"}

{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb",“mail_from”:“sensu@xxx”,“mail_to”:“name@xxx.com”,“name”:“mailer”},“output”:"\tfrom /etc/sensu/handlers/mailer.rb:13:in `’\n"}

So I’m guessing that being new to Ruby there is some path/environment issue going on here. I’ve looked at other similar handlers, but they all also require mail and sensu-handler.

Thanks in advance!

Hey,

I believe resetting the shbang should be unnecessary, as ‘#!/usr/bin/env ruby’ should pull it from the environment when EMBEDDED_RUBY=true is set.

And you installed the ‘mail’ gem to the embedded ruby, not system ruby (/opt/sensu/embedded/bin/gem list mail)?

···

On Wednesday, February 5, 2014 9:18:31 AM UTC-8, Michael M wrote:
Hi all, I am new to Sensu, just installed it and am evaluating at the moment. As we have a need like most shops to get fairly verbose notifications via SMS/email, I also installed the mailer.rb handler from the Sensu Community Plugins. In it, it requires sensu-handler, which I thought was part of the installed gem sensu-plugin and in fact I can find it in the embedded path:

find /opt/sensu/embedded -name “sensu-handler
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb

So the error I’m getting is:
/etc/sensu/handlers/mailer.rb:12:in `require’: no such file to load – sensu-handler (LoadError)\n"}"

But if I change to EMBEDDED_RUBY=true in /etc/init.d/sensu-service and set the shebang in mailer.rb to /opt/sensu/embedded/bin/ruby, I get errors on another required gem, mail, which I have installed along with other dependencies.

{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb",“mail_from”:“sensu@xxx”,“mail_to”:“x…@xxx.com”,“name”:“mailer”},“output”:"/opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require’: cannot load such file – mail (LoadError)\n"}

{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb",“mail_from”:“sensu@xxx”,“mail_to”:“na…@xx.com”,“name”:“mailer”},“output”:"\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require’\n"}

{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb",“mail_from”:“sensu@xxx”,“mail_to”:“na…@xxx.com”,“name”:“mailer”},“output”:"\tfrom /etc/sensu/handlers/mailer.rb:13:in `’\n"}

So I’m guessing that being new to Ruby there is some path/environment issue going on here. I’ve looked at other similar handlers, but they all also require mail and sensu-handler.

Thanks in advance!

Hi Nick,

Yes, it is installed in the embedded ruby:

/opt/sensu/embedded/bin/gem list mail

*** LOCAL GEMS ***

mail (2.5.4)

Thanks

···

On Wednesday, February 5, 2014 9:18:31 AM UTC-8, Michael M wrote:

Hi all, I am new to Sensu, just installed it and am evaluating at the moment. As we have a need like most shops to get fairly verbose notifications via SMS/email, I also installed the mailer.rb handler from the Sensu Community Plugins. In it, it requires sensu-handler, which I thought was part of the installed gem sensu-plugin and in fact I can find it in the embedded path:

find /opt/sensu/embedded -name “sensu-handler

/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb

So the error I’m getting is:

/etc/sensu/handlers/mailer.rb:12:in `require’: no such file to load – sensu-handler (LoadError)\n"}"

But if I change to EMBEDDED_RUBY=true in /etc/init.d/sensu-service and set the shebang in mailer.rb to /opt/sensu/embedded/bin/ruby, I get errors on another required gem, mail, which I have installed along with other dependencies.

{“type”:“pipe”,“command”:“/etc/sensu/handlers/mailer.rb”,“mail_from”:“sensu@xxx”,“mail_to”:"xxx@xxx.com",“name”:“mailer”},“output”:“/opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require’: cannot load such file – mail (LoadError)\n”}

{“type”:“pipe”,“command”:“/etc/sensu/handlers/mailer.rb”,“mail_from”:“sensu@xxx”,“mail_to”:"name@xx.com",“name”:“mailer”},“output”:“\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require’\n”}

{“type”:“pipe”,“command”:“/etc/sensu/handlers/mailer.rb”,“mail_from”:“sensu@xxx”,“mail_to”:"name@xxx.com",“name”:“mailer”},“output”:“\tfrom /etc/sensu/handlers/mailer.rb:13:in `'\n”}

So I’m guessing that being new to Ruby there is some path/environment issue going on here. I’ve looked at other similar handlers, but they all also require mail and sensu-handler.

Thanks in advance!

Hmm. Since that is running at the start of the file, you could probably reproduce outside of Sensu, just by running ‘/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/mailer.rb’. If that complains, you might be able to look at the load path (puts $:.inspect). You could also try removing the line “gem ‘mail’, ‘~> 2.5.4’” from before the require. Happy debugging!

-Nick

···

On Wednesday, February 5, 2014 9:38:57 AM UTC-8, Michael M wrote:
Hi Nick,

Yes, it is installed in the embedded ruby:
/opt/sensu/embedded/bin/gem list mail

*** LOCAL GEMS ***

mail (2.5.4)

Thanks

On Wednesday, February 5, 2014 9:18:31 AM UTC-8, Michael M wrote:
Hi all, I am new to Sensu, just installed it and am evaluating at the moment. As we have a need like most shops to get fairly verbose notifications via SMS/email, I also installed the mailer.rb handler from the Sensu Community Plugins. In it, it requires sensu-handler, which I thought was part of the installed gem sensu-plugin and in fact I can find it in the embedded path:

find /opt/sensu/embedded -name “sensu-handler
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb

So the error I’m getting is:
/etc/sensu/handlers/mailer.rb:12:in `require’: no such file to load – sensu-handler (LoadError)\n"}"

But if I change to EMBEDDED_RUBY=true in /etc/init.d/sensu-service and set the shebang in mailer.rb to /opt/sensu/embedded/bin/ruby, I get errors on another required gem, mail, which I have installed along with other dependencies.

{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb",“mail_from”:“sensu@xxx”,“mail_to”:“x…@xxx.com”,“name”:“mailer”},“output”:"/opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require’: cannot load such file – mail (LoadError)\n"}

{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb",“mail_from”:“sensu@xxx”,“mail_to”:“na…@xx.com”,“name”:“mailer”},“output”:"\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require’\n"}

{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb",“mail_from”:“sensu@xxx”,“mail_to”:“na…@xxx.com”,“name”:“mailer”},“output”:"\tfrom /etc/sensu/handlers/mailer.rb:13:in `’\n"}

So I’m guessing that being new to Ruby there is some path/environment issue going on here. I’ve looked at other similar handlers, but they all also require mail and sensu-handler.

Thanks in advance!