Add additional information (VERBOSE env)

This commit is contained in:
StarOpenSource 2023-07-18 14:34:16 +02:00
parent fffac845f6
commit 7b921a1184
2 changed files with 73 additions and 16 deletions

View file

@ -26,25 +26,46 @@ function isonline(){
echo -e "${COLOR_CYAN}Server statistics report"
echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services${LINESPACE}"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mastodon (Puma)${LINESPACE}"; fi
export "SERVICES_MASTODON_PUMA=$(ps -eo args|grep puma|grep "\\[live\\]"&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mastodon (Streaming)${LINESPACE}"; fi
export "SERVICES_MASTODON_STREAMING=$(ps -eo args|grep node|grep streaming&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mastodon (Sidekiq)${LINESPACE}"; fi
export "SERVICES_MASTODON_SIDEKIQ=$(ps -eo args|grep sidekiq|grep ' live '&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: httpd${LINESPACE}"; fi
export "SERVICES_HTTPD=$(ps -eo args|grep httpd|grep ' -k '&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Docker${LINESPACE}"; fi
export "SERVICES_DOCKER=$(ps -eo args|grep dockerd|grep '\--containerd'&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: MariaDB${LINESPACE}"; fi
export "SERVICES_MARIADB=$(ps -eo args|grep '/usr/bin'|grep mariadbd&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PHP 8.2 FPM${LINESPACE}"; fi
export "SERVICES_PHP82=$(ps -eo args|grep php-fpm|grep php82&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PHP 8.1 FPM${LINESPACE}"; fi
export "SERVICES_PHP81=$(ps -eo args|grep php-fpm|grep php81&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PHP 7.4 FPM${LINESPACE}"; fi
export "SERVICES_PHP74=$(ps -eo args|grep php-fpm|grep php74&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: fail2ban${LINESPACE}"; fi
export "SERVICES_FAIL2BAN=$(ps -eo args|grep fail2ban-server|grep python3&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Forgejo${LINESPACE}"; fi
export "SERVICES_FORGEJO=$(ps -eo args|grep forgejo|grep 'web -c'&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Traccar${LINESPACE}"; fi
export "SERVICES_TRACCAR=$(ps -eo args|grep traccar|grep java&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: SOSSchedule${LINESPACE}"; fi
export "SERVICES_SOSSCHEDULE=$(ps -eo args|grep sosschedule|grep bash&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Pterodactyl Daemon (Wings)${LINESPACE}"; fi
export "SERVICES_WINGS=$(ps -eo args|grep wings|grep '/usr/local/bin'&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: pteroq${LINESPACE}"; fi
export "SERVICES_PTEROQ=$(ps -eo args|grep 'artisan queue:work'|grep php&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Uptime Kuma{LINESPACE}"; fi
export "SERVICES_UPTIMEKUMA=$(docker ps|grep uptime-kuma&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Adminer${LINESPACE}"; fi
export "SERVICES_ADMINER=$(docker ps|grep adminer&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PostgreSQL${LINESPACE}"; fi
export "SERVICES_POSTGRES=$(docker ps|grep postgres&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mail server${LINESPACE}"; fi
export "SERVICES_MAILSERVER=$(docker ps|grep mailserver&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Cronie${LINESPACE}"; fi
export "SERVICES_CRONIE=$(ps -eo args|grep cronie&>/dev/null;echo $?)"
echo -e "${LINEREP}${COLOR_PURPLE}:: Processing data${LINESPACE}"
export "SERVICES_MASTODON_PUMA=$(isonline $SERVICES_MASTODON_PUMA)"
export "SERVICES_MASTODON_STREAMING=$(isonline $SERVICES_MASTODON_STREAMING)"
@ -65,20 +86,21 @@ export "SERVICES_UPTIMEKUMA=$(isonline $SERVICES_UPTIMEKUMA)"
export "SERVICES_ADMINER=$(isonline $SERVICES_ADMINER)"
export "SERVICES_POSTGRES=$(isonline $SERVICES_POSTGRES)"
export "SERVICES_MAILSERVER=$(isonline $SERVICES_MAILSERVER)"
export "SERVICES_CRONIE=$(isonline $SERVICES_CRONIE)"
export "GENERATED=$(date '+%T %d.%m.%Y')"
echo -e "${LINEREP}${COLOR_BLUE}Report generated: ${COLOR_YELLOW}$GENERATED"
echo -e "${COLOR_RESET}${COLOR_BLUE}Services:${COLOR_RESET} $SERVICES_DOCKER Docker"
echo -e "${COLOR_RESET} $SERVICES_FAIL2BAN fail2ban"
echo -e "${COLOR_RESET} $SERVICES_SOSSCHEDULE sosschedule"
echo -e "${COLOR_RESET} $SERVICES_SOSSCHEDULE SOSSchedule"
echo -e "${COLOR_RESET} $SERVICES_MARIADB MariaDB"
echo -e "${COLOR_RESET} $SERVICES_POSTGRES PostgreSQL"
echo -e "${COLOR_RESET} $SERVICES_PHP82 PHP82 FPM"
echo -e "${COLOR_RESET} $SERVICES_PHP81 PHP81 FPM"
echo -e "${COLOR_RESET} $SERVICES_PHP74 PHP74 FPM"
echo -e "${COLOR_RESET} $SERVICES_WINGS Wings"
echo -e "${COLOR_RESET} $SERVICES_PTEROQ Pteroq"
echo -e "${COLOR_RESET} $SERVICES_PHP82 PHP 8.2 FPM"
echo -e "${COLOR_RESET} $SERVICES_PHP81 PHP 8.1 FPM"
echo -e "${COLOR_RESET} $SERVICES_PHP74 PHP 7.4 FPM"
echo -e "${COLOR_RESET} $SERVICES_WINGS Pterodactyl Daemon (Wings)"
echo -e "${COLOR_RESET} $SERVICES_PTEROQ pteroq"
echo -e "${COLOR_RESET} $SERVICES_ADMINER Adminer"
echo -e "${COLOR_RESET} $SERVICES_HTTPD Apache"
echo -e "${COLOR_RESET} $SERVICES_HTTPD httpd"
echo -e "${COLOR_RESET} $SERVICES_MAILSERVER Mail server"
echo -e "${COLOR_RESET} $SERVICES_UPTIMEKUMA Uptime Kuma"
echo -e "${COLOR_RESET} $SERVICES_FORGEJO Forgejo"
@ -86,3 +108,4 @@ echo -e "${COLOR_RESET} $SERVICES_MASTODON_PUMA Mastodon (Puma)"
echo -e "${COLOR_RESET} $SERVICES_MASTODON_STREAMING Mastodon (Streaming)"
echo -e "${COLOR_RESET} $SERVICES_MASTODON_SIDEKIQ Mastodon (Sidekiq)"
echo -e "${COLOR_RESET} $SERVICES_TRACCAR Traccar"
echo -e "${COLOR_RESET} $SERVICES_CRONIE Cronie"

View file

@ -26,41 +26,73 @@ function isonline(){
echo -e "${COLOR_CYAN}Server statistics report"
echo -e "${COLOR_PURPLE}:: Computing memory usage${LINESPACE}"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing memory usage: TOTAL${LINESPACE}"; fi
export "MEM_TOTAL=$(free -m|awk '/^Speicher:/{print $2}')"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing memory usage: USED${LINESPACE}"; fi
export "MEM_USED=$(free -m|awk '/^Speicher:/{print $3}')"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing memory usage: FREE${LINESPACE}"; fi
export "MEM_FREE=$(free -m|awk '/^Speicher:/{print $4}')"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing memory usage: AVAILABLE${LINESPACE}"; fi
export "MEM_AVAILABLE=$(free -m|awk '/^Speicher:/{print $7}')"
echo -e "${LINEREP}${COLOR_PURPLE}:: Computing swap usage${LINESPACE}"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing swap usage: TOTAL${LINESPACE}"; fi
export "SWAP_TOTAL=$(free -m|awk '/^Swap:/{print $2}')"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing swap usage: USED${LINESPACE}"; fi
export "SWAP_USED=$(free -m|awk '/^Swap:/{print $3}')"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing swap usage: FREE${LINESPACE}"; fi
export "SWAP_FREE=$(free -m|awk '/^Swap:/{print $4}')"
echo -e "${LINEREP}${COLOR_PURPLE}:: Computing processor usage${LINESPACE}"
export "CPU_USAGE=$(vmstat 1 2 | awk 'END { print 100 - $15 }')"
echo -e "${LINEREP}${COLOR_PURPLE}:: Computing disk usage${LINESPACE}"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing disk usage: PERCENT${LINESPACE}"; fi
export "DISK_PERCENT=$(df -h|grep '/dev/mapper/cryptlvm'|head -1|awk '{printf $5}')"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing disk usage: FREE${LINESPACE}"; fi
export "DISK_FREE=$(df -h|grep '/dev/mapper/cryptlvm'|head -1|awk '{printf $4}')"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing disk usage: USED${LINESPACE}"; fi
export "DISK_USED=$(df -h|grep '/dev/mapper/cryptlvm'|head -1|awk '{printf $3}')"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing disk usage: TOTAL${LINESPACE}"; fi
export "DISK_TOTAL=$(df -h|grep '/dev/mapper/cryptlvm'|head -1|awk '{printf $2}')"
echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services${LINESPACE}"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mastodon (Puma)${LINESPACE}"; fi
export "SERVICES_MASTODON_PUMA=$(ps -eo args|grep puma|grep "\\[live\\]"&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mastodon (Streaming)${LINESPACE}"; fi
export "SERVICES_MASTODON_STREAMING=$(ps -eo args|grep node|grep streaming&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mastodon (Sidekiq)${LINESPACE}"; fi
export "SERVICES_MASTODON_SIDEKIQ=$(ps -eo args|grep sidekiq|grep ' live '&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: httpd${LINESPACE}"; fi
export "SERVICES_HTTPD=$(ps -eo args|grep httpd|grep ' -k '&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Docker${LINESPACE}"; fi
export "SERVICES_DOCKER=$(ps -eo args|grep dockerd|grep '\--containerd'&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: MariaDB${LINESPACE}"; fi
export "SERVICES_MARIADB=$(ps -eo args|grep '/usr/bin'|grep mariadbd&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PHP 8.2 FPM${LINESPACE}"; fi
export "SERVICES_PHP82=$(ps -eo args|grep php-fpm|grep php82&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PHP 8.1 FPM${LINESPACE}"; fi
export "SERVICES_PHP81=$(ps -eo args|grep php-fpm|grep php81&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PHP 7.4 FPM${LINESPACE}"; fi
export "SERVICES_PHP74=$(ps -eo args|grep php-fpm|grep php74&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: fail2ban${LINESPACE}"; fi
export "SERVICES_FAIL2BAN=$(ps -eo args|grep fail2ban-server|grep python3&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Forgejo${LINESPACE}"; fi
export "SERVICES_FORGEJO=$(ps -eo args|grep forgejo|grep 'web -c'&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Traccar${LINESPACE}"; fi
export "SERVICES_TRACCAR=$(ps -eo args|grep traccar|grep java&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: SOSSchedule${LINESPACE}"; fi
export "SERVICES_SOSSCHEDULE=$(ps -eo args|grep sosschedule|grep bash&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Pterodactyl Daemon (Wings)${LINESPACE}"; fi
export "SERVICES_WINGS=$(ps -eo args|grep wings|grep '/usr/local/bin'&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: pteroq${LINESPACE}"; fi
export "SERVICES_PTEROQ=$(ps -eo args|grep 'artisan queue:work'|grep php&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Uptime Kuma{LINESPACE}"; fi
export "SERVICES_UPTIMEKUMA=$(docker ps|grep uptime-kuma&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Adminer${LINESPACE}"; fi
export "SERVICES_ADMINER=$(docker ps|grep adminer&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PostgreSQL${LINESPACE}"; fi
export "SERVICES_POSTGRES=$(docker ps|grep postgres&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mail server${LINESPACE}"; fi
export "SERVICES_MAILSERVER=$(docker ps|grep mailserver&>/dev/null;echo $?)"
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Cronie${LINESPACE}"; fi
export "SERVICES_CRONIE=$(ps -eo args|grep cronie&>/dev/null;echo $?)"
echo -e "${LINEREP}${COLOR_PURPLE}:: Processing data${LINESPACE}"
export "SERVICES_MASTODON_PUMA=$(isonline $SERVICES_MASTODON_PUMA)"
export "SERVICES_MASTODON_STREAMING=$(isonline $SERVICES_MASTODON_STREAMING)"
@ -81,6 +113,7 @@ export "SERVICES_UPTIMEKUMA=$(isonline $SERVICES_UPTIMEKUMA)"
export "SERVICES_ADMINER=$(isonline $SERVICES_ADMINER)"
export "SERVICES_POSTGRES=$(isonline $SERVICES_POSTGRES)"
export "SERVICES_MAILSERVER=$(isonline $SERVICES_MAILSERVER)"
export "SERVICES_CRONIE=$(isonline $SERVICES_CRONIE)"
export "GENERATED=$(date '+%T %d.%m.%Y')"
echo -e "${LINEREP}${COLOR_BLUE}Report generated: ${COLOR_YELLOW}$GENERATED"
echo -e "${COLOR_RESET}${COLOR_BLUE}Memory:${COLOR_RESET} Total ${COLOR_YELLOW}${MEM_TOTAL}MiB"
@ -97,16 +130,16 @@ echo -e "${COLOR_RESET} Used ${COLOR_YELLOW}${DISK_USED}iB"
echo -e "${COLOR_RESET} Free ${COLOR_YELLOW}${DISK_FREE}iB"
echo -e "${COLOR_RESET}${COLOR_BLUE}Services:${COLOR_RESET} $SERVICES_DOCKER Docker"
echo -e "${COLOR_RESET} $SERVICES_FAIL2BAN fail2ban"
echo -e "${COLOR_RESET} $SERVICES_SOSSCHEDULE sosschedule"
echo -e "${COLOR_RESET} $SERVICES_SOSSCHEDULE SOSSchedule"
echo -e "${COLOR_RESET} $SERVICES_MARIADB MariaDB"
echo -e "${COLOR_RESET} $SERVICES_POSTGRES PostgreSQL"
echo -e "${COLOR_RESET} $SERVICES_PHP82 PHP82 FPM"
echo -e "${COLOR_RESET} $SERVICES_PHP81 PHP81 FPM"
echo -e "${COLOR_RESET} $SERVICES_PHP74 PHP74 FPM"
echo -e "${COLOR_RESET} $SERVICES_WINGS Wings"
echo -e "${COLOR_RESET} $SERVICES_PTEROQ Pteroq"
echo -e "${COLOR_RESET} $SERVICES_PHP82 PHP 8.2 FPM"
echo -e "${COLOR_RESET} $SERVICES_PHP81 PHP 8.1 FPM"
echo -e "${COLOR_RESET} $SERVICES_PHP74 PHP 7.4 FPM"
echo -e "${COLOR_RESET} $SERVICES_WINGS Pterodactyl Daemon (Wings)"
echo -e "${COLOR_RESET} $SERVICES_PTEROQ pteroq"
echo -e "${COLOR_RESET} $SERVICES_ADMINER Adminer"
echo -e "${COLOR_RESET} $SERVICES_HTTPD Apache"
echo -e "${COLOR_RESET} $SERVICES_HTTPD httpd"
echo -e "${COLOR_RESET} $SERVICES_MAILSERVER Mail server"
echo -e "${COLOR_RESET} $SERVICES_UPTIMEKUMA Uptime Kuma"
echo -e "${COLOR_RESET} $SERVICES_FORGEJO Forgejo"
@ -114,6 +147,7 @@ echo -e "${COLOR_RESET} $SERVICES_MASTODON_PUMA Mastodon (Puma)"
echo -e "${COLOR_RESET} $SERVICES_MASTODON_STREAMING Mastodon (Streaming)"
echo -e "${COLOR_RESET} $SERVICES_MASTODON_SIDEKIQ Mastodon (Sidekiq)"
echo -e "${COLOR_RESET} $SERVICES_TRACCAR Traccar"
echo -e "${COLOR_RESET} $SERVICES_CRONIE Cronie"
echo -e ""
echo -e "${COLOR_RESET}${COLOR_BLUE}Tip: Use \"Available\" instead of \"Free\" for available ram. Here's why: https://linuxatemyram.com"
echo -e "${COLOR_RESET}${COLOR_BLUE}Info: The CPU usage might be reported incorrectly (polling rate issue). Use htop for accurate CPU usage.${COLOR_RESET}"