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))
|
services=($(cat /.motd.services))
|
||||||
# sort services
|
# sort services
|
||||||
IFS=$'\n' services=($(sort <<<"${services[*]}"))
|
#IFS=$'\n' services=($(sort <<<"${services[*]}"))
|
||||||
unset IFS
|
#unset IFS
|
||||||
|
|
||||||
service_status=()
|
service_status=()
|
||||||
# get status of all services
|
# get status of all services
|
||||||
@ -56,7 +56,7 @@ printf "$out" | column -ts $',' | sed -e 's/^/ /'
|
|||||||
|
|
||||||
### Disk space ###
|
### Disk space ###
|
||||||
# config
|
# config
|
||||||
max_usage=90
|
max_usage=80
|
||||||
bar_width=50
|
bar_width=50
|
||||||
# colors
|
# colors
|
||||||
white="\e[39m"
|
white="\e[39m"
|
||||||
@ -105,20 +105,23 @@ done <<< $(echo -e "$DISKS")
|
|||||||
|
|
||||||
|
|
||||||
### Welcome message ###
|
### 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
|
||||||
echo -e "Welcome to $(hostname), $(whoami)!
|
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}')"
|
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 ###
|
### ZFS available space warning ###
|
||||||
if test $(command -v zfs); then
|
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
|
while read line; do
|
||||||
name=$(echo "$line" | awk '{print $1}')
|
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
|
percentage=$(echo "scale=2;$avail/($used+$avail)*100" | bc)
|
||||||
echo -e "${red}Warning! ${white}$name ${undim}has less than 150GB"
|
|
||||||
|
if (( $(echo "$percentage < 20" | bc -l) )); then
|
||||||
|
echo -e "${red}Warning! ${white}$name ${undim}only has ${percentage}% capacity left"
|
||||||
fi
|
fi
|
||||||
done <<< $(echo -e "$POOLS")
|
done <<< $(echo -e "$POOLS")
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user