30 lines
838 B
Bash
Executable File
30 lines
838 B
Bash
Executable File
#!/bin/bash
|
|
# ///
|
|
# query_nodes.sh
|
|
# 描述:查询所有节点
|
|
# 作者:AI Generated
|
|
# 创建日期:2026-04-06
|
|
#
|
|
# 使用方式:
|
|
# ./query_nodes.sh # 查询所有节点
|
|
# ./query_nodes.sh <node_id> # 查询指定节点
|
|
# ///
|
|
|
|
DB_HOST=${DB_HOST:-localhost}
|
|
DB_PORT=${DB_PORT:-5432}
|
|
DB_NAME=${DB_NAME:-wxauto}
|
|
DB_USER=${DB_USER:-wxauto}
|
|
DB_PASS=${DB_PASS:-wxauto_password}
|
|
|
|
export PGPASSWORD="$DB_PASS"
|
|
|
|
if [ -n "$1" ]; then
|
|
echo "=== 节点信息: $1 ==="
|
|
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c \
|
|
"SELECT * FROM nodes WHERE node_id = '$1';"
|
|
else
|
|
echo "=== 所有节点 ==="
|
|
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c \
|
|
"SELECT node_id, name, api_url, enabled, status, wechat_status, is_healthy, group FROM nodes ORDER BY node_id;"
|
|
fi
|