Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adds an optional (extra) multicast listener to StatsD #395

Open
wants to merge 1 commit into from

2 participants

@ciaranj

As mentioned in #394

  • Can be useful where you have multiple statsd servers all interested in the same statsd emitted metrics.
@ciaranj ciaranj Adds an optional (extra) udp broadcast listener to StatsD
* Can be useful where you have multiple statsd servers all interested in
the same statsd emitted metrics.
a53f07e
@mrtazz
Owner

This is interesting. I'm not sure how useful this is in general but I have some ideas for pluggable receiver frontends which this could fit into. I'll close the #394 and comment on here when I've put something up about that.

@mrtazz mrtazz referenced this pull request
Closed

UDP Multicast Binding #394

@ciaranj

Yeah, totally accept my usage is an edge-case, but works well for me. With the benefit of hind sight, really all I was doing was allowing binding to multiple UDP ports (since the original attempt at multicast support failed on some network configs) :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2014
  1. @ciaranj

    Adds an optional (extra) udp broadcast listener to StatsD

    ciaranj authored
    * Can be useful where you have multiple statsd servers all interested in
    the same statsd emitted metrics.
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 2 deletions.
  1. +1 −0  exampleConfig.js
  2. +11 −2 stats.js
View
1  exampleConfig.js
@@ -25,6 +25,7 @@ Optional Variables:
mgmt_address: address to run the management TCP interface on
[default: 0.0.0.0]
mgmt_port: port to run the management TCP interface on [default: 8126]
+ broadcast_port: udp broadcast port to additionally listen to.
title : Allows for overriding the process title. [default: statsd]
if set to false, will not override the process title and let the OS set it.
The length of the title has to be less than or equal to the binary name + cli arguments
View
13 stats.js
@@ -168,7 +168,7 @@ config.configFile(process.argv[2], function (config, oldConfig) {
var keyFlushInterval = Number((config.keyFlush && config.keyFlush.interval) || 0);
var udp_version = config.address_ipv6 ? 'udp6' : 'udp4';
- server = dgram.createSocket(udp_version, function (msg, rinfo) {
+ function process_udp_message(msg, rinfo) {
backendEvents.emit('packet', msg, rinfo);
counters[packets_received]++;
var packet_data = msg.toString();
@@ -244,7 +244,16 @@ config.configFile(process.argv[2], function (config, oldConfig) {
}
stats.messages.last_msg_seen = Math.round(new Date().getTime() / 1000);
- });
+ }
+ server = dgram.createSocket(udp_version, process_udp_message);
+
+ if( config.broadcast_port) {
+ multicastServer= dgram.createSocket(udp_version, process_udp_message);
+ multicastServer.bind( config.broadcast_port, function(err) {
+ multicastServer.setBroadcast(true);
+ });
+ }
+
mgmtServer = net.createServer(function(stream) {
stream.setEncoding('ascii');
Something went wrong with that request. Please try again.