dev
This commit is contained in:
60
domain-api/deploy/linux/collect_diagnostics.sh
Normal file
60
domain-api/deploy/linux/collect_diagnostics.sh
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
BASE_DIR="${1:-/opt/domaincheck}"
|
||||
OUT_DIR="${2:-$BASE_DIR/diagnostics}"
|
||||
STAMP="$(date +%Y%m%d_%H%M%S)"
|
||||
BUNDLE_DIR="$OUT_DIR/diag_$STAMP"
|
||||
|
||||
mkdir -p "$BUNDLE_DIR"
|
||||
|
||||
write_cmd() {
|
||||
local name="$1"
|
||||
shift
|
||||
{
|
||||
echo "# command: $*"
|
||||
echo
|
||||
"$@"
|
||||
} > "$BUNDLE_DIR/$name.txt" 2>&1 || true
|
||||
}
|
||||
|
||||
copy_if_exists() {
|
||||
local src="$1"
|
||||
local dest="$2"
|
||||
if [ -f "$src" ]; then
|
||||
cp "$src" "$dest"
|
||||
fi
|
||||
}
|
||||
|
||||
write_cmd "systemctl_api" systemctl status domaincheck-api --no-pager
|
||||
write_cmd "systemctl_worker" systemctl status domaincheck-worker --no-pager
|
||||
write_cmd "journal_api" journalctl -u domaincheck-api -n 200 --no-pager
|
||||
write_cmd "journal_worker" journalctl -u domaincheck-worker -n 200 --no-pager
|
||||
write_cmd "api_health_curl" curl -sS http://127.0.0.1:8100/health
|
||||
write_cmd "api_preflight_curl" curl -sS http://127.0.0.1:8100/api/v1/runtime/preflight
|
||||
write_cmd "api_runtime_curl" curl -sS http://127.0.0.1:8100/api/v1/runtime/status
|
||||
write_cmd "ps_processes" ps -ef
|
||||
write_cmd "ss_listen" ss -lntp
|
||||
write_cmd "df_h" df -h
|
||||
write_cmd "free_h" free -h
|
||||
|
||||
copy_if_exists "$BASE_DIR/domainCheck/.env" "$BUNDLE_DIR/domainCheck.env"
|
||||
copy_if_exists "$BASE_DIR/domain-api/.env" "$BUNDLE_DIR/domain-api.env"
|
||||
|
||||
if [ -d "$BASE_DIR/domain-api/runtime" ]; then
|
||||
cp -r "$BASE_DIR/domain-api/runtime" "$BUNDLE_DIR/domain-api-runtime"
|
||||
fi
|
||||
|
||||
if [ -f "$BASE_DIR/domainCheck/logs/app.log" ]; then
|
||||
tail -n 300 "$BASE_DIR/domainCheck/logs/app.log" > "$BUNDLE_DIR/app_tail.log" 2>&1 || true
|
||||
fi
|
||||
|
||||
if [ -f "$BASE_DIR/domainCheck/detect_worker.log" ]; then
|
||||
tail -n 500 "$BASE_DIR/domainCheck/detect_worker.log" > "$BUNDLE_DIR/detect_worker_tail.log" 2>&1 || true
|
||||
fi
|
||||
|
||||
ARCHIVE="$OUT_DIR/diag_$STAMP.tar.gz"
|
||||
tar -czf "$ARCHIVE" -C "$OUT_DIR" "diag_$STAMP"
|
||||
|
||||
echo "diagnostics_dir=$BUNDLE_DIR"
|
||||
echo "diagnostics_archive=$ARCHIVE"
|
||||
Reference in New Issue
Block a user