Skip to content

Instantly share code, notes, and snippets.

@fukata
Last active December 22, 2015 17:19
Show Gist options
  • Save fukata/6504937 to your computer and use it in GitHub Desktop.
Save fukata/6504937 to your computer and use it in GitHub Desktop.
fluentd DSL config. I want to extract number from hostname.
source {
type "forward"
port 24224
}
match('test.**') {
type "forward"
num = ::Kernel.open("|hostname"){|o| o.read.chop}.gsub('hoge','').to_i / 20 + 1 # host01 => 1
(num..num+1).each do |n|
server {
host "proxy%02d" % n
port 24224
}
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment