forked from 40Cakes/PlexMOTD
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path12-disk-stats
executable file
·24 lines (21 loc) · 959 Bytes
/
12-disk-stats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
MY_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${MY_PATH}/config.conf"
echo -e "${BLU} Used Avail. Total Percent${NC}"
for i in $(echo "${DISKS}" | sed "s/,/ /g"); do
if mountpoint -q "${i}"; then
AVAIL="$(df --output=avail $i | tail -1)"
USED="$(df --output=used $i | tail -1)"
SIZE="$(df --output=size $i | tail -1)"
PERCENT="$(df --output=pcent $i | tail -1 | sed 's/\%//')"
CHAR=$(echo 20-${#i} | bc)
if [ "${PERCENT}" -gt 90 ]; then
COLOR="${RED}"
elif [ "${PERCENT}" -gt 75 ]; then
COLOR="${YEL}"
else
COLOR="${GRN}"
fi
echo -e " ${YEL}$i$(printf '%*s' "$CHAR" | tr ' ' "."): ${NC}$COLOR$(echo "scale=2; $USED/1073741824" | bc -l | awk '{printf "%.2f", $0}')${NC}T $COLOR$(echo "scale=2; $AVAIL/1073741824" | bc -l | awk '{printf "%.2f", $0}')${NC}T $COLOR$(echo "scale=2; $SIZE/1073741824" | bc -l | awk '{printf "%.2f", $0}')${NC}T $COLOR$PERCENT${NC}%"
fi
done