diff options
author | sacreman <sacreman@gmail.com> | 2014-04-12 18:41:26 +0100 |
---|---|---|
committer | sacreman <sacreman@gmail.com> | 2014-04-12 18:41:26 +0100 |
commit | 0d77d2c67c505ff66e6c9d42f96dbaf75c8599da (patch) | |
tree | fe81f361e12289ffe99ef2737996e3cdd2ecbe82 | |
parent | 7475c53822c2e22d0994ea059bfd482044019a5b (diff) | |
download | logster-0d77d2c67c505ff66e6c9d42f96dbaf75c8599da.zip logster-0d77d2c67c505ff66e6c9d42f96dbaf75c8599da.tar.gz logster-0d77d2c67c505ff66e6c9d42f96dbaf75c8599da.tar.bz2 |
adds graphite socket protocol option (choose tcp or udp)
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | bin/logster | 9 |
2 files changed, 10 insertions, 1 deletions
@@ -103,6 +103,8 @@ Additional usage details can be found with the -h option: --graphite-host=GRAPHITE_HOST Hostname and port for Graphite collector, e.g. graphite.example.com:2003 + --graphite-protocol=[tcp|udp] + Specify graphite socket protocol. Options are tcp and udp. Defaults to tcp. --statsd-host=STATSD_HOST Hostname and port for statsd collector, e.g. statsd.example.com:8125 diff --git a/bin/logster b/bin/logster index 5b459c8..30e923e 100755 --- a/bin/logster +++ b/bin/logster @@ -86,6 +86,8 @@ cmdline.add_option('--gmetric-options', action='store', default='-d 180 -c /etc/ganglia/gmond.conf') cmdline.add_option('--graphite-host', action='store', help='Hostname and port for Graphite collector, e.g. graphite.example.com:2003') +cmdline.add_option('--graphite-protocol', action='store', default='tcp', + help='Specify graphite socket protocol. Options are tcp and udp. Defaults to tcp.') cmdline.add_option('--statsd-host', action='store', help='Hostname and port for statsd collector, e.g. statsd.example.com:8125') cmdline.add_option('--aws-key', action='store', default=os.getenv('AWS_ACCESS_KEY_ID'), @@ -215,7 +217,12 @@ def submit_graphite(metrics, options): if (not options.dry_run): host = options.graphite_host.split(':') - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + if options.graphite_protocol == 'udp': + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + else: + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect((host[0], int(host[1]))) try: |