3. 远程主机添加到prometheus监控
1. 上传node-explorer到要被监控的主机解压缩¶
# 10.0.8.2
tar -zxvf node_exporter-1.3.1.linux-amd64.tar.gz
ubuntu@zabbix:~$ cd node_exporter-1.3.1.linux-amd64/
ubuntu@zabbix:~/node_exporter-1.3.1.linux-amd64$ ls
LICENSE node_exporter NOTICE
2. 运行¶
sudo -i
nohup ./node_exporter &
jobs
netstat -tunlp|grep 9100
ubuntu@zabbix:~/node_exporter-1.3.1.linux-amd64$ sudo -i
root@zabbix:~# cd /home/ubuntu/node_exporter-1.3.1.linux-amd64/
root@zabbix:/home/ubuntu/node_exporter-1.3.1.linux-amd64# ls
LICENSE node_exporter NOTICE
root@zabbix:/home/ubuntu/node_exporter-1.3.1.linux-amd64# nohup ./node_exporter &
[1] 1306387
root@zabbix:/home/ubuntu/node_exporter-1.3.1.linux-amd64# nohup: ignoring input and appending output to 'nohup.out'
root@zabbix:/home/ubuntu/node_exporter-1.3.1.linux-amd64#
root@zabbix:/home/ubuntu/node_exporter-1.3.1.linux-amd64# jobs
[1]+ Running nohup ./node_exporter &
root@zabbix:/home/ubuntu/node_exporter-1.3.1.linux-amd64#
root@zabbix:/home/ubuntu/node_exporter-1.3.1.linux-amd64#
root@zabbix:/home/ubuntu/node_exporter-1.3.1.linux-amd64# netstat -tunlp|grep 9100
tcp6 0 0 :::9100 :::* LISTEN 1306387/./node_expo
浏览器查看¶
点击metrics可以看到所有监控项!

3. 修改prometheus配置文件¶
# 10.0.8.5
vim prometheus.yml
# 文件最后添加如下内容
# 新加10.0.8.2
- job_name: "agent"
static_configs:
- targets: ["10.0.8.2:9100"]
4. 关闭Prometheus¶
# 查看进程号
ps -ef|grep prometheus
netstat -tunlp|grep 9090
# 关闭进程
kill -9
root@4c16g:/home/ubuntu/prometheus-2.33.3.linux-amd64# ps -ef|grep prometheus
root 665088 1 0 13:17 ? 00:00:01 ./prometheus
root 718516 711590 0 13:42 pts/0 00:00:00 grep --color=auto prometheus
root@4c16g:/home/ubuntu/prometheus-2.33.3.linux-amd64#
root@4c16g:/home/ubuntu/prometheus-2.33.3.linux-amd64# netstat -tunlp|grep prometheus
tcp6 0 0 :::9090 :::* LISTEN 665088/./prometheus
root@4c16g:/home/ubuntu/prometheus-2.33.3.linux-amd64#
root@4c16g:/home/ubuntu/prometheus-2.33.3.linux-amd64#
root@4c16g:/home/ubuntu/prometheus-2.33.3.linux-amd64# kill -9 665088
root@4c16g:/home/ubuntu/prometheus-2.33.3.linux-amd64#
root@4c16g:/home/ubuntu/prometheus-2.33.3.linux-amd64# netstat -tunlp|grep prometheus
5. 重启Prometheus¶
nohup ./prometheus &
jobs
6. 访问查看¶
点击status,找到target
可以看到agent显示为up,说明成功!!!

7. 监控项查看¶
查看某个监控项,会显示所有主机信息!

最后更新:
2022-02-25 03:53:42