42 lines
1.4 KiB
Python
Executable File
42 lines
1.4 KiB
Python
Executable File
#!/usr/bin/python2 -B
|
|
|
|
""" simple display to show results of disk.py """
|
|
|
|
import disk
|
|
|
|
def bytes2human(bytes):
|
|
units = ["", "K", "M", "G", "T", "P", "E"]
|
|
counter = 0
|
|
while bytes > 1024:
|
|
bytes = bytes / 1024
|
|
counter += 1
|
|
return "%.1f%s" %(bytes, units[counter])
|
|
|
|
def blocks2bytes(blocks, blocksize):
|
|
bytes = float(blocks) * float(blocksize)
|
|
return bytes
|
|
|
|
|
|
if __name__ == "__main__":
|
|
diskmoninstance = disk.diskmon()
|
|
notmounted = "Not mounted partitions:"
|
|
for partition in diskmoninstance.partitions:
|
|
if partition.has_key("mountpoint"):
|
|
totalbytes = blocks2bytes(partition["total blocks"], partition["blocksize"])
|
|
#totalhuman = bytes2human(totalbytes)
|
|
freebytes = blocks2bytes(partition["free blocks"], partition["blocksize"])
|
|
#freehuman = bytes2human(freebytes)
|
|
print "Device:\t\t%s" %(partition["device"]) + \
|
|
"\nUUID:\t\t%s" %(partition["uuid"]) + \
|
|
"\nMountpoint:\t%s" %(partition["mountpoint"]) + \
|
|
"\nFilesystem:\t%s" %(partition["filesystem"]) + \
|
|
"\nFree:\t\t%s/%s" %(bytes2human(freebytes), bytes2human(totalbytes)) + \
|
|
"\nFiles:\t\t%s\n" %(partition["files"])
|
|
else:
|
|
notmounted = notmounted + " " + partition["device"]
|
|
|
|
print notmounted
|
|
|
|
|
|
#end of file
|