socialnerds/hive
socialnerds
/
hive
Archived
1
0
Fork 0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
hive/df_check.py

27 lines
609 B
Python
Executable File

#!/usr/bin/python2.7
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