← 返回
未分类 Key

Server Monitor Collector

Collect server monitoring data (Zabbix / Prometheus / Alibaba / Tencent / Huawei Cloud), generate CSV/XLSX reports and send via email or Feishu.
采集服务器监控数据(Zabbix / Prometheus /阿里云 / 腾讯云 / 华为云),生成 CSV/XLSX 报表并通过邮件或飞书发送。
freepengyang
未分类 clawhub v1.0.2 1 版本 100000 Key: 需要
★ 0
Stars
📥 409
下载
💾 2
安装
1
版本
#alibaba#devops#huawei#latest#monitoring#server#tencent#zabbix

概述

Server Monitor Collector

Collect server or cloud VM monitoring data, generate formatted Excel reports, and optionally send summaries via email or Feishu/Lark.

Supported Data Sources

SourceAuthNotes
---------------------
ZabbixUser/Pass or API TokenHost groups, memory, CPU, disk
PrometheusURL onlyPromQL queries
Alibaba Cloud CMSAccessKey/SecretKeyECS, RDS, SLB, EIP metrics
Tencent Cloud CAMSecretID/KeyTC3-HMAC-SHA256 signature
Huawei Cloud IAMAccessKey/SecretKeyIAM Token auth

Data sources are auto-detected from .env — configure credentials for any combination and they will all be collected.

Setup

1. Configure Environment

Create/edit ~/.hermes/.env. Only configure the sources you need:

# --- Zabbix (pick one auth method) ---
ZABBIX_URL=https://zabbix.example.com/api_jsonrpc.php
ZABBIX_USER=Admin
ZABBIX_PASSWORD=your_password
# ZABBIX_TOKEN=your_api_token  # optional, takes priority over password

# --- Alibaba Cloud ---
ALIBABA_ACCESS_KEY_ID=your_key_id
ALIBABA_ACCESS_KEY_SECRET=your_secret
ALIBABA_REGION=cn-hangzhou
# ALIBABA_METRICS=CPUUtilization,MemoryUtilization,InternetInRate  # optional

# --- Tencent Cloud ---
TENCENT_SECRET_ID=your_secret_id
TENCENT_SECRET_KEY=your_secret_key
TENCENT_REGION=ap-shanghai

# --- Huawei Cloud ---
HUAWEI_ACCESS_KEY=your_access_key
HUAWEI_SECRET_KEY=your_secret_key
HUAWEI_REGION=cn-east-3

# --- Notifications ---
FEISHU_CHAT_ID=oc_xxxx         # optional
SMTP_HOST=smtp.example.com      # optional, omit to skip email
SMTP_PORT=465
SMTP_FROM=alarm@example.com
SMTP_TOKEN=your_token
TARGET_EMAIL=admin@example.com

# --- Report options ---
# TOPN: show top N hosts by memory+CPU score, 0=off (default: 50)
TOPN=50

2. Install Dependencies

Zabbix / Prometheus — no extra deps:

python3 zabbix_cron.py

Alibaba Cloud — needs SDK (use uv since venv has no pip):

uv run --with aliyun-python-sdk-core --with aliyun-python-sdk-cms \
  python3 cloud_monitor.py

Tencent / Huawei — pure Python, only httpx needed:

uv run --with httpx python3 cloud_monitor.py

3. Run Once (Manual Test)

python3 zabbix_cron.py

Expected output:

  • ~/.hermes/cron/output/zabbix_monitor.csv
  • ~/.hermes/cron/output/zabbix_monitor.xlsx (one sheet per host group + overview + TOP sheet)

4. Schedule Daily Report

hermes cron create \
  --name "Daily Server Health Report" \
  --script zabbix_cron.py \
  --schedule "30 9 * * *"

Output Format

CSV

  • UTF-8-BOM encoding — opens correctly in Windows Excel without garbled characters
  • Columns: 主机组, 主机名, IP, 内存可用(GB), 内存总量(GB), 内存占用率(%), CPU占用率(%)

XLSX

  • 总览 sheet: summary table with host group stats and alarm counts
  • Group sheets: one per host group, sorted by memory usage descending
  • TOP50(内存+CPU) sheet: top 50 hosts across all groups by combined memory+CPU score
  • Cell coloring: 🔴 ≥80% red, 🟠 ≥60% orange, 🟡 ≥40% yellow

Auto-Detection Logic

Scripts detect which sources to use based on which env vars are set:

Env var presentData source used
---------------------------------
ZABBIX_URLZabbix API
ALIBABA_ACCESS_KEY_IDAlibaba Cloud CMS (SDK)
TENCENT_SECRET_IDTencent Cloud CAM (TC3签名)
HUAWEI_ACCESS_KEYHuawei Cloud IAM (Token)
PROMETHEUS_URLPrometheus PromQL

Zabbix Host Group Exclusion

These groups are excluded by default (set in EXCLUDE_GROUPS in script):

  • Templates* — template groups
  • Discovered hosts — Zabbix auto-discovery

Key Zabbix Item Keys

KeyDescription
------------------
vm.memory.size[available]Memory available (bytes)
vm.memory.size[total]Memory total (bytes)
system.cpu.utilCPU utilization (%)
vfs.fs.size[/,pused]Root disk usage (%)

Alarm Thresholds

MetricWarningAlarm
------------------------
Memory usage≥40% yellow≥60% orange, ≥80% red
CPU usage≥40% yellow≥60% orange, ≥80% red

Feishu Message Format

Markdown card sent to FEISHU_CHAT_ID containing:

  • Report timestamp, total hosts, group count
  • Top 20 hosts with memory ≥60% or CPU ≥60%
  • Color-coded: 🔴≥80%, 🟠≥60%, 🟡≥40%

Email Format

  • Subject: 服务器监控报告 YYYY-MM-DD HH:MM
  • Body: HTML summary matching the Feishu card
  • Attachment: zabbix_monitor.xlsx

References

  • references/zabbix-config.md — Zabbix API details, item keys, auth options
  • references/notification-config.md — Feishu and email SMTP setup, common providers
  • references/cloud-config.md — Alibaba / Tencent / Huawei API endpoints, namespaces, SDK usage

Guardrails

  • Never hardcode credentials — always use ~/.hermes/.env
  • Never print full credentials in logs or chat
  • Never place scripts in web-accessible directories
  • If Zabbix host has no Agent — memory metrics show N/A, CPU still works
  • Alibaba Cloud MemoryUtilization requires Cloud Monitor Agent installed on ECS instance

版本历史

共 1 个版本

  • v1.0.2 当前
    2026-05-07 10:09 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Ops Code Review

freepengyang
Code Review 安全扫描工具,自动化代码审计,支持 Django/Python、React+TypeScript、PHP 多语言。 自动识别代码仓库提交变更,调用安全扫描器进行规范检查和风险检测,报告推送飞书群。 支持 post-c
★ 0 📥 497

Clawhub Gate

freepengyang
ClawHub 预发布安全门禁:本地静态分析 + ClawScan 循环检查,确保 Skill 通过 VirusTotal 与 ClawScan 检查后才发布。 关键词:clawhub publish pre-publish securit
★ 0 📥 389

Pg Game Monitor

freepengyang
Prometheus + Grafana 监控方案,专为**单台物理机部署多个 Java 游戏进程 + 自建 MySQL**的场景设计。Java 进程通过 jstat/jcmd 无侵入采集 JVM 运行时指标(堆内存、新生代、老年代、GC、
★ 0 📥 395