added comments to df_check.py
This commit is contained in:
parent
349d1c4694
commit
a3d4b684fd
12
df_check.py
12
df_check.py
|
@ -2,21 +2,25 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
# given paths(mountpoints)
|
||||||
path=("/boot", "/", "/home/")
|
path=("/boot", "/", "/home/")
|
||||||
|
|
||||||
|
#output head
|
||||||
print "mountpoints\tfree megabytes"
|
print "mountpoints\tfree megabytes"
|
||||||
print "------------------------------"
|
print "------------------------------"
|
||||||
|
|
||||||
|
#work path tuple
|
||||||
for mountpoint in path:
|
for mountpoint in path:
|
||||||
|
#check if given path is a mountpoint
|
||||||
if os.path.ismount(mountpoint):
|
if os.path.ismount(mountpoint):
|
||||||
|
#create statvfs object
|
||||||
fs = os.statvfs(mountpoint)
|
fs = os.statvfs(mountpoint)
|
||||||
|
#calculate free megabytes
|
||||||
freembytes = fs.f_bavail * fs.f_bsize / 1024**2.0
|
freembytes = fs.f_bavail * fs.f_bsize / 1024**2.0
|
||||||
|
#output
|
||||||
print "%s\t\t%.1f MB" %(mountpoint, freembytes)
|
print "%s\t\t%.1f MB" %(mountpoint, freembytes)
|
||||||
else:
|
else:
|
||||||
print "error: given path is not a mountpoint"
|
print "error: given path is not a mountpoint"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# end of file
|
# end of file
|
||||||
|
|
Reference in New Issue