您的位置:首页 > 运维架构 > Linux

Linux与windows资源监控(prometheus+grafana)

2019-03-21 15:16 851 查看

(一) 下载安装监控软件

  1. 下载node_exporter。(linux)
    wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
    tar zxfv node_exporter-0.17.0.linux-amd64.tar.gz
    后台启动:以9101端口做监听端口
    启动命令:
    nohup ./node_exporter --web.listen-address=":9101" &
    ps -ef | grep node_
    查看进程
    netstat -tunlp | grep node
    查看端口
    netstat -tunlp | grep 9101

  2. 下载wmi_exporter.(windows)
    软件位置
    https://github.com/martinlindhe/wmi_exporter/releases

直接安装
以9182 端口做监听端口
(二) prometheus.xml修改(linux+windows)

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).

alerting:
alertmanagers:

  • static_configs: targets:

    - alertmanager:9093

rule_files:

- “first_rules.yml”

- “second_rules.yml”

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’]
    labels:
    instance: prometheus
    #节点监控
    #windows
  • job_name: ‘name1’
    static_configs:
      targets: [‘ip:9182’]
      labels:
      instance: name1

    #linux

    • job_name: name2’
      static_configs: targets: [‘ip:9101’]
      labels:
      instance: ip
      name: name
      env: linux

    重新启动prometheus;

    (三) 打开端口

    1. Linux
      sudo iptables -I INPUT -s 192.16.4.227 -p tcp --dport 9101 -j ACCEPT

    2. windows

    windows防火墙-高级-入站规则-新建规则-端口(选择tcp连接),
    教程
    https://zhidao.baidu.com/question/921418892992256059.html

    (四) grafana导入dashboard;

    windows的dashboard模板;
    下载位置: https://grafana.com/dashboards/8781

    D:\grafana_dashboard\windows-node_rev1.json

    Linux的dashboard模板;
    下载位置: https://grafana.com/dashboards/8919/revisions
    D:\grafana_dashboard\1-node-exporter-0-16-0-17-for-prometheus_rev7.json

    展示界面如下;
    linux

    windows;

  • 内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
    标签: