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

(一) 下载安装监控软件

  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;
在这里插入图片描述

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值