Created
June 15, 2015 04:12
-
-
Save jessereynolds/afc9b2498650e32ed6fc to your computer and use it in GitHub Desktop.
fix heartbeat in all rrd files to 120 seconds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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