Update motd.sh
This commit is contained in:
parent
e0af0c4021
commit
a2981a3e35
21
motd.sh
21
motd.sh
@ -26,8 +26,8 @@ undim="\e[0m"
|
||||
|
||||
services=($(cat /.motd.services))
|
||||
# sort services
|
||||
IFS=$'\n' services=($(sort <<<"${services[*]}"))
|
||||
unset IFS
|
||||
#IFS=$'\n' services=($(sort <<<"${services[*]}"))
|
||||
#unset IFS
|
||||
|
||||
service_status=()
|
||||
# get status of all services
|
||||
@ -56,7 +56,7 @@ printf "$out" | column -ts $',' | sed -e 's/^/ /'
|
||||
|
||||
### Disk space ###
|
||||
# config
|
||||
max_usage=90
|
||||
max_usage=80
|
||||
bar_width=50
|
||||
# colors
|
||||
white="\e[39m"
|
||||
@ -105,20 +105,23 @@ done <<< $(echo -e "$DISKS")
|
||||
|
||||
|
||||
### Welcome message ###
|
||||
LAST_LOGIN=$(last -w | grep arisu | head -2 | tail -1)
|
||||
LAST_LOGIN=$(last -w | grep $(whoami) | head -2 | tail -1)
|
||||
echo -e
|
||||
echo -e "Welcome to $(hostname), $(whoami)!
|
||||
Last login: $(echo "$LAST_LOGIN" | awk '{for(i=4;i<=NF;i++) print $i}' | paste -sd ' ') from $(echo "$LAST_LOGIN" | awk '{print $3}')"
|
||||
|
||||
### ZFS available space warning ###
|
||||
if test $(command -v zfs); then
|
||||
POOLS=$(zfs list -o name,available -p | tail -n+2)
|
||||
POOLS=$(zfs list -o name,used,available -p | tail -n+2)
|
||||
while read line; do
|
||||
name=$(echo "$line" | awk '{print $1}')
|
||||
avail=$(echo "$line" | awk '{print $2}')
|
||||
used=$(echo "$line" | awk '{print $2}')
|
||||
avail=$(echo "$line" | awk '{print $3}')
|
||||
|
||||
if [ $avail -le 150000000000 ]; then
|
||||
echo -e "${red}Warning! ${white}$name ${undim}has less than 150GB"
|
||||
percentage=$(echo "scale=2;$avail/($used+$avail)*100" | bc)
|
||||
|
||||
if (( $(echo "$percentage < 20" | bc -l) )); then
|
||||
echo -e "${red}Warning! ${white}$name ${undim}only has ${percentage}% capacity left"
|
||||
fi
|
||||
done <<< $(echo -e "$POOLS")
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user