commit e8ebfe59c59b9e7558c833bdd04d6ea1f93449fe Author: Slava Date: Thu Mar 28 13:35:54 2019 +0300 Add files via upload diff --git a/10-display-name b/10-display-name new file mode 100644 index 0000000..ac8b8ac --- /dev/null +++ b/10-display-name @@ -0,0 +1,3 @@ +#!/bin/bash + +figlet -k -f slant "$(hostname)" diff --git a/20-sysinfo b/20-sysinfo new file mode 100644 index 0000000..c5467cf --- /dev/null +++ b/20-sysinfo @@ -0,0 +1,26 @@ +#!/bin/bash + +# get load averages +IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(/bin/cat /proc/loadavg | awk '{ print $1,$2,$3 }') +# get free memory +IFS=" " read USED FREE TOTAL <<<$(free -htm | grep "Mem" | awk {'print $3,$4,$2'}) +# get processes +PROCESS=`ps -eo user=|sort|uniq -c | awk '{ print $2 " " $1 }'` +PROCESS_ALL=`echo "$PROCESS"| awk {'print $2'} | awk '{ SUM += $1} END { print SUM }'` +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 }'` + +W="\e[0;39m" +G="\e[1;32m" + +echo -e " +${W}system info: +$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 Load........: $G$LOAD1$W (1m), $G$LOAD5$W (5m), $G$LOAD15$W (15m) +$W Processes...:$W $G$PROCESS_ROOT$W (root), $G$PROCESS_USER$W (user) | $G$PROCESS_ALL$W (total) + +$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" diff --git a/30-hdd-free b/30-hdd-free new file mode 100644 index 0000000..ded98c0 --- /dev/null +++ b/30-hdd-free @@ -0,0 +1,32 @@ +#!/bin/bash + +mountpoints=('/mnt/sdb1' '/') +barWidth=50 +maxDiscUsage=90 +clear="\e[39m\e[0m" +dim="\e[2m" +barclear="" +echo + +for point in "${mountpoints[@]}"; do + line=$(df -hl "${point}") + usagePercent=$(echo "$line"|tail -n1|awk '{print $5;}'|sed 's/%//') + usedBarWidth=$((($usagePercent*$barWidth)/100)) + barContent="" + color="\e[32m" + if [ "${usagePercent}" -ge "${maxDiscUsage}" ]; then + color="\e[31m" + fi + barContent="${color}" + for sep in $(seq 1 $usedBarWidth); do + barContent="${barContent}|" + done + barContent="${barContent}${clear}${dim}" + for sep in $(seq 1 $(($barWidth-$usedBarWidth))); do + barContent="${barContent}-" + done + bar="[${barContent}${clear}]" + echo "${line}" | awk '{if ($1 != "Filesystem") printf("%-30s%+3s used out of %+5s\n", $1, $3, $2); }' | sed -e 's/^/ /' + echo -e "${bar}" | sed -e 's/^/ /' + +done diff --git a/30-hdd-temp b/30-hdd-temp new file mode 100644 index 0000000..511ae49 --- /dev/null +++ b/30-hdd-temp @@ -0,0 +1,19 @@ +#!/bin/bash +sd=(sda sdb sdc sdd) +out="" +clear="\e[0m\e[39m" + +my_target_temp=45 +for i in ${!sd[@]}; do + temp=$(hddtemp -nq /dev/${sd[$i]} 2> /dev/null) + color="\e[42m" + if [ "$temp" -ge "${my_target_temp}" ]; then + color="\e[41m" + fi + out+="${sd[$i]} \e[30m $color $temp $clear ," + c=i+1 +done +out+="\n" +echo -e " +HDD Temps:" +printf "$out" | column -c $c -ts $',' | sed -e 's/^/ /' diff --git a/30-hdd-temp.save b/30-hdd-temp.save new file mode 100644 index 0000000..13a1ec3 --- /dev/null +++ b/30-hdd-temp.save @@ -0,0 +1,19 @@ +#!/bin/bash +sd=(sda sdb sdc sdd) +out="" +clear="\e[0m" + +my_target_temp=45 +for i in ${!sd[@]}; do + temp=$(hddtemp -nq /dev/${sd[$i]} 2> /dev/null) + color="\e[42m" + if [ "$temp" -ge "${my_target_temp}" ]; then + color="\e[41m" + fi + mapfile -t out <"${sd[$i]} \e[30m $color $temp°$clear \e[39m ," + c=i+1 +done +out+="\n" +echo -e " +HDD Temps:" +printf "$out" | column -c $c -ts $',' | sed -e 's/^/ /' diff --git a/40-services b/40-services new file mode 100644 index 0000000..4d507e4 --- /dev/null +++ b/40-services @@ -0,0 +1,35 @@ +#!/bin/bash + +# set column width +COLUMNS=3 +# colors +green="\e[1;32m" +red="\e[1;31m" +undim="\e[0m" +services=( "lxd" "smartd" "plexmediaserver" "deluge-web" "deluged" "smbd" "minecraft@gregtech" "flexget") +# sort services +IFS=$'\n' services=($(sort <<<"${services[*]}")) +unset IFS + +service_status=() +# get status of all services +for service in "${services[@]}"; do + service_status+=($(systemctl is-active "$service")) +done + +for i in ${!services[@]}; do + # color green if service is active, else red + if [[ "${service_status[$i]}" == "active" ]]; then + out+="${services[$i]}:,${green}${service_status[$i]}${undim}," + else + out+="${services[$i]}:,${red}${service_status[$i]}${undim}," + fi + # insert \n every $COLUMNS column + if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then + out+="\n" + fi +done +out+="\n" + +printf "\nservices:\n" +printf "$out" | column -ts $',' | sed -e 's/^/ /' diff --git a/50-flexget b/50-flexget new file mode 100644 index 0000000..a09e6d9 --- /dev/null +++ b/50-flexget @@ -0,0 +1,5 @@ +#!/bin/bash + +echo " +Flexget ACCEPTED:" +column -t -s % /home/server/.flexget/accepted.log | tail -n 10 diff --git a/60-lxd b/60-lxd new file mode 100644 index 0000000..e0c6ebb --- /dev/null +++ b/60-lxd @@ -0,0 +1,29 @@ +#!/bin/bash + +# set column width +COLUMNS=2 +# colors +green="\e[1;32m" +red="\e[1;31m" +undim="\e[0m" + +mapfile -t containers < <(lxc list -c ns | awk '{ print $2,$4 }' | sed '/^\s*$/d' | tail -n +2) + +out="" +for i in "${!containers[@]}"; do + IFS=" " read name status <<< ${containers[i]} + # color green if service is active, else red + if [[ "${status}" == "RUNNING" ]]; then + out+="${name}:,${green}${status,,}${undim}," + else + out+="${name}:,${red}${status,,}${undim}," + fi + # insert \n every $COLUMNS column + if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then + out+="\n" + fi +done +out+="\n" + +printf "\nlxd status:\n" +printf "$out" | column -ts $',' | sed -e 's/^/ /'