Testing Sensu Plugin - Error

When testing a Sensu Plugin to check mysql, downloaded from sensu giuthub plugins, I get this error:

[user@linux]# ruby mysql-alive.rb

Sensu::Plugin::CLI: Not implemented! You should override Sensu::Plugin::CLI#run.

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’: no such file to load – mysql (LoadError)

from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’

from mycheck.rb:5

The beginning of the plugin is like others that do not throw this error.

#!/usr/bin/env ruby

require ‘rubygems’ if RUBY_VERSION < ‘1.9.0’

require ‘sensu-plugin/check/cli’

require ‘mysql’

class CheckMySQL < Sensu::Plugin::Check::CLI

I am new to sensu and ruby and can’t figure this out.

Any help would be appreciated.

Also how would I pass options to the mysql-alive.rb script?

There are options in the script and I do not know how to pass the required parameters into it.

Thanks.

Sensu installs its own ruby that you can use for the plugins. Look for EMBEDDED_RUBY in the docs. If you put EMBEDDED_RUBY=true in the environment, it will use its ruby instance to run the plugins.

You can find the embedded ruby at /opt/sensu/embedded/bin (by default) along with a rubygems manager there. I sometimes use the installed embedded ruby and gem to install gems required by other plugins.

One alternative is to change the hashbang line to use /opt/sensu/embedded/bin/ruby instead of the system ruby. Not a preference, but it works.

Does that help a little?

Mojo

···

On Sun, Apr 20, 2014 at 6:07 AM, Jesse V jvardam@outlook.com wrote:

When testing a Sensu Plugin to check mysql, downloaded from sensu giuthub plugins, I get this error:

[user@linux]# ruby mysql-alive.rb

Sensu::Plugin::CLI: Not implemented! You should override Sensu::Plugin::CLI#run.

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’: no such file to load – mysql (LoadError)

from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’

from mycheck.rb:5

The beginning of the plugin is like others that do not throw this error.

#!/usr/bin/env ruby

require ‘rubygems’ if RUBY_VERSION < ‘1.9.0’

require ‘sensu-plugin/check/cli’

require ‘mysql’

class CheckMySQL < Sensu::Plugin::Check::CLI

I am new to sensu and ruby and can’t figure this out.

Any help would be appreciated.

Also how would I pass options to the mysql-alive.rb script?

There are options in the script and I do not know how to pass the required parameters into it.

Thanks.

It should be noted that if you require the mysql gem, you will need it installed by the embedded rubygems that sensu provides (if you are using the EMBEDDED_RUBY).

If you are not using the embedded rubygems, you will need the mysql gem installed on the system ruby.

To pass options into sensu plugins, you add command line params in the “command” definition for the check.

The example in the docs adds some params for check-procs: http://sensuapp.org/docs/0.12/adding_a_check

···

On Mon, Apr 21, 2014 at 8:15 AM, Mojo mojo.la@gmail.com wrote:

Sensu installs its own ruby that you can use for the plugins. Look for EMBEDDED_RUBY in the docs. If you put EMBEDDED_RUBY=true in the environment, it will use its ruby instance to run the plugins.

You can find the embedded ruby at /opt/sensu/embedded/bin (by default) along with a rubygems manager there. I sometimes use the installed embedded ruby and gem to install gems required by other plugins.

One alternative is to change the hashbang line to use /opt/sensu/embedded/bin/ruby instead of the system ruby. Not a preference, but it works.

Does that help a little?

Mojo

On Sun, Apr 20, 2014 at 6:07 AM, Jesse V jvardam@outlook.com wrote:

When testing a Sensu Plugin to check mysql, downloaded from sensu giuthub plugins, I get this error:

[user@linux]# ruby mysql-alive.rb

Sensu::Plugin::CLI: Not implemented! You should override Sensu::Plugin::CLI#run.

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’: no such file to load – mysql (LoadError)

from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’

from mycheck.rb:5

The beginning of the plugin is like others that do not throw this error.

#!/usr/bin/env ruby

require ‘rubygems’ if RUBY_VERSION < ‘1.9.0’

require ‘sensu-plugin/check/cli’

require ‘mysql’

class CheckMySQL < Sensu::Plugin::Check::CLI

I am new to sensu and ruby and can’t figure this out.

Any help would be appreciated.

Also how would I pass options to the mysql-alive.rb script?

There are options in the script and I do not know how to pass the required parameters into it.

Thanks.