Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ifstat_influx.py
#!/usr/bin/env python3
import subprocess
delay = 4
def ifstat():
result = subprocess.check_output(["ifstat", str(delay), "1"]).decode()
lines = result.splitlines()
devs = lines[0].split()
speeds = list(map(float, lines[2].split()))
ls = []
for i in range(len(devs)):
r = f"ifstat,dev=\"{devs[i]}\" in={speeds[2*i]},out={speeds[2*i+1]}"
ls.append(r)
return ls
print("\n".join(ifstat()))
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.