linux-motd/ update-motd.d/30-disks

29 lines
No EOL
628 B
Bash

#!/bin/bash
CR='\033[0;31m'
CYW='\033[1;33m'
CG='\033[0;32m'
CB="\e[1;34m"
NC='\033[0m' # No Color
# Titel
echo -e "
echo -e "${CB}disk usage:${NC}"
echo -e ""
echo -e " Filesystem Size Used"
df -h --output=source,size,pcent,target | tail -n +2 | \
grep -Ev 'tmpfs|devtmpfs|udev|squashfs|overlay|nfs|cifs|smbfs|fuse|proc|sysfs' | \
while read -r fs size pcent target; do
usage=${pcent%\%}
if [ "$usage" -ge 90 ]; then
color=$CR
elif [ "$usage" -ge 70 ]; then
color=$CY
else
color=$CG
fi
printf " %-46s %6s ${color}%4s${NC}\n" "$target" "$size" "$pcent"
done