From f7665eeb148296c38114da6c50823c9d176fa28b Mon Sep 17 00:00:00 2001 From: Pieds-Nus Date: Wed, 21 Sep 2022 12:48:58 +0000 Subject: [PATCH] Added status.sh : quick overview of system state (memory, swaps, disks, temp...) --- status.sh | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ swaps.sh | 13 +++++++++ 2 files changed, 97 insertions(+) create mode 100644 status.sh create mode 100644 swaps.sh diff --git a/status.sh b/status.sh new file mode 100644 index 0000000..d0b36e6 --- /dev/null +++ b/status.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +echo -en "_________________\n CPU: " + +tmp=$(echo "($(acpitool -c | head -n3 | tail -n 1 | rev | cut -d " " -f 2 | rev)-800)/26" | bc) + +echo -e "$tmp%\t\t\t\t\t\t$(progressbar $tmp)" + +tmp=$(echo " ( $(cat /sys/class/thermal/thermal_zone*/temp | tr "\n" "+") 0 ) / $( ls -d /sys/class/thermal/thermal_zone* | wc -l ) " | bc | rev | cut -c 4- | rev) +echo -e "\t $tmpĀ°C\t\t\t\t\t\t$(progressbar $tmp)" + +echo -e "_________________\n RAM: \n" + +#tmp=($(free | tail -n 2 | cut -c 10-32)) +tmp=($(free | tail -n 2 | tr -s " " | cut -d " " -f 2,4,7)) + +h=$(free -h | cut -c 1-45) + +echo " total used free" + + + +#free -h | grep Mem | cut -c 1-45 +echo "$h" | cut -z -d " +" -f 2 + +r=$(echo "(${tmp[0]}-${tmp[1]})*100/${tmp[0]}" | bc) +echo -ne "\t$r%\t" +progressbar "$r" + + +echo "$h" | cut -z -d " +" -f 3 + +r=$(echo "(${tmp[3]}-${tmp[4]})*100/${tmp[3]}" | bc) +echo -ne "\t$r%\t" +progressbar "$r" + + +echo -e "\n_________________\n Swaps:\n" + +s=$(swaps | sort) +p=($(echo "$s" | cut -d " " -f 3 | tr -d "%")) +n=$(echo "$s" | wc -l) +i=1 + +while test $i -le $n ; do + echo "$s" | cut -z -d " +" -f $i + echo -en "\t\t\t\t" + progressbar ${p[(($i-1))]} + ((i++)) +done + +echo -e "\n_________________\n Disks:\n" +df=$(df -h --print-type | grep ext4 | \ + sed "s/\/dev\/sd[a|b]1 ext4/boot/" | \ + sed "s/\/dev\/mapper\/root_crypt ext4/root/" | \ + sed "s/\/dev\/mapper\/data_crypt ext4/data/" ) + +p=($(df | grep /dev/ | grep -v tmpfs | tr -s " " | cut -d " " -f 5 | tr -d "%")) + +echo "$df" | cut -z -d " +" -f 1 +echo -en "\t\t\t" +progressbar ${p[0]} + +echo "$df" | cut -z -d " +" -f 2 +echo -en "\t\t\t" +progressbar ${p[1]} + +echo "$df" | cut -z -d " +" -f 3 +echo -en "\t\t\t" +progressbar ${p[2]} + + +test "$1" = "hold" && read -sn 1 aaa + + + + + diff --git a/swaps.sh b/swaps.sh new file mode 100644 index 0000000..2a06f1c --- /dev/null +++ b/swaps.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +while read line ; do + + echo "$line"| grep "Filename" > /dev/null && continue + + name=$(echo $line | cut -d " " -f 1) + total=$(echo $line | cut -d " " -f 3) + used=$(echo $line | cut -d " " -f 4) + perc=$((100*used/total)) + + echo -e "$name\t($(($total/1024000))GB)\t$perc%" | sort +done < /proc/swaps