Last active
December 15, 2015 05:59
-
-
Save dcarley/5212980 to your computer and use it in GitHub Desktop.
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
#!/bin/env ruby | |
require 'fileutils' | |
require 'pathname' | |
ARGV.each do |old_name| | |
match = old_name.match(/^(.+)\/([^\/]+_production)\/(.*?)_?(nginx|varnish)\/(.+\.wsp)$/) | |
next unless match | |
root, host, vhost, prog, wsp = match.captures | |
vhost.gsub!(/\//, '_') | |
new_name = File.join(root, host, "#{prog}_logs", vhost, wsp) | |
dir_name = File.dirname(new_name) | |
new_relative = Pathname.new(new_name).relative_path_from(Pathname.new(old_name).parent) | |
unless File.exist?(new_name) | |
puts new_name | |
FileUtils.mkdir_p(dir_name) | |
FileUtils.mv(old_name, new_name) | |
FileUtils.ln_s(new_relative, old_name) | |
end | |
end |
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
time sudo find /opt/graphite/storage/whisper/*_production \ | |
\( -name http_???\.wsp -or -name time_request\.wsp -or -name time_upstream\.wsp \) \ | |
-type f -mmin -30 \ | |
-exec ruby ~/rename_wsp.rb {} \+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment