openclaw/EXTENSIONS.md
Claude Code 9c3fb9f66a feat: add advanced extensions and tools (v2.1)
This commit adds comprehensive extensions and tools for advanced
system management and optimization.

New Tools Added:
- setup-ssl.bat: SSL/TLS configuration wizard
  - Self-signed certificate generation
  - Let's Encrypt support
  - Nginx reverse proxy setup
  - Gateway WSS and Grafana HTTPS

- Log Analyzer Service (port 9102)
  - Real-time log aggregation
  - Pattern-based analysis
  - Health status API
  - Event tracking

- Performance Tuner Script
  - System parameter optimization
  - PostgreSQL tuning
  - Docker optimization
  - Automatic log cleanup
  - Performance monitoring daemon

- Health Check Reporter
  - Daily health reports
  - Email notifications (optional)
  - JSON and text report formats
  - Cluster-wide metrics

- Cluster Scaling Tool
  - Interactive management interface
  - Add/remove devices
  - Load balancing config
  - Failover setup
  - Resource scaling

Documentation:
- EXTENSIONS.md: Complete tool documentation

Service Endpoints:
- Log Analyzer: http://server:9102/api/logs/*
- Metrics: http://server:9101/metrics
- Database API: http://server:18800/api/*

System Improvements:
- Enhanced monitoring capabilities
- Automated performance tracking
- Comprehensive logging
- Easy cluster management

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-29 19:38:51 +08:00

5.4 KiB
Raw Blame History

🔧 Moltbot 扩展功能工具集

版本: v2.1 最后更新: 2026-01-29


📦 新增工具概览

本文档描述了在 v2.0 基础上新增的扩展工具和功能。


1. SSL/TLS 配置向导

文件: setup-ssl.bat

功能

自动配置 HTTPS/WSS 加密通信

支持模式

  • 自签名证书(快速测试)
  • Let's Encrypt免费需要域名
  • 使用现有证书

使用方法

setup-ssl.bat

配置内容

  • Nginx 反向代理
  • SSL 证书自动安装
  • Gateway WSS 支持
  • Grafana HTTPS 支持

2. 日志聚合分析器

文件: /opt/moltbot-monitoring/log-analyzer.py (服务器)

功能

实时日志聚合、分析和告警

API 端点

GET /api/logs/summary    - 日志摘要
GET /api/logs/events     - 最近事件
GET /api/logs/health     - 健康状态
GET /api/logs/service?service=<name>  - 特定服务日志

监控的日志

  • Gateway 日志
  • 数据库 API 日志
  • 备份日志
  • 同步日志
  • 健康检查日志
  • 系统认证日志

使用示例

# 获取日志摘要
curl http://38.14.254.51:9102/api/logs/summary

# 获取健康状态
curl http://38.14.254.51:9102/api/logs/health

3. 性能优化脚本

文件: /usr/local/bin/moltbot-optimize.sh (服务器)

优化项目

  1. 系统参数优化

    • 网络连接数
    • 文件描述符限制
    • 共享内存配置
    • 虚拟内存参数
  2. PostgreSQL 优化

    • 内存分配
    • 连接池配置
    • WAL 设置
    • 查询优化
  3. Docker 优化

    • 日志大小限制
    • 存储驱动配置
    • 并发下载限制
  4. 日志清理

    • 自动压缩旧日志
    • 删除过期日志
    • Journal 日志清理
  5. 磁盘 I/O 优化

    • I/O 调度器设置
    • Swap 配置

使用方法

# SSH 到服务器
ssh root@38.14.254.51

# 运行优化
/usr/local/bin/moltbot-optimize.sh

4. 健康检查报告

文件: /usr/local/bin/moltbot-health-report.py (服务器)

功能

生成每日健康报告并可选发送邮件

报告内容

  • 系统指标CPU、内存、磁盘、负载
  • 服务状态
  • 数据库统计
  • 最近问题列表

使用方法

# 生成报告
/usr/local/bin/moltbot-health-report.py

# 查看报告
cat /opt/moltbot-monitoring/reports/report_*.txt

配置自动发送

编辑 /opt/moltbot-monitoring/alert-config.json:

{
  "email": {
    "enabled": true,
    "smtp_host": "smtp.gmail.com",
    "smtp_port": 587,
    "smtp_user": "your-email@gmail.com",
    "smtp_password": "your-app-password",
    "to_email": "admin@example.com"
  }
}

配置定时任务

# 每天早上 8 点生成报告
0 8 * * * root /usr/local/bin/moltbot-health-report.py

5. 集群扩容工具

文件: cluster-scaler.bat

功能

交互式集群管理界面

支持操作

  1. 查看集群状态
  2. 添加新设备
  3. 移除设备
  4. 配置负载均衡
  5. 启用故障转移
  6. 生成集群报告
  7. 扩容(增加资源)
  8. 缩容(减少资源)

使用方法

cluster-scaler.bat

菜单导航

[1] View current cluster status    - 查看集群状态
[2] Add new device to cluster      - 添加设备
[3] Remove device from cluster     - 移除设备
[4] Configure load balancing      - 负载均衡配置
[5] Enable failover mode           - 故障转移配置
[6] Generate cluster report        - 生成集群报告
[7] Scale up (add resources)       - 扩容
[8] Scale down (remove resources)  - 缩容

📊 服务端口汇总

服务 端口 说明
Gateway 18789 WebSocket 网关
Database API 18800 REST API
Prometheus 9090 指标采集
Grafana 3000 可视化
Log Analyzer 9102 日志分析
Metrics Exporter 9101 指标导出

🚀 快速开始

1. 配置 SSL 加密

setup-ssl.bat

2. 运行性能优化

ssh root@38.14.254.51 "/usr/local/bin/moltbot-optimize.sh"

3. 添加新设备到集群

cluster-scaler.bat
# 选择 [2] Add new device

4. 生成健康报告

ssh root@38.14.254.51 "/usr/local/bin/moltbot-health-report.py"

📝 维护任务

每日

  • 检查健康报告
  • 监控日志分析器告警
  • 验证备份完成

每周

  • 审查系统性能
  • 检查磁盘使用
  • 清理旧日志

每月

  • 审查安全更新
  • 测试备份恢复
  • 性能调优评估

🔗 相关文档

  • DEPLOYMENT-COMPLETE.md - 完整部署指南
  • ROADMAP.md - 功能路线图
  • admin-panel.html - Web 管理面板

⚠️ 注意事项

  1. SSL 证书

    • 自签名证书会显示浏览器警告
    • Let's Encrypt 需要域名和 80 端口
  2. 性能优化

    • PostgreSQL 重启会短暂中断服务
    • 建议在维护窗口执行
  3. 集群扩容

    • 添加设备需要物理访问或远程访问
    • 确保网络连接稳定
  4. 日志分析

    • 日志文件可能很大
    • 定期清理旧日志

🆘 故障排除

SSL 配置失败

# 检查 Nginx 配置
nginx -t

# 查看 Nginx 日志
journalctl -u nginx -n 50

日志分析器无法启动

# 检查服务状态
systemctl status moltbot-log-analyzer

# 查看日志
journalctl -u moltbot-log-analyzer -n 50

性能优化后问题

# 恢复默认配置
sysctl --system

# 重启 PostgreSQL
systemctl restart postgresql

🎉 扩展功能已就绪,按需使用!