zoukankan      html  css  js  c++  java
  • 服务器监控

    docker 监控(服务端)

    cAdvisor(Container Advisor)用于收集正在运行的容器资源使用和性能信息。
    Grafana 是一个开源的度量分析和可视化系统

    docker run -d 
    --volume=/:/rootfs:ro 
    --volume=/var/run:/var/run:ro 
    --volume=/sys:/sys:ro 
    --volume=/var/lib/docker/:/var/lib/docker:ro 
    --volume=/dev/disk/:/dev/disk:ro 
    --publish=8080:8080 
    --detach=true 
    --name=cadvisor 
    google/cadvisor:latest
    View Code

    主机监控

    安装node_exporter

    node_exporter.sh

    #!/bin/bash
    
    wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
    
    tar zxf node_exporter-0.17.0.linux-amd64.tar.gz
    mv node_exporter-0.17.0.linux-amd64 /usr/local/node_exporter
    
    cat <<EOF >/usr/lib/systemd/system/node_exporter.service
    [Unit]
    Description=https://prometheus.io
    
    [Service]
    Restart=on-failure
    ExecStart=/usr/local/node_exporter/node_exporter
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    systemctl daemon-reload
    systemctl enable node_exporter
    systemctl restart node_exporter
    View Code

    数据存储

    Docker部署: https://prometheus.io/docs/prometheus/latest/installation/
    配置

    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: "docker"
        static_configs:
        - targets: ['192.168.31.62:8080']
    
      - job_name: "Linux"
        static_configs:
        - targets: ['192.168.31.62:9100']
    View Code
    docker run -d 
    --name=prometheus 
    -p 9090:9090 
    -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml 
    prom/prometheus
    View Code

    数据展示

    https://github.com/google/cadvisor
    https://grafana.com/grafana/download
    Docker主机监控模板: 193
    Linux主机监控模板: 9276
    账号密码默认admin

    docker run -d 
    --name=grafana 
    -p 3000:3000 
    grafana/grafana
    View Code

     

  • 相关阅读:
    张小龙:微信十周年总结
    天呐!!!竟还有人不知道如何将Python程序打包成exe
    Making Games with Python & Pygame 中文翻译
    turtle怎么引入背景图片
    Python少儿编程全集(一):一只小海龟(turtle库的使用)
    C/C++基础编程
    少儿编程论坛,汇集所有少儿编程资源!!!
    少儿编程:认识python中的turtle库(一)
    博客导航栏,衣渐衫衣终不悔,沉淀技术这十年(持续更新...)
    SpringBoot学习笔记【尚硅谷】
  • 原文地址:https://www.cnblogs.com/huay/p/13760477.html
Copyright © 2011-2022 走看看