Hands-on task
if: compare a number with a threshold
Monitoring passes the script how full the disk is, in percent — a whole number from 0 to 100. Write /root/disk-alert.sh: if the number in the first argument is greater than 80, the script prints ALERT, otherwise OK.
$ bash disk-alert.sh 93
ALERT
$ bash disk-alert.sh 80
OK
$ bash disk-alert.sh 42
OK
Exactly 80 isn't an alert yet.
- bash scripts
- if
- comparing numbers
- -gt