Skip to content

Commit

Permalink
Report disk usage during fuzzer runs
Browse files Browse the repository at this point in the history
Signed-off-by: Anmol Shrivastava <[email protected]>
  • Loading branch information
colemole9595 committed Apr 19, 2022
1 parent 0d34e72 commit 5a67a67
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion fuzzers/run_fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,27 @@ def mem_convert(s):
return v


def get_diskspace(diskstr=None):
"""
Return the free and used space on the disk
associated with the current directory.
>>> import pprint
>>> pprint.pprint(get_diskspace())
{'free': '760G', 'used': '109G'}
"""

if diskstr is None:
diskstr = subprocess.check_output(
'df -h .', shell=True).decode("utf-8")

lines = [x.split() for x in diskstr.strip().splitlines()]

disk = {'used': lines[1][2], 'free': lines[1][3]}

return disk


def get_memory(memstr=None):
r"""
>>> import pprint
Expand Down Expand Up @@ -568,12 +589,15 @@ def log(msg, *a, **k):
if retcode is not None:
break
mem = get_memory()['mem']
disk = get_diskspace()
log(
"Still running (1m:{:0.2f}%, 5m:{:0.2f}%, 15m:{:0.2f}% Mem:{:0.1f}Gi used, {:0.1f}Gi free).\n{}",
"Still running (1m:{:0.2f}%, 5m:{:0.2f}%, 15m:{:0.2f}% Mem:{:0.1f}Gi used, {:0.1f}Gi free Disk:{}i used, {}i free).\n{}",
*get_load(),
mem['used'] / 1e9,
mem['available'] /
1e9, # Using available so the numbers add up.
disk['used'],
disk['free'],
PsTree.get(p.pid),
)
except (Exception, KeyboardInterrupt, SystemExit):
Expand Down

0 comments on commit 5a67a67

Please sign in to comment.