bin/metrics-cassandra-graphite.rb in sensu-plugins-cassandra-2.0.1 vs bin/metrics-cassandra-graphite.rb in sensu-plugins-cassandra-2.0.2

- old
+ new

@@ -192,46 +192,46 @@ def parse_info info = nodetool_cmd('info') # #YELLOW # TODO: come back and refactor me to be better info.each_line do |line| # rubocop:disable Metrics/BlockLength - if m == line.match(/^Exceptions\s*:\s+([0-9]+)$/) + if (m = line.match(/^Exceptions\s*:\s+([0-9]+)$/)) output "#{config[:scheme]}.exceptions", m[1], @timestamp end - if m =+ line.match(/^Load\s*:\s+([0-9.]+)\s+([KMGT]i?B|bytes)$/)# rubocop:disable all + if (m = line.match(/^Load\s*:\s+([0-9.]+)\s+([KMGT]i?B|bytes)$/)) output "#{config[:scheme]}.load", convert_to_bytes(m[1], m[2]), @timestamp end - if m == line.match(/^Uptime[^:]+:\s+(\d+)$/) + if (m = line.match(/^Uptime[^:]+:\s+(\d+)$/)) output "#{config[:scheme]}.uptime", m[1], @timestamp end - if m == line.match(/^Heap Memory[^:]+:\s+([0-9.]+)\s+\/\s+([0-9.]+)$/)# rubocop:disable all + if (m = line.match(/^Heap Memory[^:]+:\s+([0-9.]+)\s+\/\s+([0-9.]+)$/)) output "#{config[:scheme]}.heap.used", convert_to_bytes(m[1], 'MB'), @timestamp output "#{config[:scheme]}.heap.total", convert_to_bytes(m[2], 'MB'), @timestamp end # v1.1+ - if m == line.match(/^Key Cache[^:]+: size ([0-9]+) \(bytes\), capacity ([0-9]+) \(bytes\), ([0-9]+) hits, ([0-9]+) requests/)# rubocop:disable all + if (m = line.match(/^Key Cache[^:]+: size ([0-9]+) \(bytes\), capacity ([0-9]+) \(bytes\), ([0-9]+) hits, ([0-9]+) requests/)) output "#{config[:scheme]}.key_cache.size", m[1], @timestamp output "#{config[:scheme]}.key_cache.capacity", m[2], @timestamp output "#{config[:scheme]}.key_cache.hits", m[3], @timestamp output "#{config[:scheme]}.key_cache.requests", m[4], @timestamp end # cassandra nodetool v3.0+ Changed the key cache output # Key Cache : entries 569669, size 100 MiB, capacity 100 MiB, 35689224 hits, 70654365 requests, 0.505 recent hit rate, 14400 save period in seconds # Key Cache : entries 13291, size 7.83 MB, capacity 50 MB, 119444 hits, 139720 requests, 0.855 recent hit rate, 14400 save period in seconds - if m == line.match(/^Key Cache[^:]+: entries ([0-9]+), size ([-+]?[0-9]*\.?[0-9]+) ([KMGT]i?B|bytes), capacity ([-+]?[0-9]*\.?[0-9]+) ([KMGT]i?B|bytes), ([0-9]+) hits, ([0-9]+) requests, ([-+]?[0-9]*\.?[0-9]+) recent hit rate/)# rubocop:disable all + if (m = line.match(/^Key Cache[^:]+: entries ([0-9]+), size ([-+]?[0-9]*\.?[0-9]+) ([KMGT]i?B|bytes), capacity ([-+]?[0-9]*\.?[0-9]+) ([KMGT]i?B|bytes), ([0-9]+) hits, ([0-9]+) requests, ([-+]?[0-9]*\.?[0-9]+) recent hit rate/)) # rubocop:disable Metrics/LineLength output "#{config[:scheme]}.key_cache.size", convert_to_bytes(m[2], m[3]), @timestamp output "#{config[:scheme]}.key_cache.capacity", convert_to_bytes(m[4], m[5]), @timestamp output "#{config[:scheme]}.key_cache.hits", m[6], @timestamp output "#{config[:scheme]}.key_cache.requests", m[7], @timestamp output "#{config[:scheme]}.key_cache.hit_rate", m[8], @timestamp end - if m == line.match(/^Row Cache[^:]+: size ([0-9]+) \(bytes\), capacity ([0-9]+) \(bytes\), ([0-9]+) hits, ([0-9]+) requests/)# rubocop:disable all + if (m = line.match(/^Row Cache[^:]+: size ([0-9]+) \(bytes\), capacity ([0-9]+) \(bytes\), ([0-9]+) hits, ([0-9]+) requests/)) output "#{config[:scheme]}.row_cache.size", m[1], @timestamp output "#{config[:scheme]}.row_cache.capacity", m[2], @timestamp output "#{config[:scheme]}.row_cache.hits", m[3], @timestamp output "#{config[:scheme]}.row_cache.requests", m[4], @timestamp end