socialnerds/hive
socialnerds
/
hive
Archived
1
0
Fork 0

added comments to df_check.py

This commit is contained in:
David 2012-05-14 11:27:28 +02:00
parent 349d1c4694
commit a3d4b684fd
1 changed files with 8 additions and 4 deletions

View File

@ -2,21 +2,25 @@
import os
# given paths(mountpoints)
path=("/boot", "/", "/home/")
#output head
print "mountpoints\tfree megabytes"
print "------------------------------"
#work path tuple
for mountpoint in path:
#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 is not a mountpoint"
# end of file