DF_CMD = ['/usr/bin/df', '--no-sync', '--portability']
+DF_SIZE_UNIT = 1024
class FilesystemFillState:
""" representation of 1 line of the 'df' command
Note that only apprixomately capacity == used/size
and that only approximately used + available == size
+ and that all sizes are in bytes
"""
def __init__(self):
for line in out[1:]:
stats = FilesystemFillState()
stats.name = line[ : separator_cols[0]].strip()
- stats.size = int(line[separator_cols[0] : separator_cols[1]].strip())
- stats.used = int(line[separator_cols[1] : separator_cols[2]].strip())
+ stats.size = int(line[separator_cols[0] : separator_cols[1]].strip()) \
+ * DF_SIZE_UNIT
+ stats.used = int(line[separator_cols[1] : separator_cols[2]].strip()) \
+ * DF_SIZE_UNIT
stats.available = int(line[separator_cols[2] : separator_cols[3]]\
- .strip())
+ .strip()) * DF_SIZE_UNIT
stats.capacity = int(line[separator_cols[3] : separator_cols[4]]\
.strip()[:-1])
stats.mount_point = line[separator_cols[4] : ].strip()