From f305a65abf5b62bdabebdbf53582b40857aabb6f Mon Sep 17 00:00:00 2001 From: "sundapeng.sdp" Date: Fri, 26 Sep 2025 14:45:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=93=E5=8C=85=E5=88=86=E5=8F=91?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=9B=AE=E5=BD=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #11 --- .../{demo-all-in-one => all-in-one}/README.md | 14 ++- .../config}/.VERSION.example | 0 .../config}/.checklist.example | 0 .../all-in-one/config/.config.env.example | 8 ++ .../deps/cron-offline.tar.gz | Bin .../node-exporter-installer/bin/node_exporter | Bin .../node-exporter-installer/check_health.sh | 0 .../node-exporter-installer/install.sh | 0 .../node-exporter-installer/package.sh | 0 .../node-exporter-installer/uninstall.sh | 0 .../scripts}/check_health.sh | 113 ++++++++++++++---- .../scripts}/install_artifact.sh | 21 ++++ .../scripts}/package_artifact.sh | 35 ++++-- .../scripts}/publish_artifact.sh | 18 +-- .../scripts}/setup.sh | 9 ++ .../scripts}/uninstall_artifact.sh | 14 +-- .../scripts}/version-manager.sh | 40 +++---- src/metric/ftp/README.md | 18 +-- 18 files changed, 202 insertions(+), 88 deletions(-) rename src/metric/client-plugins/{demo-all-in-one => all-in-one}/README.md (73%) rename src/metric/client-plugins/{demo-all-in-one => all-in-one/config}/.VERSION.example (100%) rename src/metric/client-plugins/{demo-all-in-one => all-in-one/config}/.checklist.example (100%) create mode 100644 src/metric/client-plugins/all-in-one/config/.config.env.example rename src/metric/client-plugins/{demo-all-in-one => all-in-one}/deps/cron-offline.tar.gz (100%) rename src/metric/client-plugins/{ => all-in-one/plugins}/node-exporter-installer/bin/node_exporter (100%) rename src/metric/client-plugins/{ => all-in-one/plugins}/node-exporter-installer/check_health.sh (100%) rename src/metric/client-plugins/{ => all-in-one/plugins}/node-exporter-installer/install.sh (100%) rename src/metric/client-plugins/{ => all-in-one/plugins}/node-exporter-installer/package.sh (100%) rename src/metric/client-plugins/{ => all-in-one/plugins}/node-exporter-installer/uninstall.sh (100%) rename src/metric/client-plugins/{demo-all-in-one => all-in-one/scripts}/check_health.sh (75%) rename src/metric/client-plugins/{demo-all-in-one => all-in-one/scripts}/install_artifact.sh (97%) rename src/metric/client-plugins/{demo-all-in-one => all-in-one/scripts}/package_artifact.sh (92%) rename src/metric/client-plugins/{demo-all-in-one => all-in-one/scripts}/publish_artifact.sh (88%) rename src/metric/client-plugins/{demo-all-in-one => all-in-one/scripts}/setup.sh (98%) mode change 100644 => 100755 rename src/metric/client-plugins/{demo-all-in-one => all-in-one/scripts}/uninstall_artifact.sh (95%) mode change 100644 => 100755 rename src/metric/client-plugins/{demo-all-in-one => all-in-one/scripts}/version-manager.sh (88%) diff --git a/src/metric/client-plugins/demo-all-in-one/README.md b/src/metric/client-plugins/all-in-one/README.md similarity index 73% rename from src/metric/client-plugins/demo-all-in-one/README.md rename to src/metric/client-plugins/all-in-one/README.md index 39baf4b..68640cf 100644 --- a/src/metric/client-plugins/demo-all-in-one/README.md +++ b/src/metric/client-plugins/all-in-one/README.md @@ -46,16 +46,20 @@ node-exporter-installer /path/to/node-exporter-installer 1.1.0 - 压缩版本的安装包 - 一键安装的bash脚本 -## 第四步:部署到FTP服务器(详见 FTP 搭建) +## 第四步:部署到FTP服务器 把发布的内容上传到FTP服务器,客户端就可以通过一键命令安装: ```bash -curl -u user:passwd ftp://server_ip/setup.sh -o setup.sh +curl -fsSL 'ftp://{$USER}:{$PASSWD}@{$your-ftp-server}/setup.sh' -o setup.sh +# root用户直接执行,非root用户需要使用sudo chmod +x setup.sh +bash setup.sh --server {$your-ftp-server} --user {$USER} --password {$PASSWD} -sudo ./setup.sh --server server_ip --user user --password passwd -``` +示例: +curl -fsS 'ftp://ftpuser:ZGClab1234!@177.177.70.200/setup.sh' -o setup.sh +chmod +x setup.sh +bash setup.sh --server {$域名} --user ftpuser --password 'ZGClab1234!' -这样客户就能直接从FTP服务器下载并安装组件了。 \ No newline at end of file +``` \ No newline at end of file diff --git a/src/metric/client-plugins/demo-all-in-one/.VERSION.example b/src/metric/client-plugins/all-in-one/config/.VERSION.example similarity index 100% rename from src/metric/client-plugins/demo-all-in-one/.VERSION.example rename to src/metric/client-plugins/all-in-one/config/.VERSION.example diff --git a/src/metric/client-plugins/demo-all-in-one/.checklist.example b/src/metric/client-plugins/all-in-one/config/.checklist.example similarity index 100% rename from src/metric/client-plugins/demo-all-in-one/.checklist.example rename to src/metric/client-plugins/all-in-one/config/.checklist.example diff --git a/src/metric/client-plugins/all-in-one/config/.config.env.example b/src/metric/client-plugins/all-in-one/config/.config.env.example new file mode 100644 index 0000000..8871dfe --- /dev/null +++ b/src/metric/client-plugins/all-in-one/config/.config.env.example @@ -0,0 +1,8 @@ +# Argus Metric 配置文件示例 +# 复制此文件为 config.env 并根据需要修改配置 + +# 连接master服务 +MASTER_ENDPOINT=master.argus.com:3000 + +# 上报状态间隔描述(秒) +REPORT_INTERVAL_SECONDS=60 diff --git a/src/metric/client-plugins/demo-all-in-one/deps/cron-offline.tar.gz b/src/metric/client-plugins/all-in-one/deps/cron-offline.tar.gz similarity index 100% rename from src/metric/client-plugins/demo-all-in-one/deps/cron-offline.tar.gz rename to src/metric/client-plugins/all-in-one/deps/cron-offline.tar.gz diff --git a/src/metric/client-plugins/node-exporter-installer/bin/node_exporter b/src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/bin/node_exporter similarity index 100% rename from src/metric/client-plugins/node-exporter-installer/bin/node_exporter rename to src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/bin/node_exporter diff --git a/src/metric/client-plugins/node-exporter-installer/check_health.sh b/src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/check_health.sh similarity index 100% rename from src/metric/client-plugins/node-exporter-installer/check_health.sh rename to src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/check_health.sh diff --git a/src/metric/client-plugins/node-exporter-installer/install.sh b/src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/install.sh similarity index 100% rename from src/metric/client-plugins/node-exporter-installer/install.sh rename to src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/install.sh diff --git a/src/metric/client-plugins/node-exporter-installer/package.sh b/src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/package.sh similarity index 100% rename from src/metric/client-plugins/node-exporter-installer/package.sh rename to src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/package.sh diff --git a/src/metric/client-plugins/node-exporter-installer/uninstall.sh b/src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/uninstall.sh similarity index 100% rename from src/metric/client-plugins/node-exporter-installer/uninstall.sh rename to src/metric/client-plugins/all-in-one/plugins/node-exporter-installer/uninstall.sh diff --git a/src/metric/client-plugins/demo-all-in-one/check_health.sh b/src/metric/client-plugins/all-in-one/scripts/check_health.sh similarity index 75% rename from src/metric/client-plugins/demo-all-in-one/check_health.sh rename to src/metric/client-plugins/all-in-one/scripts/check_health.sh index 527b2a0..a6ab23a 100755 --- a/src/metric/client-plugins/demo-all-in-one/check_health.sh +++ b/src/metric/client-plugins/all-in-one/scripts/check_health.sh @@ -37,21 +37,21 @@ log_error() { check_component() { local component_name="$1" local check_script_path="$2" - + log_info "检查 $component_name 健康状态..." - + if [[ ! -f "$check_script_path" ]]; then log_error "健康检查脚本不存在: $check_script_path" echo "{\"name\": \"$component_name\", \"status\": \"unhealth\", \"reason\": \"健康检查脚本不存在: $check_script_path\"}" return 1 fi - + if [[ ! -x "$check_script_path" ]]; then log_error "健康检查脚本无执行权限: $check_script_path" echo "{\"name\": \"$component_name\", \"status\": \"unhealth\", \"reason\": \"健康检查脚本无执行权限: $check_script_path\"}" return 1 fi - + # 执行健康检查脚本,只捕获 stdout,stderr 输出到终端 local result if result=$("$check_script_path" 2>/dev/null); then @@ -70,15 +70,68 @@ get_timestamp() { date '+%Y-%m-%d %H:%M:%S' } +# 生成UTC时间戳 +get_utc_timestamp() { + date -u '+%Y-%m-%dT%H:%M:%SZ' +} + +# 获取主机名 +get_hostname() { + hostname +} + +# 创建健康状态目录 +create_health_dir() { + local hostname=$(get_hostname) + local health_dir="/private/argus/agent/health/$hostname" + + if [[ ! -d "$health_dir" ]]; then + log_info "创建健康状态目录: $health_dir" + mkdir -p "$health_dir" + fi + + echo "$health_dir" +} + +# 写入单个模块的健康状态JSON文件 +write_component_health_json() { + local component_name="$1" + local status="$2" + local error_msg="$3" + local health_dir="$4" + + # 生成模块名前缀-xxx.json格式的文件名 + local module_prefix="metric" + local filename="${module_prefix}-${component_name}.json" + local filepath="$health_dir/$filename" + + # 生成UTC时间戳 + local timestamp=$(get_utc_timestamp) + + # 构建JSON内容 + local json_content=$(cat << EOF +{ + "status": "$status", + "error": "$error_msg", + "timestamp": "$timestamp" +} +EOF +) + + # 写入文件 + echo "$json_content" > "$filepath" + log_info "已写入模块健康状态文件: $filepath" +} + # 从安装记录文件中读取组件安装目录 read_install_record() { local install_record_file="$1" - + if [[ ! -f "$install_record_file" ]]; then log_error "安装记录文件不存在: $install_record_file" return 1 fi - + # 检查是否有 jq 命令来解析 JSON if command -v jq &> /dev/null; then # 使用 jq 解析 JSON @@ -93,7 +146,7 @@ read_install_record() { else # 如果没有 jq,尝试简单的文本解析 log_warning "jq 命令不可用,尝试简单文本解析" - + # 查找所有 install_dir 行 local components=() while IFS= read -r line; do @@ -104,7 +157,7 @@ read_install_record() { components+=("$component_name:$install_dir") fi done < "$install_record_file" - + if [[ ${#components[@]} -gt 0 ]]; then printf '%s\n' "${components[@]}" return 0 @@ -121,11 +174,15 @@ main() { echo " 整体健康检查脚本" >&2 echo "==========================================" >&2 echo >&2 - + # 记录健康检查开始时间 local start_time=$(get_timestamp) log_info "健康检查开始时间: $start_time" - + + # 创建健康状态目录 + local health_dir + health_dir=$(create_health_dir) + # 从安装记录文件中读取组件信息 log_info "从安装记录文件读取组件信息: $INSTALL_RECORD_FILE" local components_info @@ -133,31 +190,47 @@ main() { log_error "无法读取安装记录文件,健康检查终止" exit 1 fi - + # 存储所有检查结果 local all_results=() local overall_status="health" - + # 逐个检查组件 while IFS= read -r component_info; do if [[ -n "$component_info" ]]; then IFS=':' read -r component_name install_dir <<< "$component_info" local check_script_path="$install_dir/check_health.sh" - + local result + local component_status="healthy" + local error_msg="" + if result=$(check_component "$component_name" "$check_script_path"); then all_results+=("$result") else all_results+=("$result") overall_status="unhealth" + component_status="unhealthy" + # 从结果中提取错误信息 + if command -v jq &> /dev/null; then + error_msg=$(echo "$result" | jq -r '.reason // ""' 2>/dev/null || echo "") + else + # 简单的文本解析提取错误信息 + if [[ "$result" =~ \"reason\":[[:space:]]*\"([^\"]+)\" ]]; then + error_msg="${BASH_REMATCH[1]}" + fi + fi fi + + # 写入单个模块的健康状态JSON文件 + write_component_health_json "$component_name" "$component_status" "$error_msg" "$health_dir" fi done <<< "$components_info" - + # 记录健康检查结束时间 local end_time=$(get_timestamp) log_info "健康检查结束时间: $end_time" - + # 构建完整的健康检查结果 JSON local health_check_result=$(cat << EOF { @@ -170,14 +243,14 @@ $(printf '%s,\n' "${all_results[@]}" | sed '$s/,$//') } EOF ) - + # 写入健康日志文件 log_info "将健康检查结果写入日志文件: $HEALTH_LOG_FILE" echo "$health_check_result" >> "$HEALTH_LOG_FILE" - + # 输出 JSON 结果到 stdout echo "$health_check_result" - + # 显示总结到 stderr echo >&2 echo "==========================================" >&2 @@ -188,7 +261,7 @@ EOF echo "整体状态: $overall_status" >&2 echo "日志文件: $HEALTH_LOG_FILE" >&2 echo >&2 - + if [[ "$overall_status" == "health" ]]; then log_success "所有组件健康检查通过!" exit 0 @@ -201,4 +274,4 @@ EOF # 脚本入口 if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then main "$@" -fi +fi \ No newline at end of file diff --git a/src/metric/client-plugins/demo-all-in-one/install_artifact.sh b/src/metric/client-plugins/all-in-one/scripts/install_artifact.sh similarity index 97% rename from src/metric/client-plugins/demo-all-in-one/install_artifact.sh rename to src/metric/client-plugins/all-in-one/scripts/install_artifact.sh index 9198751..72a3c5b 100755 --- a/src/metric/client-plugins/demo-all-in-one/install_artifact.sh +++ b/src/metric/client-plugins/all-in-one/scripts/install_artifact.sh @@ -2,6 +2,23 @@ set -e +# 加载配置文件 +load_config() { + local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + local config_file="$script_dir/config.env" + + if [[ -f "$config_file" ]]; then + log_info "加载配置文件: $config_file" + # 导出配置文件中的环境变量 + set -a # 自动导出所有变量 + source "$config_file" + set +a # 关闭自动导出 + log_success "配置文件加载完成" + else + log_warning "配置文件不存在: $config_file,使用默认配置" + fi +} + RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' @@ -662,6 +679,10 @@ main() { echo " Argus-Metrics All-in-One 安装脚本 v1.0" echo "==========================================" echo + + # 加载配置文件 + load_config + log_info "安装目录: $INSTALL_DIR" echo diff --git a/src/metric/client-plugins/demo-all-in-one/package_artifact.sh b/src/metric/client-plugins/all-in-one/scripts/package_artifact.sh similarity index 92% rename from src/metric/client-plugins/demo-all-in-one/package_artifact.sh rename to src/metric/client-plugins/all-in-one/scripts/package_artifact.sh index 4cb7dc8..6783b8e 100755 --- a/src/metric/client-plugins/demo-all-in-one/package_artifact.sh +++ b/src/metric/client-plugins/all-in-one/scripts/package_artifact.sh @@ -54,19 +54,19 @@ fi # 获取当前目录和版本 CURRENT_DIR=$(pwd) -VERSION=$(cat VERSION 2>/dev/null || echo "1.0.0") +VERSION=$(cat config/VERSION 2>/dev/null || echo "1.0.0") ARTIFACT_DIR="artifact/$VERSION" log_info "开始打包 AIOps All-in-One 安装包 v$VERSION" # 检查必要文件 log_info "检查必要文件..." -if [[ ! -f "VERSION" ]]; then +if [[ ! -f "config/VERSION" ]]; then log_error "VERSION 文件不存在" exit 1 fi -if [[ ! -f "checklist" ]]; then +if [[ ! -f "config/checklist" ]]; then log_error "checklist 文件不存在" exit 1 fi @@ -179,7 +179,7 @@ while IFS= read -r line; do component_count=$((component_count + 1)) log_info " - $component v$version" -done < checklist +done < config/checklist if [[ $component_count -eq 0 ]]; then log_error "没有找到有效的组件" @@ -368,32 +368,41 @@ log_success "版本信息文件生成完成: $version_json" # 复制`安装`脚本到 artifact 目录 log_info "复制安装脚本..." -if [[ -f "install_artifact.sh" ]]; then - cp "install_artifact.sh" "$ARTIFACT_DIR/install.sh" +if [[ -f "scripts/install_artifact.sh" ]]; then + cp "scripts/install_artifact.sh" "$ARTIFACT_DIR/install.sh" chmod +x "$ARTIFACT_DIR/install.sh" log_success "安装脚本复制完成: $ARTIFACT_DIR/install.sh" else - log_warning "install_artifact.sh 文件不存在" + log_warning "scripts/install_artifact.sh 文件不存在" fi # 复制`卸载`脚本到 artifact 目录 log_info "复制卸载脚本..." -if [[ -f "uninstall_artifact.sh" ]]; then - cp "uninstall_artifact.sh" "$ARTIFACT_DIR/uninstall.sh" +if [[ -f "scripts/uninstall_artifact.sh" ]]; then + cp "scripts/uninstall_artifact.sh" "$ARTIFACT_DIR/uninstall.sh" chmod +x "$ARTIFACT_DIR/uninstall.sh" log_success "卸载脚本复制完成: $ARTIFACT_DIR/uninstall.sh" else - log_warning "uninstall_artifact.sh 文件不存在" + log_warning "scripts/uninstall_artifact.sh 文件不存在" fi # 复制`健康检查`脚本到 artifact 目录 log_info "复制健康检查脚本..." -if [[ -f "check_health.sh" ]]; then - cp "check_health.sh" "$ARTIFACT_DIR/check_health.sh" +if [[ -f "scripts/check_health.sh" ]]; then + cp "scripts/check_health.sh" "$ARTIFACT_DIR/check_health.sh" chmod +x "$ARTIFACT_DIR/check_health.sh" log_success "健康检查脚本复制完成: $ARTIFACT_DIR/check_health.sh" else - log_warning "check_health.sh 文件不存在" + log_warning "scripts/check_health.sh 文件不存在" +fi + +# 复制配置文件到 artifact 目录 +log_info "复制配置文件..." +if [[ -f "config/config.env" ]]; then + cp "config/config.env" "$ARTIFACT_DIR/" + log_success "配置文件复制完成: $ARTIFACT_DIR/config.env" +else + log_warning "config 目录不存在,跳过配置文件复制" fi # 复制 deps 目录到 artifact 目录 diff --git a/src/metric/client-plugins/demo-all-in-one/publish_artifact.sh b/src/metric/client-plugins/all-in-one/scripts/publish_artifact.sh similarity index 88% rename from src/metric/client-plugins/demo-all-in-one/publish_artifact.sh rename to src/metric/client-plugins/all-in-one/scripts/publish_artifact.sh index d346622..2a4e709 100755 --- a/src/metric/client-plugins/demo-all-in-one/publish_artifact.sh +++ b/src/metric/client-plugins/all-in-one/scripts/publish_artifact.sh @@ -43,7 +43,7 @@ fi VERSION="$1" ARTIFACT_DIR="artifact/$VERSION" -PUBLISH_DIR="/srv/ftp/share" +PUBLISH_DIR="/Users/sundapeng/Project/nlp/aiops/client-plugins/all-in-one/publish/" # 检查版本目录是否存在 if [[ ! -d "$ARTIFACT_DIR" ]]; then @@ -86,22 +86,22 @@ fi if [[ -f "$ARTIFACT_DIR/check_health.sh" ]]; then log_info "复制健康检查脚本..." cp "$ARTIFACT_DIR/check_health.sh" "$TEMP_PACKAGE_DIR/" -elif [[ -f "check_health.sh" ]]; then +elif [[ -f "scripts/check_health.sh" ]]; then log_info "复制健康检查脚本 (从当前目录)..." - cp "check_health.sh" "$TEMP_PACKAGE_DIR/" + cp "scripts/check_health.sh" "$TEMP_PACKAGE_DIR/" else log_warning "未找到 check_health.sh 文件" fi # 复制安装脚本并重命名为 install.sh -if [[ -f "install_artifact.sh" ]]; then +if [[ -f "scripts/install_artifact.sh" ]]; then log_info "复制安装脚本..." - cp "install_artifact.sh" "$TEMP_PACKAGE_DIR/install.sh" + cp "scripts/install_artifact.sh" "$TEMP_PACKAGE_DIR/install.sh" fi -if [[ -f "uninstall_artifact.sh" ]]; then +if [[ -f "scripts/uninstall_artifact.sh" ]]; then log_info "复制卸载脚本..." - cp "uninstall_artifact.sh" "$TEMP_PACKAGE_DIR/uninstall.sh" + cp "scripts/uninstall_artifact.sh" "$TEMP_PACKAGE_DIR/uninstall.sh" fi # 复制 deps 目录 @@ -126,9 +126,9 @@ log_info "更新 LATEST_VERSION 文件..." echo "$VERSION" > "$PUBLISH_DIR/LATEST_VERSION" # 复制 setup.sh 到发布目录 -if [[ -f "setup.sh" ]]; then +if [[ -f "scripts/setup.sh" ]]; then log_info "复制 setup.sh 到发布目录..." - cp "setup.sh" "$PUBLISH_DIR/" + cp "scripts/setup.sh" "$PUBLISH_DIR/" fi # 显示发布结果 diff --git a/src/metric/client-plugins/demo-all-in-one/setup.sh b/src/metric/client-plugins/all-in-one/scripts/setup.sh old mode 100644 new mode 100755 similarity index 98% rename from src/metric/client-plugins/demo-all-in-one/setup.sh rename to src/metric/client-plugins/all-in-one/scripts/setup.sh index e0c7ef5..961d81f --- a/src/metric/client-plugins/demo-all-in-one/setup.sh +++ b/src/metric/client-plugins/all-in-one/scripts/setup.sh @@ -2,6 +2,12 @@ set -e +# 加载配置文件(仅在解压后的目录中可用) +load_config() { + # setup.sh 脚本不需要配置文件,FTP参数通过命令行参数或环境变量提供 + log_info "setup.sh 脚本使用命令行参数或环境变量获取FTP配置" +} + # 颜色定义 RED='\033[0;31m' GREEN='\033[0;32m' @@ -820,6 +826,9 @@ main() { echo "==========================================" echo + # 加载配置文件 + load_config + # 对于状态和备份列表操作,不需要FTP参数和root权限 if [[ "$ACTION" == "status" || "$ACTION" == "backup-list" ]]; then if [[ "$ACTION" == "status" ]]; then diff --git a/src/metric/client-plugins/demo-all-in-one/uninstall_artifact.sh b/src/metric/client-plugins/all-in-one/scripts/uninstall_artifact.sh old mode 100644 new mode 100755 similarity index 95% rename from src/metric/client-plugins/demo-all-in-one/uninstall_artifact.sh rename to src/metric/client-plugins/all-in-one/scripts/uninstall_artifact.sh index fce9087..ca137a7 --- a/src/metric/client-plugins/demo-all-in-one/uninstall_artifact.sh +++ b/src/metric/client-plugins/all-in-one/scripts/uninstall_artifact.sh @@ -27,8 +27,8 @@ log_error() { } # 配置变量 -INSTALL_DIR="/opt/aiops" -TEMP_DIR="/tmp/aiops-uninstall-$$" +INSTALL_DIR="/opt/argus-metric" +TEMP_DIR="/tmp/argus-metric-uninstall-$$" VERSION_FILE="version.json" # 检查是否为 root 用户 @@ -200,8 +200,8 @@ cleanup_global_files() { # 清理可能的全局配置文件 local global_configs=( - "/etc/aiops" - "/var/log/aiops" + "/etc/argus-metric" + "/var/log/argus-metric" ) for config in "${global_configs[@]}"; do @@ -214,7 +214,7 @@ cleanup_global_files() { # 显示卸载信息 show_uninstall_info() { - log_success "AIOps All-in-One 卸载完成!" + log_success "Argus-Metrics All-in-One 卸载完成!" echo echo "卸载信息:" echo " 版本: $VERSION" @@ -246,7 +246,7 @@ trap cleanup EXIT # 主函数 main() { echo "==========================================" - echo " AIOps All-in-One 卸载脚本" + echo " Argus-Metrics All-in-One 卸载脚本" echo "==========================================" echo @@ -255,7 +255,7 @@ main() { create_temp_dirs parse_version_info - log_warning "此操作将完全卸载 AIOps All-in-One" + log_warning "此操作将完全卸载 Argus-Metrics All-in-One" read -p "确认继续?(y/N): " confirm if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then diff --git a/src/metric/client-plugins/demo-all-in-one/version-manager.sh b/src/metric/client-plugins/all-in-one/scripts/version-manager.sh similarity index 88% rename from src/metric/client-plugins/demo-all-in-one/version-manager.sh rename to src/metric/client-plugins/all-in-one/scripts/version-manager.sh index 28b3497..65e566c 100755 --- a/src/metric/client-plugins/demo-all-in-one/version-manager.sh +++ b/src/metric/client-plugins/all-in-one/scripts/version-manager.sh @@ -49,8 +49,8 @@ show_help() { # 获取当前版本 get_current_version() { - if [[ -f "VERSION" ]]; then - cat VERSION + if [[ -f "config/VERSION" ]]; then + cat config/VERSION else echo "0.0.0" fi @@ -67,7 +67,7 @@ set_version() { exit 1 fi - echo "$new_version" > VERSION + echo "$new_version" > config/VERSION log_success "版本号已设置为: $new_version" } @@ -109,7 +109,7 @@ show_version() { local current_version=$(get_current_version) log_info "当前版本: $current_version" - if [[ -f "checklist" ]]; then + if [[ -f "config/checklist" ]]; then echo echo "组件清单:" while IFS= read -r line; do @@ -118,7 +118,7 @@ show_version() { if [[ -n "$component" && -n "$version" ]]; then echo " - $component v$version" fi - done < checklist + done < config/checklist fi # 检查是否有对应的 artifact @@ -227,7 +227,7 @@ validate_version() { local errors=0 # 检查 VERSION 文件 - if [[ ! -f "VERSION" ]]; then + if [[ ! -f "config/VERSION" ]]; then log_error "VERSION 文件不存在" errors=$((errors + 1)) else @@ -241,7 +241,7 @@ validate_version() { fi # 检查 checklist 文件 - if [[ ! -f "checklist" ]]; then + if [[ ! -f "config/checklist" ]]; then log_error "checklist 文件不存在" errors=$((errors + 1)) else @@ -253,12 +253,12 @@ validate_version() { component_count=$((component_count + 1)) # 检查组件目录是否存在 - if [[ ! -d "components/$component" ]]; then - log_error "组件目录不存在: components/$component" + if [[ ! -d "plugins/$component" ]]; then + log_error "组件目录不存在: plugins/$component" errors=$((errors + 1)) fi fi - done < checklist + done < config/checklist if [[ $component_count -gt 0 ]]; then log_success "checklist 包含 $component_count 个组件" @@ -269,26 +269,26 @@ validate_version() { fi # 检查 package.sh 文件 - if [[ ! -f "package.sh" ]]; then - log_error "package.sh 文件不存在" + if [[ ! -f "scripts/package_artifact.sh" ]]; then + log_error "package_artifact.sh 文件不存在" errors=$((errors + 1)) else - if [[ -x "package.sh" ]]; then - log_success "package.sh 可执行" + if [[ -x "scripts/package_artifact.sh" ]]; then + log_success "package_artifact.sh 可执行" else - log_warning "package.sh 不可执行,请运行: chmod +x package.sh" + log_warning "package_artifact.sh 不可执行,请运行: chmod +x scripts/package_artifact.sh" fi fi # 检查 install.sh 文件 - if [[ ! -f "install.sh" ]]; then - log_error "install.sh 文件不存在" + if [[ ! -f "scripts/install_artifact.sh" ]]; then + log_error "install_artifact.sh 文件不存在" errors=$((errors + 1)) else - if [[ -x "install.sh" ]]; then - log_success "install.sh 可执行" + if [[ -x "scripts/install_artifact.sh" ]]; then + log_success "install_artifact.sh 可执行" else - log_warning "install.sh 不可执行,请运行: chmod +x install.sh" + log_warning "install_artifact.sh 不可执行,请运行: chmod +x scripts/install_artifact.sh" fi fi diff --git a/src/metric/ftp/README.md b/src/metric/ftp/README.md index f0cf696..f3881e1 100644 --- a/src/metric/ftp/README.md +++ b/src/metric/ftp/README.md @@ -151,19 +151,9 @@ EOF # 本地测试连接 ftp localhost -# 远程测试连接 -ftp 服务器IP +curl -fsS 'ftp://ftpuser:ZGClab1234!@177.177.70.200/setup.sh' -o setup.sh -# 使用命令行工具测试(直接访问share目录) -curl ftp://ftpuser:ZGClab1234!@服务器IP/ - -# 测试被动模式 -lftp ftp://ftpuser:ZGClab1234!@服务器IP/ - -# 访问特定文件 -curl ftp://ftpuser:ZGClab1234!@服务器IP/文件名 - -curl -fsS 'ftp://ftpuser:ZGClab1234!@172.17.0.2/1' - -curl -fsS 'ftp://ftpuser:ZGClab1234!@172.17.0.2/1.txt' -o 1.txt +# root用户直接执行,非root用户需要使用sudo +chmod +x setup.sh +bash setup.sh --server {$域名} --user ftpuser --password 'ZGClab1234!' ``` \ No newline at end of file