Refactor installation scripts: rename server installer and merge agent verification
This commit is contained in:
parent
e8a5fc61ad
commit
4129a6fed1
18
README.md
18
README.md
@ -17,13 +17,13 @@
|
||||
默认安装最新稳定版 , 默认使用当前主机名作为域名
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/install.sh | bash
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/server-install.sh | bash
|
||||
```
|
||||
|
||||
### 指定版本与域名 (安装建议)
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/install.sh \
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/server-install.sh \
|
||||
| bash -s -- observability.svc.plus
|
||||
```
|
||||
|
||||
@ -70,7 +70,7 @@ And gather the synergistic superpowers of all [**444+ PostgreSQL Extensions**](h
|
||||
[**Prepare**](https://svc.plus/docs/deploy/prepare) a fresh `x86_64` / `aarch64` node runs any [**compatible**](https://svc.plus/docs/ref/linux) **Linux** OS Distros, then [**Install**](https://svc.plus/docs/setup/install#install) **Pigsty** with:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/install.sh | bash
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/server-install.sh | bash
|
||||
```
|
||||
|
||||
Then [**configure**](https://svc.plus/docs/concept/iac/configure) and run the [**`deploy.yml`**](https://svc.plus/docs/setup/playbook) playbook with an [**admin user**](https://svc.plus/docs/deploy/admin) (**nopass** `ssh` & `sudo`):
|
||||
@ -108,14 +108,14 @@ pig sty deploy # run the deploy.yml playbook
|
||||
默认安装最新稳定版 , 默认使用当前主机名作为域名
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/install.sh | bash
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/server-install.sh | bash
|
||||
```
|
||||
|
||||
### 指定版本与域名 (安装建议)
|
||||
|
||||
```bash
|
||||
# bash -s -- <版本> <域名>
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/install.sh \
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/server-install.sh \
|
||||
| bash -s -- observability.svc.plus
|
||||
```
|
||||
|
||||
@ -143,13 +143,7 @@ curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability
|
||||
| bash -s -- --endpoint https://infra.svc.plus/ingest/otlp
|
||||
```
|
||||
|
||||
### Verification
|
||||
|
||||
After installation, you can verify the status of the agents:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/cloud-neutral-toolkit/observability.svc.plus/main/scripts/agent-verify.sh | bash
|
||||
```
|
||||
> **Note**: The script automatically verifies the installation after setup.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -17,11 +17,14 @@ VECTOR_VERSION="0.36.0"
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[0;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
log_fail() { echo -e "${RED}[FAIL]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
|
||||
# Detect Architecture
|
||||
ARCH=$(uname -m)
|
||||
@ -212,6 +215,55 @@ EOF
|
||||
log_success "Vector installed and started."
|
||||
}
|
||||
|
||||
# --- 4. Verify Installation ---
|
||||
verify_installation() {
|
||||
echo ""
|
||||
log_info "---------------------------------------------------"
|
||||
log_info " Verifying Installation..."
|
||||
log_info "---------------------------------------------------"
|
||||
|
||||
# Check Services
|
||||
check_service() {
|
||||
local service=$1
|
||||
if systemctl is-active --quiet "$service"; then
|
||||
log_success "Service '$service' is running"
|
||||
else
|
||||
log_fail "Service '$service' is NOT running"
|
||||
systemctl status "$service" --no-pager | head -n 10
|
||||
fi
|
||||
}
|
||||
|
||||
check_service "node_exporter"
|
||||
check_service "process_exporter"
|
||||
check_service "vector"
|
||||
|
||||
# Check Ports
|
||||
check_port() {
|
||||
local port=$1
|
||||
local name=$2
|
||||
if ss -tulnA | grep -q ":$port "; then
|
||||
log_success "Port $port ($name) is listening"
|
||||
else
|
||||
log_fail "Port $port ($name) is NOT listening"
|
||||
fi
|
||||
}
|
||||
|
||||
echo ""
|
||||
log_info "Checking Ports..."
|
||||
check_port 9100 "Node Exporter"
|
||||
check_port 9256 "Process Exporter"
|
||||
|
||||
# Check Logs
|
||||
echo ""
|
||||
log_info "Checking Vector Logs (Last 10 lines)..."
|
||||
if journalctl -u vector -n 20 --no-pager | grep -iE "error|fail"; then
|
||||
log_warn "Possible errors found in Vector logs:"
|
||||
journalctl -u vector -n 20 --no-pager | grep -iE "error|fail"
|
||||
else
|
||||
log_success "No recent errors found in Vector logs."
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Check Permissions ---
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
log_error "This script must be run as root"
|
||||
@ -222,9 +274,10 @@ fi
|
||||
install_node_exporter
|
||||
install_process_exporter
|
||||
install_vector
|
||||
verify_installation
|
||||
|
||||
echo ""
|
||||
log_success "---------------------------------------------------"
|
||||
log_success " Agent installation complete!"
|
||||
log_success " Agent installation & verification complete!"
|
||||
log_success " Data is being pushed to: $ENDPOINT"
|
||||
log_success "---------------------------------------------------"
|
||||
|
||||
67
scripts/server-install.sh
Normal file
67
scripts/server-install.sh
Normal file
@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
#==============================================================#
|
||||
# File : install.sh
|
||||
# Mtime : 2026-02-01
|
||||
# Desc : Install observability.svc.plus
|
||||
# Usage : curl ... | bash -s <VERSION> <DOMAIN>
|
||||
#==============================================================#
|
||||
|
||||
# Default parameters
|
||||
VERSION="${1:-main}"
|
||||
DOMAIN="${2:-$(hostname)}"
|
||||
REPO_URL="https://github.com/cloud-neutral-toolkit/observability.svc.plus.git"
|
||||
INSTALL_DIR="${HOME}/pigsty"
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${BLUE}Installing observability.svc.plus...${NC}"
|
||||
echo -e "${BLUE}Version : ${VERSION}${NC}"
|
||||
echo -e "${BLUE}Domain : ${DOMAIN}${NC}"
|
||||
echo -e "${BLUE}Repo : ${REPO_URL}${NC}"
|
||||
echo -e "${BLUE}Dir : ${INSTALL_DIR}${NC}"
|
||||
|
||||
# Check for git
|
||||
if ! command -v git &> /dev/null; then
|
||||
echo -e "${RED}Error: git is not installed.${NC}"
|
||||
echo "Please install git first (yum install git / apt install git)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clone or Update
|
||||
if [ -d "${INSTALL_DIR}" ]; then
|
||||
echo -e "${BLUE}Directory ${INSTALL_DIR} already exists.${NC}"
|
||||
read -p "Overwrite? (y/N) " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
rm -rf "${INSTALL_DIR}"
|
||||
git clone -b "${VERSION}" "${REPO_URL}" "${INSTALL_DIR}"
|
||||
else
|
||||
echo -e "${BLUE}Updating existing repo...${NC}"
|
||||
cd "${INSTALL_DIR}"
|
||||
git fetch origin
|
||||
git checkout "${VERSION}" || echo -e "${RED}Version ${VERSION} not found${NC}"
|
||||
git pull origin "${VERSION}"
|
||||
fi
|
||||
else
|
||||
git clone -b "${VERSION}" "${REPO_URL}" "${INSTALL_DIR}"
|
||||
fi
|
||||
|
||||
cd "${INSTALL_DIR}"
|
||||
|
||||
# Run Bootstrap
|
||||
if [ -f "./bootstrap" ]; then
|
||||
echo -e "${BLUE}Running bootstrap...${NC}"
|
||||
./bootstrap
|
||||
else
|
||||
echo -e "${RED}bootstrap script not found!${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Installation successful!${NC}"
|
||||
echo -e "Next steps:"
|
||||
echo -e " cd ${INSTALL_DIR}"
|
||||
echo -e " ./configure # Generate config"
|
||||
echo -e " ./deploy.yml # Install"
|
||||
Loading…
Reference in New Issue
Block a user