pfSense-Dashboard/plugins/telegraf_gateways-3.7.py
Victor Robellini 80963d9652 https://forum.netgate.com/topic/152132/grafana-dashboard-using-telegraf-with-additional-plugins/20
Thanks to @JohnKap the response times in the gateway plugin (3.7) now work.  The fix
would most likely work witht he 2.7 script as well, but I don't have time to test at the moment.
2020-04-16 10:53:55 -04:00

22 lines
745 B
Python
Executable File

#!/usr/local/bin/python3.7
# telegraf_gateways-3.7.py
# https://gist.github.com/fastjack/a0feb792a9655da7aa3e2a7a1d9f812f#file-gateways-py-for-pfsense-2-4-5
# Special thanks to fashjack - https://gist.github.com/fastjack
import glob, os, socket
DPINGER_SOCK_PATH = "/var/run/"
os.chdir(DPINGER_SOCK_PATH)
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).decode().split('\n', 1)[0]
values = line.split()
print("gateways,gateway_name="+values[0]+" rtt="+str(int(values[1])/1.0)+ \
",rttsd="+str(int(values[2])/1.0)+",loss="+str(int(values[3]))+"i")
sock.close()