IT 3110: Systems Automation
Shell Scripting 3
This assignment will hone your skills as a Bash shell programmer.
Create the following script:
You are challenged with monitoring a bunch of servers to make sure that you never run out of disk space. Write a shell script that will monitor all of your linux machines and alert you if your disk space is ever over a certain percent (i.e. 80%). This script should be run as a cron job that runs every hour.
If you script detects that disk space is over the threshold %, it should run
apt autoremove and then
Your script should be designed such that you can pass in the threshold limit from the command line: (i.e. if my script is called disk_check.sh, I would run it like
./disk_check.sh 80 < machines.txt, to check if my machines are above the 80% threshold.) Note your machine should also read from a file that has your machines listed in them (either ip’s or fqdn).
BONUS See if you can send an alert email when over the threshold. (There may need to be additional configuration). (You would need an appropriately configured MTA)
For testing, run your script manually.
Note: You can send an email alert by doing something like
echo "hello world" | mail -s "a subject" email@example.com
Take a print screen of your scripts running. Also upload your scripts.
Last Updated 02/18/2021