Skip to content

Instantly share code, notes, and snippets.

@nomaster
Created November 14, 2018 14:19
Show Gist options
  • Save nomaster/e4f3b231a1fe2ce5d1966e9362991d3a to your computer and use it in GitHub Desktop.
Save nomaster/e4f3b231a1fe2ce5d1966e9362991d3a to your computer and use it in GitHub Desktop.
Python3 version of the ethtool fact script for Ansible
#!/usr/bin/env python3
import subprocess
import json
stats = subprocess.getoutput("/sbin/ethtool -i enp0s3").split("\n")
result = {}
for line in stats:
key, value = line.split(": ")
result[key] = value
print(json.dumps(result, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment