#!/usr/bin/env python
#coding:utf-8
import subprocess
import json
import os,sys
space = []
df= os.popen(‘df -P -k’).read()
df = subprocess.Popen([“df”, “-P”, “-k”], stdout=subprocess.PIPE)
output = df.communicate()[0]
for line in output.split(“\n”)[1:]:
if len(line):
try:
device, size, used, available, percent, mountpoint = line.split()
space.append(dict(mountpoint=mountpoint, available=available))
except:
pass
print json.dumps(dict(space=space), indent=4)
Recent Comments