Rework for modular system

Autoadd disks to temps (only for sd*, and works on smartmontools)
Some cosmetic changes
This commit is contained in:
2020-01-14 02:18:46 +03:00
parent ff44ea7749
commit 003a32b4a2
6 changed files with 49 additions and 40 deletions

View File

@@ -1,3 +1,6 @@
#!/bin/bash #!/bin/bash
color="\e[1;33m"
figlet -k -f slant "$(hostname)" clear="\e[m"
echo -e ${color}
figlet -k -f slant $(hostname)
echo -e ${clear}

View File

@@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
# get load averages
IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(/bin/cat /proc/loadavg | awk '{ print $1,$2,$3 }')
# get free memory # get free memory
IFS=" " read USED FREE TOTAL <<<$(free -htm | grep "Mem" | awk {'print $3,$4,$2'}) IFS=" " read USED FREE TOTAL <<<$(free -htm | grep "Mem" | awk {'print $3,$4,$2'})
# get processes # get processes
@@ -11,16 +9,13 @@ PROCESS_ROOT=`echo "$PROCESS"| grep root | awk {'print $2'}`
PROCESS_USER=`echo "$PROCESS"| grep -v root | awk {'print $2'} | awk '{ SUM += $1} END { print SUM }'` PROCESS_USER=`echo "$PROCESS"| grep -v root | awk {'print $2'} | awk '{ SUM += $1} END { print SUM }'`
W="\e[0;39m" W="\e[0;39m"
G="\e[1;32m" G="\e[1;33m"
echo -e " echo -e "
${W}system info: ${W}system info:
$W Distro......: $W`cat /etc/*release | grep "PRETTY_NAME" | cut -d "=" -f 2- | sed 's/"//g'` $W Uptime.: $W`uptime -p | awk '{if ($1 != "test") printf("%s %s %s %s\n", $2, $3, $4, $5); }' | sed 's/,//g'`
$W Kernel......: $W`uname -sr` $W Distro.: $W`cat /etc/*release | grep "PRETTY_NAME" | cut -d "=" -f 2- | sed 's/"//g'`
$W Kernel.: $W`uname -sr`
$W Uptime......: $W`uptime -p` $W Proc...: $W$G$PROCESS_ROOT$W (r), $G$PROCESS_USER$W (u) | $G$PROCESS_ALL$W (t)
$W Load........: $G$LOAD1$W (1m), $G$LOAD5$W (5m), $G$LOAD15$W (15m) $W CPU....:$W`cat /proc/cpuinfo | grep "name" | cut -d : -f2 | uniq | cut -f1 -d"@" | sed 's/(TM)//;s/(R)//;s/CPU//'`
$W Processes...:$W $G$PROCESS_ROOT$W (root), $G$PROCESS_USER$W (user) | $G$PROCESS_ALL$W (total) $W Memory.: $G$USED$W used | $G$TOTAL$W in total$W"
$W CPU.........: $W`cat /proc/cpuinfo | grep "model name" | cut -d ' ' -f3- | awk {'print $0'} | head -1`
$W Memory......: $G$USED$W used, $G$FREE$W free, $G$TOTAL$W in total$W"

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
mountpoints=('/mnt/sdb1' '/' '/mnt/backup/') mountpoints=('/dev/sdf1' '/dev/vg1/downloads' '/dev/sdb1')
barWidth=50 barWidth=34
maxDiscUsage=90 maxDiscUsage=90
clear="\e[39m\e[0m" clear="\e[39m\e[0m"
dim="\e[2m" dim="\e[2m"
@@ -10,10 +10,11 @@ echo
echo 'HDD free:' echo 'HDD free:'
for point in "${mountpoints[@]}"; do for point in "${mountpoints[@]}"; do
line=$(df -hl "${point}") line=$(df -hl "${point}")
label=$(lsblk -o label "${point}")
usagePercent=$(echo "$line"|tail -n1|awk '{print $5;}'|sed 's/%//') usagePercent=$(echo "$line"|tail -n1|awk '{print $5;}'|sed 's/%//')
usedBarWidth=$((($usagePercent*$barWidth)/100)) usedBarWidth=$((($usagePercent*$barWidth)/100))
barContent="" barContent=""
color="\e[32m" color="\e[33m"
if [ "${usagePercent}" -ge "${maxDiscUsage}" ]; then if [ "${usagePercent}" -ge "${maxDiscUsage}" ]; then
color="\e[31m" color="\e[31m"
fi fi
@@ -26,7 +27,8 @@ for point in "${mountpoints[@]}"; do
barContent="${barContent}-" barContent="${barContent}-"
done done
bar="[${barContent}${clear}]" bar="[${barContent}${clear}]"
echo "${line}" | awk '{if ($1 != "Filesystem") printf("%-30s%+3s used out of %+5s\n", $1, $3, $2); }' | sed -e 's/^/ /' echo "${label}" | awk '{if ($1 != "LABEL") printf("%-10s", $1); }'
echo -e "${bar}" | sed -e 's/^/ /' echo "${line}" | awk '{if ($1 != "Filesystem") printf("%+8s used out of %+5s\n", $3, $2); }'
echo -e "${bar}"
done done

View File

@@ -1,23 +1,30 @@
#!/bin/bash #!/bin/bash
sd=(sda) disks=${disks:-()}
out="" out=""
dim="\e[43m"
white="\e[31m"
label="\e[1;30m"
COLUMNS=3 COLUMNS=3
clear="\e[0m\e[39m" clear="\e[0m\e[39m"
my_target_temp=45 my_target_temp=45
for i in ${!sd[@]}; do k=0
temp=$(smartctl -a /dev/${sd[$i]} | grep Temperature_Celsius | grep 194 | awk '{print $10}' 2> /dev/null)
for i in {a..z}; do
temp=$(smartctl -a /dev/sd${i} | grep Temperature_Celsius | grep 194 | awk '{print $10}' 2> /dev/null)
color="\e[42m" color="\e[42m"
if [ "$temp" -ge "${my_target_temp}" ]; then ((k++))
color="\e[41m" if [ -z "$temp" ]; then
out+=""
else
if [ "$temp" -ge "${my_target_temp}" ]; then
color="\e[41m"
fi
out+="${dim}${white}${label} sd${i} \e[30m$color $temp $clear,"
if [ $(($k % $COLUMNS)) -eq 0 ]; then
out+="\n"
fi
fi fi
out+="${sd[$i]} \e[30m $color $temp $clear ,"
c=i+1
if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then
out+="\n"
fi
done done
out+="\n" out+="\n"
echo -e " echo -e "HDD Temps:"
HDD Temps:" printf "$out" | column -c $k -ts $',' | sed -e 's/^/ /'
printf "$out" | column -c $c -ts $',' | sed -e 's/^/ /'

View File

@@ -1,12 +1,13 @@
#!/bin/bash #!/bin/bash
export LANG='en_US.UTF-8'
# set column width # set column width
COLUMNS=3 COLUMNS=2
# colors # colors
green="\e[1;32m" green="\e[1;32m"
red="\e[1;31m" red="\e[1;31m"
undim="\e[0m" undim="\e[0m"
services=( "smartd" "plexmediaserver" "docker" "smdb") services=( "smartd" "plexmediaserver" "docker" "smbd")
# sort services # sort services
IFS=$'\n' services=($(sort <<<"${services[*]}")) IFS=$'\n' services=($(sort <<<"${services[*]}"))
unset IFS unset IFS
@@ -20,9 +21,9 @@ done
for i in ${!services[@]}; do for i in ${!services[@]}; do
# color green if service is active, else red # color green if service is active, else red
if [[ "${service_status[$i]}" == "active" ]]; then if [[ "${service_status[$i]}" == "active" ]]; then
out+="${services[$i]}:,${green}${service_status[$i]}${undim}," out+="${services[$i]}:,${green}${undim},"
else else
out+="${services[$i]}:,${red}${service_status[$i]}${undim}," out+="${services[$i]}:,${red}${undim},"
fi fi
# insert \n every $COLUMNS column # insert \n every $COLUMNS column
if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then

View File

@@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
export LANG='en_US.UTF-8'
# set column width # set column width
COLUMNS=2 COLUMNS=2
# colors # colors
@@ -17,9 +18,9 @@ for i in "${!containers[@]}"; do
IFS=" " read name status <<< ${containers[i]} IFS=" " read name status <<< ${containers[i]}
# color green if service is active, else red # color green if service is active, else red
if [[ "${status}" == "Up" ]]; then if [[ "${status}" == "Up" ]]; then
out+="${name}:,${green}${status,,}${undim}," out+="${name}:,${green}${undim},"
else else
out+="${name}:,${red}${status,,}${undim}," out+="${name}:,${red}${undim},"
fi fi
# insert \n every $COLUMNS column # insert \n every $COLUMNS column
if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then
@@ -29,4 +30,4 @@ done
out+="\n" out+="\n"
printf "\nDocker status:\n" printf "\nDocker status:\n"
printf "$out" | column -ts $',' | sed -e 's/^/ /' printf "$out" | column -ts $',' | sed -e 's/^/ /'