diff --git a/jobs/pool.rb b/jobs/pool.rb index c801d96..bfced4f 100644 --- a/jobs/pool.rb +++ b/jobs/pool.rb @@ -17,15 +17,21 @@ result = %x( timeout 3 ceph df -f json ) # update total storage widget + # *updated this to work with Jewel release storage = JSON.parse(result) - used = storage['stats']['total_used'].to_i - total = storage['stats']['total_space'].to_i + used = storage['stats']['total_used_bytes'].to_i + total = storage['stats']['total_bytes'].to_i + + #Percentage was not showing the right ratio, changed vaule by replacing pretty with .to_s('TB') + #this really should be done with the Max value as well to make sure no matter the size + # Both values are in the same size value send_event('storage', { - value: Filesize.from("#{used} KB").pretty.split(' ').first.to_f, + value: Filesize.from("#{used} B").to_s('TB').split(' ').first.to_f, min: 0, - max: Filesize.from("#{total} KB").pretty.split(' ').first.to_f, - moreinfo: Filesize.from("#{used} KB").pretty + " out of " + Filesize.from("#{total} KB").pretty + max: Filesize.from("#{total} B").pretty.split(' ').first.to_f, + #max:storage['stats']['total_bytes'].pretty.to_i, + moreinfo: Filesize.from("#{used} B").pretty + " out of " + Filesize.from("#{total} B").pretty } ) diff --git a/jobs/traffic.rb b/jobs/traffic.rb index 1f25f07..04d33f9 100644 --- a/jobs/traffic.rb +++ b/jobs/traffic.rb @@ -17,13 +17,14 @@ end # detect if ceph osd pool stats is available (>=emperor) -result = %x( ceph osd pool stats -f json 2>&1) -begin - poolstats = JSON.parse(result) - poolstats_available = true -rescue - poolstats_available = false -end +# pool stats no longer needed, commenting this out (>=jewel) +#result = %x( ceph osd pool stats -f json 2>&1) +#begin +# poolstats = JSON.parse(result) +# poolstats_available = false +#rescue +# poolstats_available = false +#end SCHEDULER.every '2s' do @@ -35,25 +36,9 @@ points_iops << { x: points_iops.last[:x] + 1, y: 0 } - # if ceph osd pool stats is available, get the rw stats from that. - # otherwise, use ceph status, available in dumpling. - if poolstats_available - result = %x( timeout 2 ceph osd pool stats -f json ) - poolstats = JSON.parse(result) - - poolstats.each do |poolstat| - if poolstat['client_io_rate'].has_key?('read_bytes_sec') - points_rd.last[:y] = points_rd.last[:y] + poolstat['client_io_rate']['read_bytes_sec'].to_i - end - if poolstat['client_io_rate'].has_key?('write_bytes_sec') - points_wr.last[:y] = points_wr.last[:y] + poolstat['client_io_rate']['write_bytes_sec'].to_i - end - if poolstat['client_io_rate'].has_key?('op_per_sec') - points_iops.last[:y] = points_iops.last[:y] + poolstat['client_io_rate']['op_per_sec'].to_i - end - end - else - result = %x( timeout 2 ceph status -f json ) + # if cep) osd pool stats is available, get the rw stats from that. + # otherwise) use ceph status, available in dumpling. + result = %x( timeout 2 ceph -s -f json ) status = JSON.parse(result) if status['pgmap'].has_key?('read_bytes_sec') @@ -62,10 +47,12 @@ if status['pgmap'].has_key?('write_bytes_sec') points_wr.last[:y] = points_wr.last[:y] + status['pgmap']['write_bytes_sec'].to_i end - if status['pgmap'].has_key?('op_per_sec') - points_iops.last[:y] = points_iops.last[:y] + status['pgmap']['op_per_sec'].to_i + if status['pgmap'].has_key?('write_op_per_sec') + points_iops.last[:y] = points_iops.last[:y] + status['pgmap']['write_op_per_sec'].to_i + end + if status['pgmap'].has_key?('read_op_per_sec') + points_iops.last[:y] = points_iops.last[:y] + status['pgmap']['read_op_per_sec'].to_i end - end send_event('traffic', {