summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts/adv_graphgen/tinc_stats
diff options
context:
space:
mode:
authorroot <root@pigstarter.retiolum>2013-06-24 18:04:25 +0200
committerroot <root@pigstarter.retiolum>2013-06-24 18:04:25 +0200
commit33483e844e508a4b256ab06d9096d1e7f580643b (patch)
tree62275b823ca6752db5d0b1bd112c64996490c20a /retiolum/scripts/adv_graphgen/tinc_stats
parentfe1f4dec340c121e43d0fca6d1139db694b2c48b (diff)
refactor Graphite sender
Diffstat (limited to 'retiolum/scripts/adv_graphgen/tinc_stats')
-rw-r--r--retiolum/scripts/adv_graphgen/tinc_stats/Graphite.py16
1 files changed, 16 insertions, 0 deletions
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())