Skip to content

Instantly share code, notes, and snippets.

@fastjack fastjack/
Last active Apr 24, 2019

What would you like to do?
Quick and dirty gateway metrics for telegraf on pfSense
import glob, os, socket
DPINGER_SOCK_PATH = "/var/run/"
for sock_name in glob.glob("dpinger*.sock"):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock_path = DPINGER_SOCK_PATH+sock_name
s = sock.connect(sock_path)
line = sock.recv(1024).split('\n', 1)[0]
values = line.split()
print "gateways,gateway_name=" + values[0] + " rtt=" + str(int(values[1])/100.0) + \
",rttsd=" + str(int(values[2])/100.0) + ",loss=" + str(int(values[3])) + "i"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.