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

- old
+ new

@@ -187,51 +187,52 @@ # Row Cache : size 7947581 (bytes), capacity 1048576000 (bytes), 84005 hits, 104727 requests, 0.701 recent hit rate, 0 save period in seconds # # According to io/util/FileUtils.java units for load are: # TB/GB/MB/KB/bytes # - def parse_info# rubocop:disable all + def parse_info info = nodetool_cmd('info') # #YELLOW - info.each_line do |line| - if m = line.match(/^Exceptions\s*:\s+([0-9]+)$/)# rubocop:disable all + # 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]+)$/) 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)$/)# rubocop:disable all output "#{config[:scheme]}.load", convert_to_bytes(m[1], m[2]), @timestamp end - if m = line.match(/^Uptime[^:]+:\s+(\d+)$/)# rubocop:disable all + 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.]+)$/)# rubocop:disable all 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/)# rubocop:disable all 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 all 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/)# rubocop:disable all 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 @@ -360,10 +361,10 @@ num_indents = line.count("\t") if m = line.match(/^Keyspace\s?:\s+(\w+)$/)# rubocop:disable all keyspace = m[1] elsif m = line.match(/\t\tColumn Family[^:]*:\s+(\w+)$/)# rubocop:disable all cf = m[1] - elsif num_indents == 0 + elsif num_indents.zero? # keyspace = nil cf = nil elsif num_indents == 2 && !cf.nil? # a column family metric # #YELLOW