April 2017
M T W T F S S
 12
3456789
10111213141516
17181920212223
24252627282930

Categories

April 2017
M T W T F S S
 12
3456789
10111213141516
17181920212223
24252627282930

python code for disk space

#!/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)