Skip to content

Instantly share code, notes, and snippets.

@hyounggyu
Created July 4, 2017 00:35
Show Gist options
  • Save hyounggyu/1ddade5d847b9594b719338921a3cb0c to your computer and use it in GitHub Desktop.
Save hyounggyu/1ddade5d847b9594b719338921a3cb0c to your computer and use it in GitHub Desktop.
import time
import psutil
tstamp = int(time.time())
d = {
"cpu_percent": psutil.cpu_percent(interval=1),
"disk_root_percent": psutil.disk_usage('/').percent,
"vmem_percent": psutil.virtual_memory().percent,
"swap_percent": psutil.swap_memory().percent,
}
for k, v in d.items():
data.append({
"measurement": k,
"tags": { "host": self.hostid },
"fields": { "value": v },
"time": tstamp,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment