Your channel got disconnected, but you had to quickly restore the server, or maybe you accidentally deleted the logs and all the information related to the outage? Don't worry! Thanks to my script, you will now know exactly when and why it happened. The script automatically collects and saves all possible data, such as time, date, syslogs, syslogs, etc. You can run it on a cron tab to keep it running in the background and verify the status of the channels.
Bitte melden Sie sich an, um dieses Bild zu sehen.
Bitte melden Sie sich an, um dieses Bild zu sehen.
Code:
Shell-Script
- #!/bin/sh
- # Script by: Grzyb.ovh
- GAMEDIR="/usr/home/mt2"
- LOG="$GAMEDIR/gamecore.log"
- CHS_PORT="ch11:28000 ch12:28001 ch13:28002 ch99:13099"
- DB_PORT="db:18000"
- AUTH_PORT="auth:17105"
- muchomor_tu_byl() {
- local app_path=$1
- local app=$2
- local port=$3
- local core_pattern=$4
- cd "$GAMEDIR/$app_path" || exit 1
- pid=$(sockstat -4 -l | grep .${port} | awk '{print $3}')
- if [ -z "$pid" ]; then
- echo "$(date +%H:%M:%S) $app error, start" >> "$LOG"
- grzyb_ovh="$GAMEDIR/cores/$(date +%Y-%m-%d-%H-%M)/$app"
- mkdir -p "$grzyb_ovh"
- find . -maxdepth 1 \( -name "$core_pattern" -o -name "syslog*" -o -name "syserr*" -o -name "p2p_packet_info.txt*" -o -name "start.log*" \) \
- -exec cp {} "$grzyb_ovh" \;
- ./"$app" >> start.log 2>&1 &
- sleep 2
- fi
- }
- for chs_port in $CHS_PORT; do
- app=$(echo "$chs_port" | cut -d: -f1)
- port=$(echo "$chs_port" | cut -d: -f2)
- muchomor_tu_byl "chs/$app" "$app" "$port" "game.core*"
- done
- for db_port in $DB_PORT; do
- app=$(echo "$db_port" | cut -d: -f1)
- port=$(echo "$db_port" | cut -d: -f2)
- muchomor_tu_byl "$app" "$app" "$port" "db.core*"
- done
- app=$(echo "$AUTH_PORT" | cut -d: -f1)
- port=$(echo "$AUTH_PORT" | cut -d: -f2)
- muchomor_tu_byl "$app" "$app" "$port" "auth.core*"