Initial commit of utility scripts

This commit is contained in:
Alex Selimov 2024-12-12 20:16:38 -05:00
parent ac77586a15
commit 1faeefffd7
34 changed files with 1328 additions and 1 deletions

19
bin/bar_cpu.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash
loads=($(mpstat -P ALL 1 1 | awk '/Average:/ && $2 ~ /[0-9]/ {print $3}'))
warn=''
if [ ${loads[0]} -gt 80 ]; then
warn=$(echo "1 "$warn)
fi
if [ ${loads[1]} -gt 80 ]; then
warn=$(echo "2 "$warn)
fi
if [ ${loads[2]} -gt 80 ]; then
warn=$(echo "3 "$warn)
fi
if [ ${loads[3]} -gt 80 ]; then
warn=$(echo "4 "$warn)
fi
avg=$(echo "(${loads[0]}+${loads[1]}+${loads[2]}+${loads[3]})/4" | bc)
echo $warn $avg%