sensu-plugins / sensu-plugins-mongodb

This plugin provides native MongoDB instrumentation for monitoring and metrics collection, including: service health, database connectivity, replication lag/status, `oplog` monitoring, collection-specific metrics, and more.

Home Page:http://sensu-plugins.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

uninitialized constant MongoDB::MongoClient

runningman84 opened this issue · comments

This script does not work anymore using the latest mongo gem:

root@ip-172-31-25-141:/etc/sensu/plugins# /opt/sensu/embedded/bin/ruby mongodb-metrics.rb 
Check failed to run: uninitialized constant MongoDB::MongoClient, ["mongodb-metrics.rb:68:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-plugin/cli.rb:56:in `block in <class:CLI>'"]
root@ip-172-31-25-141:/etc/sensu/plugins# /opt/sensu/embedded/bin/gem list

*** LOCAL GEMS ***

amq-protocol (1.9.2)
amqp (1.5.0)
async_sinatra (1.0.0)
bigdecimal (1.2.0)
bson (3.0.0, 1.12.0)
bson_ext (1.12.0)
childprocess (0.5.3)
daemons (1.2.1)
domain_name (0.5.23)
em-redis-unified (0.6.0)
em-worker (0.0.2)
eventmachine (1.0.3)
ffi (1.9.8)
http-cookie (1.0.2)
io-console (0.4.2)
ipaddress (0.8.0)
json (1.7.7)
mime-types (2.4.3)
minitest (4.3.2)
mixlib-cli (1.5.0)
mixlib-config (2.1.0)
mixlib-log (1.6.0)
mixlib-shellout (2.0.1)
mongo (2.0.1)
multi_json (1.11.0)
netrc (0.10.3)
ohai (6.16.0)
psych (2.0.0)
rack (1.6.0)
rack-protection (1.5.3)
rake (0.9.6)
rdoc (4.0.0)
rest-client (1.8.0)
sensu (0.17.0)
sensu-em (2.4.1)
sensu-extension (1.1.2)
sensu-extensions (1.2.0)
sensu-logger (1.0.0)
sensu-plugin (1.1.0)
sensu-settings (1.3.0)
sensu-spawn (1.1.0)
sensu-transport (2.4.0)
sinatra (1.3.5)
systemu (2.6.4, 2.5.2)
test-unit (2.0.0.0)
thin (1.5.0)
tilt (1.4.1)
unf (0.1.4)
unf_ext (0.0.6)
uuidtools (2.1.4)
yajl-ruby (1.2.1)

I have the same issue, I think this is caused by ruby 2.0 and latest mongo-ruby-driver, there is changes on methods so that's the problem.

I've installed mongo gem v 1.9.2, and appears to be working now but I'm getting a warning in stderror:

      ** Notice: The native BSON extension was not loaded. **

      For optimal performance, use of the BSON extension is recommended.

      To enable the extension make sure ENV['BSON_EXT_DISABLED'] is not set
      and run the following command:

        gem install bson_ext

      If you continue to receive this message after installing, make sure that
      the bson_ext gem is in your load path.

We can always pin the the earlier version of the gem as a quick fix and then make the necessary changes in the plugins to ensure they work.

@mattyjones PR to pin versions: #7

Actually, all 1.x versions of gem mongo are working. I've tested mongo 1.12.4 and it worked fine. Do you have a way to change dependency to <2.0 ? or ==1.* ?

e.g. I've installed mongo by using gem install mongo -v '< 2'

I'd prefer to pin to specific versions so we control exactly what gets installed. The 0.0.7 release pins mongo to 1.12.3. We can certainly update the pin to 1.12.4 and release a new version. It would also be nice if the plugin was updated to work with 2.x.

Is this still an issue with the latest release?

With the latest release, it is no longer an issue with mongo 1.12.4 (as described in deps file), but issue is still present for 2.x.

Thanks for checking. The plugin will need to be updated to work with 2.0 as it's a complete rewrite and not backwards compatible. I'm going to close this and we can open a new issue for 2.0.