10/20
Sign inSign up free

1442. Disk Usage Alert From df Output

easy 10 XP ~10 minHands-on lab

Monitoring runs df -PT > /var/tmp/df.txt and then your script. Write /home/student/monitor/check_usage.py:

python3 check_usage.py DF_FILE THRESHOLD

The file has a header line, then the columns Filesystem Type 1024-blocks Used Available Capacity Mounted-on. A sample is in /home/student/monitor/df.txt.

Task

  • Print every filesystem whose use (the Capacity column, like 91%) is at or above THRESHOLD percent, as MOUNT USE% (for example /var 91%), in the order they appear.
  • Ignore the types tmpfs, devtmpfs, squashfs and overlay.
  • The mount point is everything after the sixth column: it can contain spaces.
  • Exit with status 1 if anything was printed, 0 if not.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.