summaryrefslogtreecommitdiffstats
path: root/docker/storperf-master
diff options
context:
space:
mode:
authorShrenik <shrenik.jain@research.iiit.ac.in>2017-09-08 20:52:17 +0530
committerShrenik <shrenik.jain@research.iiit.ac.in>2017-09-08 20:56:19 +0530
commit7c5d697a39df3307049e5e07b3d4696360043777 (patch)
treec3162045d569fe90b86766ddc5497bd74d8cdf6f /docker/storperf-master
parent0b5b0413330729b9d1fb6b15a94571cf4db26347 (diff)
Remove localhost from emitter.py
emitter.py sends metrics to localhost and storperf-graphite. Since no graphite module is present at localhost, it needs to be removed from emitter as well. JIRA: STORPERF-205 Change-Id: I0d5732160ff39a332b088c8ba540ca6f6a483e12 Signed-off-by: Shrenik <shrenik.jain@research.iiit.ac.in>
Diffstat (limited to 'docker/storperf-master')
-rw-r--r--docker/storperf-master/storperf/carbon/emitter.py62
1 files changed, 30 insertions, 32 deletions
diff --git a/docker/storperf-master/storperf/carbon/emitter.py b/docker/storperf-master/storperf/carbon/emitter.py
index 05f6c3c..b196709 100644
--- a/docker/storperf-master/storperf/carbon/emitter.py
+++ b/docker/storperf-master/storperf/carbon/emitter.py
@@ -16,13 +16,12 @@ from storperf.db.graphite_db import GraphiteDB
class CarbonMetricTransmitter():
- carbon_servers = [('127.0.0.1', 2003),
- ('storperf-graphite', 2003)]
-
def __init__(self):
self.logger = logging.getLogger(__name__)
self.graphite_db = GraphiteDB()
self.commit_markers = {}
+ self.host = 'storperf-graphite'
+ self.port = 2003
def transmit_metrics(self, metrics, commit_marker):
timestamp = str(calendar.timegm(time.gmtime()))
@@ -30,36 +29,35 @@ class CarbonMetricTransmitter():
carbon_socket = None
- for host, port in self.carbon_servers:
- try:
- carbon_socket = socket.socket(socket.AF_INET,
- socket.SOCK_STREAM)
- carbon_socket.connect((host, port))
-
- for key, value in metrics.items():
- try:
- float(value)
- message = "%s %s %s\n" \
- % (key, value, timestamp)
- self.logger.debug("Metric: " + message.strip())
- carbon_socket.send(message)
- except ValueError:
- self.logger.debug("Ignoring non numeric metric %s %s"
- % (key, value))
-
- message = "%s.commit-marker %s %s\n" \
- % (commit_marker, timestamp, timestamp)
- carbon_socket.send(message)
- self.logger.debug("Marker %s" % message.strip())
- self.logger.info("Sent metrics to %s:%s with timestamp %s"
- % (host, port, timestamp))
+ try:
+ carbon_socket = socket.socket(socket.AF_INET,
+ socket.SOCK_STREAM)
+ carbon_socket.connect((self.host, self.port))
- except Exception, e:
- self.logger.error("While notifying carbon %s:%s %s"
- % (host, port, e))
-
- if carbon_socket is not None:
- carbon_socket.close()
+ for key, value in metrics.items():
+ try:
+ float(value)
+ message = "%s %s %s\n" \
+ % (key, value, timestamp)
+ self.logger.debug("Metric: " + message.strip())
+ carbon_socket.send(message)
+ except ValueError:
+ self.logger.debug("Ignoring non numeric metric %s %s"
+ % (key, value))
+
+ message = "%s.commit-marker %s %s\n" \
+ % (commit_marker, timestamp, timestamp)
+ carbon_socket.send(message)
+ self.logger.debug("Marker %s" % message.strip())
+ self.logger.info("Sent metrics to %s:%s with timestamp %s"
+ % (self.host, self.port, timestamp))
+
+ except Exception, e:
+ self.logger.error("While notifying carbon %s:%s %s"
+ % (self.host, self.port, e))
+
+ if carbon_socket is not None:
+ carbon_socket.close()
def confirm_commit(self, commit_marker):
marker_timestamp = self.commit_markers[commit_marker]