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

Updating to work with (>=jewel) #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 11 additions & 5 deletions jobs/pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)

Expand Down
45 changes: 16 additions & 29 deletions jobs/traffic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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')
Expand All @@ -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',
{
Expand Down