2023-07-06 18:13:10 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# shellcheck disable=SC2009 disable=SC2086
|
|
|
|
export "LINEREP=\033[F"
|
|
|
|
export "LINESPACE= "
|
|
|
|
export "COLOR_RED=\e[0;31m"
|
|
|
|
export "COLOR_GREEN=\e[0;32m"
|
|
|
|
export "COLOR_YELLOW=\e[0;33m"
|
|
|
|
export "COLOR_BLUE=\e[0;34m"
|
|
|
|
export "COLOR_PURPLE=\e[0;35m"
|
|
|
|
export "COLOR_CYAN=\e[0;36m"
|
|
|
|
export "COLOR_RESET=\e[0m"
|
|
|
|
function ntb(){
|
|
|
|
case "$1" in
|
|
|
|
"1") echo "true" ;;
|
|
|
|
"2") echo "false" ;;
|
|
|
|
*) echo "error in conversion ($1)" ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
function isonline(){
|
|
|
|
case "$1" in
|
|
|
|
"0") echo "${COLOR_GREEN}online${COLOR_RESET} " ;;
|
|
|
|
"1") echo "${COLOR_RED}offline${COLOR_RESET}" ;;
|
|
|
|
*) echo "error in conversion ($1)" ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
echo -e "${COLOR_CYAN}Server statistics report"
|
|
|
|
echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services${LINESPACE}"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mastodon (Puma)${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_MASTODON_PUMA=$(ps -eo args|grep puma|grep "\\[live\\]"&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mastodon (Streaming)${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_MASTODON_STREAMING=$(ps -eo args|grep node|grep streaming&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mastodon (Sidekiq)${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_MASTODON_SIDEKIQ=$(ps -eo args|grep sidekiq|grep ' live '&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: httpd${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_HTTPD=$(ps -eo args|grep httpd|grep ' -k '&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Docker${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_DOCKER=$(ps -eo args|grep dockerd|grep '\--containerd'&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: MariaDB${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_MARIADB=$(ps -eo args|grep '/usr/bin'|grep mariadbd&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PHP 8.2 FPM${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_PHP82=$(ps -eo args|grep php-fpm|grep php82&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PHP 8.1 FPM${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_PHP81=$(ps -eo args|grep php-fpm|grep php81&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PHP 7.4 FPM${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_PHP74=$(ps -eo args|grep php-fpm|grep php74&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: fail2ban${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_FAIL2BAN=$(ps -eo args|grep fail2ban-server|grep python3&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Forgejo${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_FORGEJO=$(ps -eo args|grep forgejo|grep 'web -c'&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Traccar${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_TRACCAR=$(ps -eo args|grep traccar|grep java&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: SOSSchedule${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_SOSSCHEDULE=$(ps -eo args|grep sosschedule|grep bash&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Pterodactyl Daemon (Wings)${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_WINGS=$(ps -eo args|grep wings|grep '/usr/local/bin'&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: pteroq${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_PTEROQ=$(ps -eo args|grep 'artisan queue:work'|grep php&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Uptime Kuma{LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_UPTIMEKUMA=$(docker ps|grep uptime-kuma&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Adminer${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_ADMINER=$(docker ps|grep adminer&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: PostgreSQL${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_POSTGRES=$(docker ps|grep postgres&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
if [ "$VERBOSE" ]; then echo -e "${LINEREP}${COLOR_PURPLE}:: Computing running services: Mail server${LINESPACE}"; fi
|
2023-07-06 18:13:10 +02:00
|
|
|
export "SERVICES_MAILSERVER=$(docker ps|grep mailserver&>/dev/null;echo $?)"
|
2023-07-18 14:34:16 +02:00
|
|
|
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 $?)"
|
2023-07-06 18:13:10 +02:00
|
|
|
echo -e "${LINEREP}${COLOR_PURPLE}:: Processing data${LINESPACE}"
|
|
|
|
export "SERVICES_MASTODON_PUMA=$(isonline $SERVICES_MASTODON_PUMA)"
|
|
|
|
export "SERVICES_MASTODON_STREAMING=$(isonline $SERVICES_MASTODON_STREAMING)"
|
|
|
|
export "SERVICES_MASTODON_SIDEKIQ=$(isonline $SERVICES_MASTODON_SIDEKIQ)"
|
|
|
|
export "SERVICES_HTTPD=$(isonline $SERVICES_HTTPD)"
|
|
|
|
export "SERVICES_DOCKER=$(isonline $SERVICES_DOCKER)"
|
|
|
|
export "SERVICES_MARIADB=$(isonline $SERVICES_MARIADB)"
|
|
|
|
export "SERVICES_PHP82=$(isonline $SERVICES_PHP82)"
|
|
|
|
export "SERVICES_PHP81=$(isonline $SERVICES_PHP81)"
|
|
|
|
export "SERVICES_PHP74=$(isonline $SERVICES_PHP74)"
|
|
|
|
export "SERVICES_FAIL2BAN=$(isonline $SERVICES_FAIL2BAN)"
|
|
|
|
export "SERVICES_FORGEJO=$(isonline $SERVICES_FORGEJO)"
|
|
|
|
export "SERVICES_TRACCAR=$(isonline $SERVICES_TRACCAR)"
|
|
|
|
export "SERVICES_SOSSCHEDULE=$(isonline $SERVICES_SOSSCHEDULE)"
|
|
|
|
export "SERVICES_WINGS=$(isonline $SERVICES_WINGS)"
|
|
|
|
export "SERVICES_PTEROQ=$(isonline $SERVICES_PTEROQ)"
|
|
|
|
export "SERVICES_UPTIMEKUMA=$(isonline $SERVICES_UPTIMEKUMA)"
|
|
|
|
export "SERVICES_ADMINER=$(isonline $SERVICES_ADMINER)"
|
|
|
|
export "SERVICES_POSTGRES=$(isonline $SERVICES_POSTGRES)"
|
|
|
|
export "SERVICES_MAILSERVER=$(isonline $SERVICES_MAILSERVER)"
|
2023-07-18 14:34:16 +02:00
|
|
|
export "SERVICES_CRONIE=$(isonline $SERVICES_CRONIE)"
|
2023-07-06 18:13:10 +02:00
|
|
|
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"
|
2023-07-18 14:34:16 +02:00
|
|
|
echo -e "${COLOR_RESET} $SERVICES_SOSSCHEDULE SOSSchedule"
|
2023-07-06 18:13:10 +02:00
|
|
|
echo -e "${COLOR_RESET} $SERVICES_MARIADB MariaDB"
|
|
|
|
echo -e "${COLOR_RESET} $SERVICES_POSTGRES PostgreSQL"
|
2023-07-18 14:34:16 +02:00
|
|
|
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"
|
2023-07-06 18:13:10 +02:00
|
|
|
echo -e "${COLOR_RESET} $SERVICES_ADMINER Adminer"
|
2023-07-18 14:34:16 +02:00
|
|
|
echo -e "${COLOR_RESET} $SERVICES_HTTPD httpd"
|
|
|
|
echo -e "${COLOR_RESET} $SERVICES_MAILSERVER Mail server"
|
2023-07-06 18:13:10 +02:00
|
|
|
echo -e "${COLOR_RESET} $SERVICES_UPTIMEKUMA Uptime Kuma"
|
|
|
|
echo -e "${COLOR_RESET} $SERVICES_FORGEJO Forgejo"
|
|
|
|
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"
|
2023-07-18 14:34:16 +02:00
|
|
|
echo -e "${COLOR_RESET} $SERVICES_CRONIE Cronie"
|