|
@@ -10,7 +10,7 @@ import StringIO
|
|
|
class GraphitePush:
|
|
|
dont_send = False
|
|
|
|
|
|
- prefix = 'ffpb.nodes.'
|
|
|
+ prefix = 'ffpb.'
|
|
|
target_host = None
|
|
|
target_port = 2003
|
|
|
|
|
@@ -27,9 +27,16 @@ class GraphitePush:
|
|
|
|
|
|
def __print_graphite_line(self, output, nodeid, item, value, timestamp):
|
|
|
print(
|
|
|
- self.prefix, nodeid, '.', item, ' ', value, ' ', timestamp,
|
|
|
+ self.prefix, 'nodes.', nodeid, '.', item, ' ', value, ' ', timestamp,
|
|
|
sep='', file=output)
|
|
|
|
|
|
+ def __do_send(self, data):
|
|
|
+ sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
|
|
+ sock.connect((self.target_host, self.target_port))
|
|
|
+ sock.sendall(data)
|
|
|
+ sock.shutdown(socket.SHUT_WR)
|
|
|
+ sock.close()
|
|
|
+
|
|
|
def push(self, data, timestamp=None):
|
|
|
if timestamp is None:
|
|
|
timestamp = time.time()
|
|
@@ -63,11 +70,7 @@ class GraphitePush:
|
|
|
all_output = output.getvalue()
|
|
|
|
|
|
if not self.dont_send:
|
|
|
- sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
|
|
- sock.connect((self.target_host, self.target_port))
|
|
|
- sock.sendall(all_output)
|
|
|
- sock.shutdown(socket.SHUT_WR)
|
|
|
- sock.close()
|
|
|
+ self.__do_send(all_output)
|
|
|
|
|
|
output.close()
|
|
|
|