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.
http://sensu-plugins.io
MIT License
9 stars 41 forks source link

metrics-mongodb.rb support for Mongo 3 #15

Closed jhsubscribe closed 8 years ago

jhsubscribe commented 9 years ago

metrics-mongodb.rb will need a version check added to stop it erroring on mongo 3

http://docs.mongodb.org/manual/reference/command/serverStatus/ Changed in version 3.0: The server status output no longer includes the workingSet, indexCounters, and recordStats sections.

Removing the 9 row "if" section which references indexCounters causes it to work on Mongo 3 so I suspect the quickest fix would be to wrap this in a "if serverStatus.version != 3" ?

jhsubscribe commented 9 years ago

I'm just writing a pull request for this....

1) Version comparison http://stackoverflow.com/questions/2051229/how-to-compare-versions-in-ruby

The Gem::Version.new('x.y.z') method for comparing the current version to 3.0.0 seems the cleanest so I've used this but depends on Ruby 2 and above. Let me know if you want me to change this to something 1.x compatible.

2) Changlog The latest released version is 0.0.4 but the changelog has entries under 0.0.5 and 0.0.6 and the version.rb in libraries seems to reference 0.0.6?. I've put mine under "unreleased" for now, let me know if that's incorrect?

jhsubscribe commented 9 years ago

FYI, I've asked Mongo support about this and they directed me to .. https://jira.mongodb.org/browse/SERVER-16378

Basically they recommend monitoring page_faults instead of index counters so we should probably add this in to the reported stats?

analytically commented 9 years ago

Yes, sounds good, can you change your PR?

analytically commented 9 years ago

I'll roll up all changes into one release.

jhsubscribe commented 9 years ago

I was just about to add it and noticed it was already there... server_metrics['mem.pageFaults'] = server_status['extra_info']['page_faults']

eheydrick commented 8 years ago

Fixed in 0.0.7. Thanks @jhsubscribe!