Rev | Line | |
---|
[53e5e13] | 1 | #!/bin/sh
|
---|
| 2 | # Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
|
---|
| 3 |
|
---|
| 4 | # This program is free software: you can redistribute it and/or modify
|
---|
| 5 | # it under the terms of the GNU General Public License as published by
|
---|
| 6 | # the Free Software Foundation, either version 3 of the License, or
|
---|
| 7 | # (at your option) any later version.
|
---|
| 8 |
|
---|
| 9 | # This program is distributed in the hope that it will be useful,
|
---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 12 | # GNU General Public License for more details.
|
---|
| 13 |
|
---|
| 14 | # You should have received a copy of the GNU General Public License
|
---|
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 16 |
|
---|
| 17 | DIR="${DIR:-$BLOCK_INSTANCE}"
|
---|
| 18 | DIR="${DIR:-$HOME}"
|
---|
| 19 | ALERT_LOW="${ALERT_LOW:-$1}"
|
---|
| 20 | ALERT_LOW="${ALERT_LOW:-10}" # color will turn red under this value (default: 10%)
|
---|
| 21 |
|
---|
| 22 | LOCAL_FLAG="-l"
|
---|
| 23 | if [ "$1" = "-n" ] || [ "$2" = "-n" ]; then
|
---|
| 24 | LOCAL_FLAG=""
|
---|
| 25 | fi
|
---|
| 26 |
|
---|
| 27 | df -h -P $LOCAL_FLAG "$DIR" | awk -v label="$LABEL" -v alert_low=$ALERT_LOW '
|
---|
| 28 | /\/.*/ {
|
---|
| 29 | # full text
|
---|
| 30 | print label $4
|
---|
| 31 |
|
---|
| 32 | # short text
|
---|
| 33 | print "HDD: " $3 "/" $2
|
---|
| 34 |
|
---|
| 35 | use=$5
|
---|
| 36 |
|
---|
| 37 | # no need to continue parsing
|
---|
| 38 | exit 0
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | END {
|
---|
| 42 | gsub(/%$/,"",use)
|
---|
| 43 | if (100 - use < alert_low) {
|
---|
| 44 | # color
|
---|
| 45 | print "#FF0000"
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 | '
|
---|
Note:
See
TracBrowser
for help on using the repository browser.