Add files via upload

This commit is contained in:
2019-03-28 13:35:54 +03:00
committed by GitHub
commit e8ebfe59c5
8 changed files with 168 additions and 0 deletions

3
10-display-name Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
figlet -k -f slant "$(hostname)"

26
20-sysinfo Normal file
View File

@@ -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"

32
30-hdd-free Normal file
View File

@@ -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

19
30-hdd-temp Normal file
View File

@@ -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/^/ /'

19
30-hdd-temp.save Normal file
View File

@@ -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/^/ /'

35
40-services Normal file
View File

@@ -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/^/ /'

5
50-flexget Normal file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
echo "
Flexget ACCEPTED:"
column -t -s % /home/server/.flexget/accepted.log | tail -n 10

29
60-lxd Normal file
View File

@@ -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/^/ /'