Update scripts

This commit is contained in:
2025-04-07 11:05:18 +01:00
parent ca8a63edcd
commit 62343c2157
5 changed files with 83 additions and 16 deletions

View File

@@ -1,3 +1,22 @@
#!/bin/sh
#!/bin/bash
free --mebi | sed -n '2{p;q}' | awk '{printf (" %.1f%%\n", ($4/$2)*100)}'
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
ENDCOLOR="\e[0m"
mem_info=$(free | awk '/Mem:/ {print $2, $3}')
read total used <<<"$mem_info"
percent=$(awk "BEGIN {printf \"%.0f\", ($used/$total)*100}")
if [ "$percent" -le 60 ]; then
percent_color=$GREEN
elif [ "$percent" -le 80 ]; then
percent_color=$YELLOW
else
percent_color=$RED
fi
mem_total=$(free -h | awk '/Mem:/ {print $2}')
mem_used=$(free -h | awk '/Mem:/ {print $3}')
echo -e " ${mem_used} / ${mem_total} (${percent_color}${percent}%${ENDCOLOR})"