使用 Grafana 监控 Linux 系统资源(Ubuntu/Debian)

本教程将指导你如何通过 apt 安装 Grafana,并集成 Zabbix 数据源,实现系统资源监控与界面汉化。

安装 Grafana

  1. 安装基本依赖

    sudo apt-get install -y apt-transport-https software-properties-common wget
    
  2. 添加 Grafana GPG 密钥

    sudo mkdir -p /etc/apt/keyrings/
    wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null
    
  3. 添加 Grafana 仓库

    echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
    sudo apt-get update
    
  4. 安装 Grafana

    sudo apt install -y grafana
    
  5. 启动并设置 Grafana 自动运行

    sudo systemctl enable grafana-server
    sudo systemctl start grafana-server
    

3. 配置 Grafana 使用 Zabbix 数据源

  1. 安装 Zabbix 插件

    sudo grafana-cli plugins install alexanderzobnin-zabbix-app
    sudo systemctl restart grafana-server
    
  2. 配置 Zabbix 数据源

    • 打开浏览器访问 Grafana:http://<你的服务器IP>:3000

    • 使用默认账号登录(用户名:admin,密码:admin

    • 步骤:

      • 进入 Configuration > Plugins,启用 Zabbix 插件

      • 前往 Configuration > Data Sources,添加新数据源

        • 类型:Zabbix
        • URL:http://<你的服务器IP>/api_jsonrpc.php
        • 登录:用户名 Admin,密码 zabbix
        • 数据库(如果需要):选择 zabbix(MySQL)
    • 完成后点击 “Save & Test” 测试连接是否成功

  1. 导入 Zabbix 仪表板

    • 导航至 + > Import
    • 输入仪表板 ID:9965
    • 选择 Zabbix 数据源并导入

4. Grafana 汉化设置

Zabbix Web 界面默认支持中文,可在 “User Settings > Language” 选择 “Chinese (zh_CN)”。

5. 验证监控

  • Zabbix:在 http://<服务器IP>/zabbix 检查 “Monitoring > Hosts” 是否显示数据。
  • Grafana:在仪表板(ID 9965)查看 CPU、内存、磁盘等图表。
梦葉樱 all right reserved,powered by Gitbook该文件最后修改时间: 2025-08-09 00:00:03

results matching ""

    No results matching ""