Skip to content

Instantly share code, notes, and snippets.

@hapylestat
Created January 20, 2015 11:09
Show Gist options
  • Select an option

  • Save hapylestat/381a03b59911543c968f to your computer and use it in GitHub Desktop.

Select an option

Save hapylestat/381a03b59911543c968f to your computer and use it in GitHub Desktop.
flume_agent_generator.py
#!/usr/bin/env python
tpl_data = """
# Name the components on this agent
a{0}.sources = src{0}
a{0}.sinks = sink{0}
a{0}.channels = c{0}
# Use a channel which buffers events in memory
a{0}.channels.c{0}.type = memory
a{0}.channels.c{0}.capacity = 10000
a{0}.channels.c{0}.transactionCapacity = 1000
# Configure the source
# a{0}.sources.src{0}.type = exec
# a{0}.sources.src{0}.command = tail -f /var/log/ambari-a{0}/ambari-a{0}.log
a{0}.sources.src{0}.channels = c{0}
a{0}.sources.src{0}.type = multiport_syslogtcp
a{0}.sources.src{0}.host = 0.0.0.0
a{0}.sources.src{0}.ports = 8004
# Configure the sink
a{0}.sinks.sink{0}.type = hdfs
a{0}.sinks.sink{0}.hdfs.path = hdfs://{1}/tmp/logs/
a{0}.sinks.sink{0}.hdfs.filePrefix = events-
a{0}.sinks.sink{0}.hdfs.round = true
a{0}.sinks.sink{0}.hdfs.roundValue = 10
a{0}.sinks.sink{0}.hdfs.roundUnit = minute
#a{0}.sinks.sink{0}.type = logger
a{0}.sinks.sink{0}.channel = c{0}
"""
hdfs_host = "host:8020"
for i in range(0, 5):
print tpl_data.format(i, hdfs_host)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment