Saturday morning, /var on reef filled up and the register stopped saving sales. Ana is adding reef to the monitoring system. It runs a check script for each disk and reads two things: one line of text and the exit code.
Write ~/disk-alarm.sh MOUNT:
| How full | It prints | Exit code |
|---|---|---|
| below 80% | MOUNT is N% full: OK | 0 |
| 80% to 89% | MOUNT is N% full: WARNING | 1 |
| 90% or more | MOUNT is N% full: CRITICAL | 2 |
learner@reef:~$ ./disk-alarm.sh /var
/var is 84% full: WARNING
learner@reef:~$ echo $?
1This line gets a mount's percentage as a bare number. In your script, "$1" takes the place of /var:
learner@reef:~$ df --output=pcent /var | tail -n 1 | tr -d ' %'
84 ← tail -n 1: the last line; tr -d ' %': delete spaces and %Make the script runnable before you run it.
You have 10 minutes. The clock starts when you start the challenge. If the time runs out, you can still finish.
Objectives
- Below 80%:
OK, exit code 0. - From 80% to 89%:
WARNING, exit code 1. - 90% or more:
CRITICAL, exit code 2.