modified df_check, finds partitions and mounts, calculates usage of mounts
This commit is contained in:
parent
4ec300ce8c
commit
1fc755d8a3
22
df_check.py
22
df_check.py
|
@ -2,6 +2,7 @@
|
|||
|
||||
import os
|
||||
|
||||
|
||||
#fileoperations
|
||||
file = open("/proc/partitions", "r")
|
||||
parts = file.read()
|
||||
|
@ -13,7 +14,6 @@ file.close()
|
|||
#definitions
|
||||
partitions = []
|
||||
blocks = []
|
||||
mountpoints = []
|
||||
|
||||
# getting all local partitions (regardless if mounted or not)
|
||||
for line in parts.split("\n"):
|
||||
|
@ -31,13 +31,10 @@ partsnew = []
|
|||
blocksnew = []
|
||||
for part in partitions:
|
||||
if hold in part:
|
||||
print "part %s contains hold %s" %(part, hold)
|
||||
blockcount = blockcount + int(blocks[counter])
|
||||
print blockcount
|
||||
partsnew.append(part)
|
||||
blocksnew.append(blocks[counter])
|
||||
else:
|
||||
print "part %s does not contain hold %s" %(part, hold)
|
||||
hold = part
|
||||
holdblocks = blocks[counter]
|
||||
blockcount = 0
|
||||
|
@ -47,29 +44,22 @@ partitions = partsnew
|
|||
blocks = blocksnew
|
||||
|
||||
|
||||
|
||||
#getting mountpoints to devices
|
||||
counter = 0
|
||||
mountpoints = []
|
||||
for item in partitions:
|
||||
for line in mounts.split("\n"):
|
||||
if line and item in line:
|
||||
mountpoints.append(line.split()[1])
|
||||
|
||||
if line.split()[1] not in mountpoints[counter]:
|
||||
mountpoints.append("%s not mounted" %(item))
|
||||
counter += 1
|
||||
|
||||
break
|
||||
|
||||
|
||||
|
||||
print "partitions: %s\nblocks: %s\nmountpoints: %s" %(partitions, blocks, mountpoints)
|
||||
|
||||
|
||||
|
||||
exit()
|
||||
|
||||
print "\n"
|
||||
# given paths(mountpoints)
|
||||
path=("/boot", "/", "/dev/sda6")
|
||||
#path=("/boot", "/", "/dev/sda6")
|
||||
path = mountpoints
|
||||
|
||||
#output head
|
||||
print "mountpoints\tfree megabytes"
|
||||
|
|
Reference in New Issue