diff --git a/diskusage_diezweite.py b/diskusage_diezweite.py index e1b486d..41a3372 100755 --- a/diskusage_diezweite.py +++ b/diskusage_diezweite.py @@ -1,9 +1,7 @@ #!/usr/bin/python2 - import os - def getmountpoint(device): mtab = open("/etc/mtab", "r") for line in mtab.readlines(): @@ -36,3 +34,29 @@ for device in test.keys(): +# getting usage information and print it to stdout +for mountpoint in mountpoints: + #check if given path is a mountpoint + if os.path.ismount(mountpoint): + #create statvfs object + fs = os.statvfs(mountpoint) + #calculate free megabytes + freembytes = fs.f_bavail * fs.f_bsize / 1024**2.0 + #output + print "%s\t\t%.1f MB" %(mountpoint, freembytes) + else: + print "error: given path (%s) is not a mountpoint" %(mountpoint) + + + +partitions = [["/dev/sda1", "uuid", "/home", "filesystem", "total blocks", "free blocks"], ["/dev/sda2", "uuid", "/", "filesystem", "total blocks", "free blocks"]] + + + + + + + + + +