冯钰 · 2020年09月27日

云芯一号试用---实现对云芯一号主机的监控

监控效果图如下。
21.PNG
22.PNG
23.PNG
24.PNG
1、前言
      监控不仅能提供实时状态展现,更能帮助故障回溯和预测风险。
      本文通过node\_exporter+prometheus+grafana开源组件,来实现对物理主机的监控。监控的指标包括:服务器CPU、内存、磁盘、I/O等信息。
2、准备工作
      a) 为了方便远程操作,需要开启root用户远程登录。参见:
          云芯一号测评1:开箱及开机自动切换高性能模式
      b) 下载node\_exporter
          下载地址为:https://github.com/prometheus/node\_exporter/releases
          选择arm64版本,如图1所示。
3.PNG
图 1
      c) 下载prometheus
          下载地址为:https://github.com/prometheus/prometheus/releases
          选择arm64版本,如图2所示。
4.PNG
图 2
      d) 下载grafana
          下载地址为:https://grafana.com/grafana/download?edition=oss&platform=arm
          选择arm64版本,如图3所示。
5.PNG
图 3
3、开始搭建
      将上述三个压缩包全部传入云芯一号系统的/root/文件夹下,并解压。
      a) 运行node\_exporter

cd ~/node_exporter-1.0.1.linux-arm64
./node_exporter

      浏览器访问http://192.168.68.160:9100/metrics     192.168.68.160为云芯一号系统的IP。
      可以看到node\_exporter收集的指标监控信息。如图4所示。
6.PNG
图 4
      b) 修改prometheus配置文件并运行
           进入prometheus-2.21.0.linux-arm64文件夹,然后修改prometheus.yml
           文件内容如下。

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'node'
    static_configs:
    - targets: ['localhost:9100']

      运行prometheus

./prometheus

      浏览器访问http://192.168.68.160:9090/targets
      可以看到prometheus的运行情况。如图5所示。
7.PNG
图 5
      c) 运行grafana

cd ~/grafana-7.2.0/bin/
./grafana-server

      浏览器访问http://192.168.68.160:3000
      用户名密码都为admin,登录后点击skip,进入grafana dashboard。
      配置数据源。如图6所示。
8.PNG
图 6
      点击Save & Test,进行数据保存。如图7所示。
9.PNG
图 7
      导入dashboard。输入dashboard id:8919。如图8所示。
10.png
图 8
      点击Load后,name:云芯一号监控,Prometheus选择之前配置的数据源。配置信息如图9所示。
11.PNG
图 9
好了,本次教程介绍完毕。

推荐阅读
关注数
4271
内容数
71
低成本Arm微服务器开发平台“云芯1号”教程及应用,欢迎关注
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息