Skip to content

Commit 5a67a67

Browse files
committed
Report disk usage during fuzzer runs
Signed-off-by: Anmol Shrivastava <[email protected]>
1 parent 0d34e72 commit 5a67a67

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

fuzzers/run_fuzzer.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,27 @@ def mem_convert(s):
319319
return v
320320

321321

322+
def get_diskspace(diskstr=None):
323+
"""
324+
Return the free and used space on the disk
325+
associated with the current directory.
326+
327+
>>> import pprint
328+
>>> pprint.pprint(get_diskspace())
329+
{'free': '760G', 'used': '109G'}
330+
"""
331+
332+
if diskstr is None:
333+
diskstr = subprocess.check_output(
334+
'df -h .', shell=True).decode("utf-8")
335+
336+
lines = [x.split() for x in diskstr.strip().splitlines()]
337+
338+
disk = {'used': lines[1][2], 'free': lines[1][3]}
339+
340+
return disk
341+
342+
322343
def get_memory(memstr=None):
323344
r"""
324345
>>> import pprint
@@ -568,12 +589,15 @@ def log(msg, *a, **k):
568589
if retcode is not None:
569590
break
570591
mem = get_memory()['mem']
592+
disk = get_diskspace()
571593
log(
572-
"Still running (1m:{:0.2f}%, 5m:{:0.2f}%, 15m:{:0.2f}% Mem:{:0.1f}Gi used, {:0.1f}Gi free).\n{}",
594+
"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{}",
573595
*get_load(),
574596
mem['used'] / 1e9,
575597
mem['available'] /
576598
1e9, # Using available so the numbers add up.
599+
disk['used'],
600+
disk['free'],
577601
PsTree.get(p.pid),
578602
)
579603
except (Exception, KeyboardInterrupt, SystemExit):

0 commit comments

Comments
 (0)