Disk Usage Alert From df Output
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.
Capacity column, like 91%) is at or above THRESHOLD percent, as MOUNT USE% (for example /var 91%), in the order they appear.tmpfs, devtmpfs, squashfs and overlay.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.
Part of Python for DevOps. Next step: Clean Up Old Files Safely, With a Dry Run
Teaching or writing about this? Embed this lab on your page
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.