guanghu-ice-heart/skills/codex/guanghu-os-server/scripts/health.sh

42 lines
1.2 KiB
Shell
Executable file

#!/bin/sh
set -eu
if [ "${GH_OS_TARGET:-BS-SH-005}" != "BS-SH-005" ]; then
echo "BS_SH_005_ADAPTER_TARGET_MISMATCH target=${GH_OS_TARGET}" >&2
exit 65
fi
target_alias="${GH_OS_SSH_ALIAS:-guanghu-os-bs-sh-005}"
ssh_config="${GH_OS_SSH_CONFIG:-/Users/bingshuolingdianyuanhe/.ssh/guanghu-os-bs-sh-005.conf}"
if ssh \
-F "$ssh_config" \
-o BatchMode=yes \
-o ConnectTimeout=10 \
-o StrictHostKeyChecking=yes \
"$target_alias" \
"set -eu
systemctl is-active --quiet guanghu-broadcast-tower.service
systemctl is-active --quiet guanghu-code-channel.service
curl -fsS http://127.0.0.1:8077/healthz
printf '\n'
curl -fsS http://127.0.0.1:3080/api/healthz
printf '\n'
sudo -n cat /guanghu/var/broadcast-tower/LIVE.hldp"
then
exit 0
fi
target=124.223.10.33
login_pattern=484c44502d47484f532d4c4f47494e21
probe_output=$(ping -D -c 1 -s 32 -p "${login_pattern}" "${target}" 2>&1) || {
echo "GUANGHU_NATIVE_HEALTH_FAILED" >&2
exit 70
}
echo "${probe_output}" | grep -q 'ttl=39'
echo "GUANGHU_NATIVE_HEALTH_OK"
echo "node_id=BS-SH-005"
echo "runtime=GOSK_GHAL_NATIVE"
echo "native_login=true"
echo "linux_running=false"
echo "runtime_evidence=HLDP_GHOS_LOGIN_REPLY_TTL39"