(一) 下载安装监控软件
-
下载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 -
下载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:
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
- targets: [‘localhost:9090’]
- job_name: ‘name1’
static_configs:- targets: [‘ip:9182’]
labels:
instance: name1
- targets: [‘ip:9182’]
#linux
- job_name: name2’
static_configs:- targets: [‘ip:9101’]
labels:
instance: ip
name: name
env: linux
- targets: [‘ip:9101’]
重新启动prometheus;
(三) 打开端口
-
Linux
sudo iptables -I INPUT -s 192.16.4.227 -p tcp --dport 9101 -j ACCEPT -
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;