IT3110 - System Automation

IT3110 @ utahtech

Week 4 Practice

Description

This assignment will hone your skills as a Bash shell programmer. In particular you will use functions, and read from a file.

READ EVERYTHING BEFORE STARTING

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 apt autoclean.

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). It should loop through each of these machines to check and see if they are over the threshold (via ssh).

You should incorporate the following functions:

Don’t forget that you should handle output of cronjobs. You could redirect to a log file or to /dev/null.