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