socialnerds/hive
socialnerds
/
hive
Archived
1
0
Fork 0

did a rewrite of diskusage in disk_mon.py

This commit is contained in:
David 2012-05-20 12:15:16 +02:00
parent b0c1fc9011
commit 62fc2fb2f1
1 changed files with 26 additions and 2 deletions

View File

@ -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"]]