-
Notifications
You must be signed in to change notification settings - Fork 41
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
Adds support for WiredTiger Engine #61
base: master
Are you sure you want to change the base?
Changes from 6 commits
6f87edd
926efbe
18b78d7
174b1cc
bfb4605
32f2e48
9884b14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ This CHANGELOG follows the format located [here](https://github.com/sensu-plugin | |
|
||
## [Unreleased] | ||
|
||
## [2.0.3] - 2018-09-14 | ||
### New Feature | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When adding a new feature we use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to update it. |
||
- Adds WiredTiger Matrics (@parin921996) | ||
|
||
## [2.0.2] - 2018-03-17 | ||
### Fixed | ||
- renamed library file `metics` to `metrics` and updated all refrences in code to it (@majormoses) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,26 @@ def replicaset_status | |
end | ||
end | ||
|
||
def wiretiger_metrics(wiredtiger, server_metrics) | ||
# wiredtiger = server_status['wiredTiger'] | ||
# data_handle Metrics | ||
wiredtiger.each do |key1, value1| | ||
next unless value1.is_a? Hash | ||
wiredtiger[key1].each do |key2, value2| | ||
if value2.is_a? Hash | ||
wiredtiger[key1][key2].each do |key3, value3| | ||
server_metrics['wiredTiger.' + key1.gsub(/(,|\s|-|\()+/, '_').tr(')', '') + '.' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like we are repeating the same logic/regex here can we make a function and call that instead I think it would make the code a lot more readable. Maybe something along the lines of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking to write json flattener but current use case was quite specific so I quickly submit this PR. But I kinda liked the idea. |
||
key2.gsub(/(,|\s|-|\()+/, '_').tr(')', '') + '.' + key3.gsub(/(,|\s|-|\()+/, '_').tr(')', '')] = value3 | ||
end | ||
else | ||
server_metrics['wiredTiger.' + key1.gsub(/(,|\s|-|\()+/, '_').tr(')', '') + | ||
'.' + key2.gsub(/(,|\s|-|\()+/, '_').tr(')', '')] = value2 | ||
end | ||
end | ||
end | ||
server_metrics | ||
end | ||
|
||
# Fetches metrics for the server we are connected to. | ||
# | ||
# @return [Mash] the metrics for the server. | ||
|
@@ -200,9 +220,8 @@ def server_metrics | |
|
||
# Extra info | ||
extra_info = server_status['extra_info'] | ||
server_metrics['mem.heap_usage_bytes'] = extra_info['heap_usage_bytes'] | ||
server_metrics['mem.pageFaults'] = extra_info['page_faults'] | ||
|
||
server_metrics['mem.heap_size_bytes'] = extra_info['heap_size'] | ||
# Global Lock | ||
global_lock = server_status['globalLock'] | ||
server_metrics['lock.totalTime'] = global_lock['totalTime'] | ||
|
@@ -217,7 +236,6 @@ def server_metrics | |
if Gem::Version.new(mongo_version) < Gem::Version.new('3.0.0') | ||
index_counters = server_status['indexCounters'] | ||
index_counters = server_status['indexCounters']['btree'] unless server_status['indexCounters']['btree'].nil? | ||
|
||
server_metrics['indexes.missRatio'] = sprintf('%.5f', index_counters['missRatio']).to_s | ||
server_metrics['indexes.hits'] = index_counters['hits'] | ||
server_metrics['indexes.misses'] = index_counters['misses'] | ||
|
@@ -255,23 +273,28 @@ def server_metrics | |
server_metrics['network.bytesOut'] = network['bytesOut'] | ||
server_metrics['network.numRequests'] = network['numRequests'] | ||
|
||
# OpLatencies | ||
if server_status.key?('opLatencies') | ||
oplatencies = server_status['opLatencies'] | ||
server_metrics['oplatencies.read.latency'] = oplatencies['reads']['latency'] | ||
server_metrics['oplatencies.read.operations'] = oplatencies['reads']['ops'] | ||
server_metrics['oplatencies.write.latency'] = oplatencies['writes']['latency'] | ||
server_metrics['oplatencies.write.operations'] = oplatencies['writes']['ops'] | ||
server_metrics['oplatencies.command.latency'] = oplatencies['commands']['latency'] | ||
server_metrics['oplatencies.command.operations'] = oplatencies['commands']['ops'] | ||
end | ||
|
||
# Opcounters | ||
opcounters = server_status['opcounters'] | ||
server_metrics['opcounters.insert'] = opcounters['insert'] | ||
server_metrics['opcounters.query'] = opcounters['query'] | ||
server_metrics['opcounters.update'] = opcounters['update'] | ||
server_metrics['opcounters.delete'] = opcounters['delete'] | ||
server_metrics['opcounters.getmore'] = opcounters['getmore'] | ||
server_metrics['opcounters.command'] = opcounters['command'] | ||
opcounters.each do |key, value| | ||
server_metrics['opcounters.' + key] = value | ||
end | ||
|
||
# Opcounters Replication | ||
opcounters_repl = server_status['opcountersRepl'] | ||
server_metrics['opcountersRepl.insert'] = opcounters_repl['insert'] | ||
server_metrics['opcountersRepl.query'] = opcounters_repl['query'] | ||
server_metrics['opcountersRepl.update'] = opcounters_repl['update'] | ||
server_metrics['opcountersRepl.delete'] = opcounters_repl['delete'] | ||
server_metrics['opcountersRepl.getmore'] = opcounters_repl['getmore'] | ||
server_metrics['opcountersRepl.command'] = opcounters_repl['command'] | ||
opcounters_repl.each do |key, value| | ||
server_metrics['opcountersRepl.' + key] = value | ||
end | ||
|
||
# Memory | ||
mem = server_status['mem'] | ||
|
@@ -280,6 +303,18 @@ def server_metrics | |
server_metrics['mem.mapped'] = mem['mapped'] | ||
server_metrics['mem.mappedWithJournal'] = mem['mappedWithJournal'] | ||
|
||
# Malloc | ||
if server_status.key?('wiredTiger') | ||
malloc = server_status['tcmalloc'] | ||
server_metrics['mem.heap_size_bytes'] = malloc['generic']['heap_size'] | ||
server_metrics['mem.current_allocated_bytes'] = malloc['generic']['current_allocated_bytes'] | ||
end | ||
# WiredTiger specific Metrics | ||
if server_status.key?('wiredTiger') | ||
wiredtiger = server_status['wiredTiger'] | ||
server_metrics = wiretiger_metrics(wiredtiger, server_metrics) | ||
end | ||
|
||
# Metrics (documents) | ||
document = server_status['metrics']['document'] | ||
server_metrics['metrics.document.deleted'] = document['deleted'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general the versioning and dating are left to the maintainers for several reasons:
2.1.0
) per our versioning guidelines