Creation motivated by fear of filling disc space during long-running stress
tests
+.. todo:: Find out why NOT_REAL_FILESYSTEMS generate warnings so quickly even
+ if they are still empty
+
.. codeauthor:: Intra2net
"""
from buffers import LogarithmicBuffer
from file_helpers import get_filesystem_fill_states, FilesystemFillState, \
get_mount_info, get_fill_from_statvfs, \
- NOT_REAL_FILESYSTEMS
+ NOT_REAL_FILESYSTEMS, size_str
from iter_helpers import pairwise
"""
if fs_state.name in NOT_REAL_FILESYSTEMS:
return []
+ if fs_state.size == 0:
+ return []
buf = None
try:
# start state
print('{0}: start states are:'.format(dt.now()))
+ first_fills = dict()
max_vals = dict()
for state in get_states():
- print('{0}, {1}B used'.format(state, state.used))
+ print('{0}, {1} used'.format(state, size_str(state.used)))
max_vals[state.mount_point] = state.used
+ first_fills[state.mount_point] = state.used
try:
- # infinite loop
+ # loop until user presses Ctrl-C
+ print('checking every {0:.1f}s, press Ctrl-C to stop...'
+ .format(interval))
while True:
time.sleep(interval)
try:
for state in get_states():
if state.used > max_vals[state.mount_point]:
- print('{0}: new max {1}B for {2}'
+ print('{0}: new max {1:,d}B for {2}'
.format(dt.now(), state.used, state))
max_vals[state.mount_point] = state.used
except KeyError:
# a new file system was added
for state in get_states():
if state.mount_point not in max_vals:
- print('{0}: new filesystem {1}, {2}B used'
+ print('{0}: new filesystem {1}, {2:,d}B used'
.format(dt.now(), state, state.used))
max_vals[state.mount_point] = state.used
+ first_fills[state.mount_point] = state.used
except KeyboardInterrupt:
# end function
print(' --> caught KeyboardInterrupt')
print('{0}: end states and maxima:'.format(dt.now()))
for state in get_states():
- print('{0}, end fill is {1}B, max fill was {2}B'
- .format(state, state.used, max_vals[state.mount_point]))
+ firstf = first_fills[state.mount_point]
+ maxf = max_vals[state.mount_point]
+ print('{0}, start/max/end fill: {1} / {2} ({3}) / {4} ({5})'
+ .format(state, size_str(firstf), size_str(maxf),
+ size_str(maxf-firstf, True), size_str(state.used),
+ size_str(state.used-firstf, True)))
def get_perf_counter():