Skip to content

Instantly share code, notes, and snippets.

@jessereynolds
Created June 15, 2015 04:12
Show Gist options
  • Save jessereynolds/afc9b2498650e32ed6fc to your computer and use it in GitHub Desktop.
Save jessereynolds/afc9b2498650e32ed6fc to your computer and use it in GitHub Desktop.
fix heartbeat in all rrd files to 120 seconds
#!/usr/bin/env ruby
# ds[value].minimal_heartbeat = 120
heartbeat = "120"
file = ARGV[0]
info = `rrdtool info '#{file}' | grep minimal_heartbeat`
puts "examining #{file}"
info.split("\n").each {|line|
ds = line.split('[', 2).last.split(']', 2).first
old_heartbeat = line.split('= ', 2).last
if old_heartbeat == heartbeat
puts "#{ds} matches desired heartbeat of #{heartbeat} already, skipping"
else
puts "#{ds} has heartbeat of #{old_heartbeat}, setting to #{heartbeat}"
system("rrdtool tune '#{file}' --heartbeat #{ds}:120")
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment