From 33483e844e508a4b256ab06d9096d1e7f580643b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 24 Jun 2013 18:04:25 +0200 Subject: refactor Graphite sender --- retiolum/scripts/adv_graphgen/tinc_stats/Graphite.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 retiolum/scripts/adv_graphgen/tinc_stats/Graphite.py (limited to 'retiolum/scripts/adv_graphgen/tinc_stats') diff --git a/retiolum/scripts/adv_graphgen/tinc_stats/Graphite.py b/retiolum/scripts/adv_graphgen/tinc_stats/Graphite.py new file mode 100644 index 00000000..ee01a02b --- /dev/null +++ b/retiolum/scripts/adv_graphgen/tinc_stats/Graphite.py @@ -0,0 +1,16 @@ +#!/usr/bin/python + +import socket +from time import time + +class GraphiteSender: + def __init__(self,host,port=2003,prefix="retiolum"): + self.host = host + self.port = port + self.prefix = prefix + self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.sock.connect((host,port)) + + def send(name,data): + from time import time + self.sock.send("%s.%s %d %d\r\n"%self.prefix,data,time()) -- cgit v1.2.3