Skip to content

Instantly share code, notes, and snippets.

@trevor-vaughan
Created September 5, 2017 04:28
Show Gist options
  • Select an option

  • Save trevor-vaughan/df6a3a0ca42a2c6f59b51d7375fe151a to your computer and use it in GitHub Desktop.

Select an option

Save trevor-vaughan/df6a3a0ca42a2c6f59b51d7375fe151a to your computer and use it in GitHub Desktop.
Output an entire Rsyslog configuration
#!/usr/bin/env ruby
base_config = '/etc/rsyslog.conf'
def process_config(config)
output = []
File.read(config).lines do |line|
if line =~ /IncludeConfig\s+(.*)/
Dir.glob($1).each do |subfile|
output += process_config(subfile)
end
else
output << line
end
end
return output
end
puts process_config(base_config).join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment