From 51f5b703cc7d64068431983ac037c6d03d48ba12 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 15 May 2012 19:03:27 +0200 Subject: [PATCH] active devel --- df_check.py | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/df_check.py b/df_check.py index 4b620b6..a4192bf 100755 --- a/df_check.py +++ b/df_check.py @@ -2,26 +2,65 @@ import os - +#fileoperations file = open("/proc/partitions", "r") parts = file.read() file.close() +file = open("/proc/mounts", "r") +mounts = file.read() +file.close() -# getting all local partitions (regardless if mounted or not) +#definitions partitions = [] blocks = [] +mountpoints = [] + +# getting all local partitions (regardless if mounted or not) for line in parts.split("\n"): if line and "name" not in line and "sr0" not in line: if line.split()[2] != "1": - partitions.append(line.split()[3]) + partitions.append("/dev/" + line.split()[3]) blocks.append(line.split()[2]) -print "partitions: %s \nblocks: %s" %(partitions, blocks) + +hold="nothing" +holdblocks = 0 +blockcount = 0 +counter = 0 +for part in partitions: + if hold in part: + print "part %s contains hold %s" %(part, hold) + blockcount = blockcount + int(blocks[counter]) + print blockcount + else: + print "part %s does not contain hold %s" %(part, hold) + hold = part + holdblocks = blocks[counter] + blockcount = 0 + counter += 1 + + + exit() +#getting mountpoints to devices +for item in partitions: + for line in mounts.split("\n"): + if line and item in line: + mountpoints.append(line.split()[1]) + break +# mountpoints.append("%s not mounted" %(item)) + + +print "partitions: %s\nblocks: %s\nmountpoints: %s" %(partitions, blocks, mountpoints) + + + +exit() + # given paths(mountpoints) path=("/boot", "/", "/dev/sda6")