Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update metrics.rb #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions lib/sensu-plugins-mongodb/metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,13 @@ def server_metrics
server_metrics['metrics.repl.network.getmores_totalMillis'] = repl['network']['getmores']['totalMillis']
server_metrics['metrics.repl.network.ops'] = repl['network']['ops']
server_metrics['metrics.repl.network.readersCreated'] = repl['network']['readersCreated']
server_metrics['metrics.repl.preload.docs_num'] = repl['preload']['docs']['num']
server_metrics['metrics.repl.preload.docs_totalMillis'] = repl['preload']['docs']['totalMillis']
server_metrics['metrics.repl.preload.indexes_num'] = repl['preload']['indexes']['num']
server_metrics['metrics.repl.preload.indexes_totalMillis'] = repl['preload']['indexes']['totalMillis']

if repl.key?('preload')
server_metrics['metrics.repl.preload.docs_num'] = repl['preload']['docs']['num']
server_metrics['metrics.repl.preload.docs_totalMillis'] = repl['preload']['docs']['totalMillis']
server_metrics['metrics.repl.preload.indexes_num'] = repl['preload']['indexes']['num']
server_metrics['metrics.repl.preload.indexes_totalMillis'] = repl['preload']['indexes']['totalMillis']
end

# Metrics (replicaset status)
# MongoDB will fail if not running with --replSet, hence the check for nil
unless replicaset_status.nil?
Expand All @@ -331,10 +333,12 @@ def server_metrics

# Metrics (storage)
if Gem::Version.new(mongo_version) >= Gem::Version.new('2.6.0')
freelist = server_status['metrics']['storage']['freelist']
server_metrics['metrics.storage.freelist.search_bucketExhauseted'] = freelist['search']['bucketExhausted']
server_metrics['metrics.storage.freelist.search_requests'] = freelist['search']['requests']
server_metrics['metrics.storage.freelist.search_scanned'] = freelist['search']['scanned']
if server_status.key?('metrics.storage')
freelist = server_status['metrics']['storage']['freelist']
server_metrics['metrics.storage.freelist.search_bucketExhauseted'] = freelist['search']['bucketExhausted']
server_metrics['metrics.storage.freelist.search_requests'] = freelist['search']['requests']
server_metrics['metrics.storage.freelist.search_scanned'] = freelist['search']['scanned']
end
end

# Metrics (ttl)
Expand Down