You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
4.0 KiB
Bash

#!/bin/bash
# System status script
# Feel free to copypaste, modify, and share; that's what we did.
# Text colors
RED='\e[1;31m'
WHT='\e[1;37m'
GRN='\e[1;32m'
BLU='\e[0;34m'
CLR='\e[0m'
INACTIVE="$RED[INACTIVE]$CLR"
ACTIVE="$GRN[ACTIVE]$CLR"
echo -e "$BLU"
toilet -f smblock.tlf "Netsyms Business"
toilet -f smblock.tlf "Accelerator"
echo -e "$CLR"
echo -e "---------------------------------------------------$WHT"
echo -e "Engineered by$BLU Netsyms Technologies$CLR"
echo -e ''
echo -e 'Home: https://netsyms.com'
echo -e 'Support: https://support.netsyms.com'
echo -e 'Source: https://source.netsyms.com'
echo -e 'Business: https://netsyms.biz'
echo -e '---------------------------------------------------'
echo -e 'The programs included with this system are free'
echo -e 'software; the exact distribution terms for each'
echo -e 'program are described in the individual files in'
echo -e '/usr/share/doc/*/copyright.'
echo -e '---------------------------------------------------'
upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
secs=$((${upSeconds}%60))
mins=$((${upSeconds}/60%60))
hours=$((${upSeconds}/3600%24))
days=$((${upSeconds}/86400))
UPTIME=`printf "%02d days, %02dh %02dm" "$days" "$hours" "$mins"`
freekb=$(cat /proc/meminfo | grep MemFree | awk {'print $2'})
totalkb=$(cat /proc/meminfo | grep MemTotal | awk {'print $2'})
freemb=$(($freekb/1000))
totalmb=$(($totalkb/1000))
percentfree=$(echo "scale=0; $freekb*100/$totalkb" | bc)
echo -e "Date .................................. $WHT$(date +%b\ %e\ %Y)$CLR"
echo -e "Time ..................................... $WHT$(date +%H:%M:%S)$CLR"
echo -e "Uptime ........................... $WHT$UPTIME$CLR"
echo -e "Processes ..................................... $WHT$(ps ax | wc -l | tr -d " ")$CLR"
echo -e "Load averages ....................$WHT$(uptime | awk -F'[a-z]:' '{ print $2}')$CLR"
if (( $percentfree < 30 )); then
echo -e "Memory used .......................... $RED$(($totalmb-$freemb)) MB ($((100-$percentfree))%)$CLR"
echo -e "Memory free .......................... $RED$freemb MB ($percentfree%)$CLR"
else
echo -e "Memory used .......................... $GRN$(($totalmb-$freemb)) MB ($((100-$percentfree))%)$CLR"
echo -e "Memory free .......................... $GRN$freemb MB ($percentfree%)$CLR"
fi
cpu=$(</sys/class/thermal/thermal_zone0/temp)
cpu=$((cpu/1000))
if (( $cpu > 45 )); then
cpu="$RED$cpu\u00b0C$CLR"
else
cpu="$GRN$cpu\u00b0C$CLR"
fi
echo -e "CPU temperature .............................. $cpu"
#
# Service Status
#
if [ $(systemctl status cjdns.service | grep 'Active: ' | awk '{ print $2 }') = 'active' ]; then
echo -e "cjdns Service ............................ $ACTIVE"
else
echo -e "cjdns Service .......................... $INACTIVE"
fi
if [ $(systemctl status nginx.service | grep 'Active: ' | awk '{ print $2 }') = 'active' ]; then
echo -e "nginx Service ............................ $ACTIVE"
else
echo -e "nginx Service .......................... $INACTIVE"
fi
if [ $(systemctl status php7.0-fpm.service | grep 'Active: ' | awk '{ print $2 }') = 'active' ]; then
echo -e "php-fpm Service .......................... $ACTIVE"
else
echo -e "php-fpm Service ........................ $INACTIVE"
fi
#
# IP/Network Info
#
echo -e "---------------------------------------------------$WHT"
echo -e "Local IP$CLR"
ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
echo -e "---------------------------------------------------$WHT"
echo -e "Public IP$CLR"
dig +short myip.opendns.com @resolver1.opendns.com
echo -e "---------------------------------------------------$WHT"
echo -e "CJDNS IP$CLR"
sudo grep -m 1 '"ipv6"' /etc/cjdroute.conf | awk '{ print $2 }' | sed 's/[",]//g'
echo -e '---------------------------------------------------'
echo -e "For network bandwidth usage data, run$WHT vnstat$CLR"
echo -e "To refresh this status message, run$WHT status$CLR"
#vnstat -i eth0+tun0+wlan0 --style 0
echo -e '---------------------------------------------------'