在linux节点上安装node exporter随记:修订间差异
来自三线的随记
小无编辑摘要 |
小无编辑摘要 |
||
第1行: | 第1行: | ||
== MONITORING LINUX HOST METRICS WITH THE NODE EXPORTER == | ==MONITORING LINUX HOST METRICS WITH THE NODE EXPORTER== | ||
=== | ===Systemd configure file example=== | ||
[Unit] | [Unit] | ||
Description=node_exporter | Description=node_exporter | ||
第18行: | 第18行: | ||
[Install] | [Install] | ||
WantedBy=multi-user.target | WantedBy=multi-user.target | ||
===binary file download=== | ===binary file download=== | ||
https://github.com/prometheus/node_exporter/releases | https://github.com/prometheus/node_exporter/releases | ||
<br /> | <br /> | ||
=== 下載node exporter 二進制文件壓縮包 === | |||
在節點上執行命令下載 | |||
wget "<nowiki>https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz</nowiki>" | |||
=== 解壓壓縮包 === | |||
[root@master wilo]# tar -xzf node_exporter-1.0.1.linux-amd64.tar.gz | |||
[root@master wilo]# ls | |||
node_exporter-1.0.1.linux-amd64 node_exporter-1.0.1.linux-amd64.tar.gz | |||
[root@master wilo]# | |||
=== 將 node_exporter 二進制文件複製到 /usr/local/bin 路徑下 === | |||
[root@master wilo]# cd node_exporter-1.0.1.linux-amd64/ | |||
[root@master node_exporter-1.0.1.linux-amd64]# ls | |||
LICENSE node_exporter NOTICE | |||
[root@master node_exporter-1.0.1.linux-amd64]# cp node_exporter /usr/local/bin/ | |||
[root@master node_exporter-1.0.1.linux-amd64]# ls -l /usr/local/bin/node_exporter | |||
-rwxr-xr-x. 1 root root 19657731 Oct 22 12:17 /usr/local/bin/node_exporter | |||
=== 直接複製下文全部文字命令並在節點上執行以創建systemd service文件 === | |||
cat <<EOF > /etc/systemd/system/node_exporter.service | |||
[Unit] | |||
Description=node_exporter | |||
After=network.target | |||
[Service] | |||
User=nobody | |||
Group=nobody | |||
Type=simple | |||
ExecStart=/usr/local/bin/node_exporter\ | |||
--collector.systemd\ | |||
--collector.processes | |||
[Install] | |||
WantedBy=multi-user.target | |||
EOF | |||
=== 重載系統 systemd 配置 === | |||
執行命令 <code>systemd daemon-reload</code> | |||
=== 啟動服務並且設置服務開機自啟 === | |||
執行命令 <code>systemctl enable --now node_exporter</code> | |||
[root@master system]# systemctl enable --now node_exporter | |||
Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /etc/systemd/system/node_exporter.service. | |||
=== 查看服務運行狀態 === | |||
執行命令<code>systemctl status node_exporter</code> | |||
能夠得到類似下文的回顯結果 | |||
主要看Active屬性值為<code>active(running)</code>就好了 | |||
[root@master system]# systemctl status node_exporter | |||
● node_exporter.service - node_exporter | |||
Loaded: loaded (/etc/systemd/system/node_exporter.service; enabled; vendor preset: disabled) | |||
Active: active (running) since Thu 2020-10-22 14:20:44 CST; 6min ago | |||
Main PID: 27847 (node_exporter) | |||
CGroup: /system.slice/node_exporter.service | |||
└─27847 /usr/local/bin/node_exporter --collector.systemd --collector.processes | |||
=== 測試接口 === | |||
在節點上使用命令<code>curl -I <nowiki>{{節點IP}}</nowiki>:9100/metrics</code>測試訪問接口 | |||
能夠得到類似下文結果 | |||
[root@master system]# curl -I 192.168.150.166:9100/metrics | |||
HTTP/1.1 200 OK | |||
Content-Type: text/plain; version=0.0.4; charset=utf-8 | |||
Date: Thu, 22 Oct 2020 06:34:49 GMT | |||
或直接使用瀏覽器訪問<code><nowiki>{{節點IP}}</nowiki>:9100/metrics</code>能夠看到相關指標信息則為正常<br /> | |||
[[分类:Linux]] | [[分类:Linux]] | ||
[[分类:Prometheus]] | [[分类:Prometheus]] | ||
{{DEFAULTSORT:node_exporter随记}} | {{DEFAULTSORT:node_exporter随记}} |
2020年10月22日 (四) 14:44的版本
MONITORING LINUX HOST METRICS WITH THE NODE EXPORTER
Systemd configure file example
[Unit] Description=node_exporter After=network.target [Service] User=prometheus Group=prometheus ExecStart=/usr/local/exporter/node_exporter/node_exporter\ --web.listen-address=:20001\ --collector.systemd\ --collector.systemd.unit-whitelist=(sshd|nginx).service\ --collector.processes\ --collector.tcpstat\ --collector.supervisord [Install] WantedBy=multi-user.target
binary file download
https://github.com/prometheus/node_exporter/releases
下載node exporter 二進制文件壓縮包
在節點上執行命令下載
wget "https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz"
解壓壓縮包
[root@master wilo]# tar -xzf node_exporter-1.0.1.linux-amd64.tar.gz [root@master wilo]# ls node_exporter-1.0.1.linux-amd64 node_exporter-1.0.1.linux-amd64.tar.gz [root@master wilo]#
將 node_exporter 二進制文件複製到 /usr/local/bin 路徑下
[root@master wilo]# cd node_exporter-1.0.1.linux-amd64/ [root@master node_exporter-1.0.1.linux-amd64]# ls LICENSE node_exporter NOTICE [root@master node_exporter-1.0.1.linux-amd64]# cp node_exporter /usr/local/bin/ [root@master node_exporter-1.0.1.linux-amd64]# ls -l /usr/local/bin/node_exporter -rwxr-xr-x. 1 root root 19657731 Oct 22 12:17 /usr/local/bin/node_exporter
直接複製下文全部文字命令並在節點上執行以創建systemd service文件
cat <<EOF > /etc/systemd/system/node_exporter.service [Unit] Description=node_exporter After=network.target [Service] User=nobody Group=nobody Type=simple ExecStart=/usr/local/bin/node_exporter\ --collector.systemd\ --collector.processes [Install] WantedBy=multi-user.target EOF
重載系統 systemd 配置
執行命令 systemd daemon-reload
啟動服務並且設置服務開機自啟
執行命令 systemctl enable --now node_exporter
[root@master system]# systemctl enable --now node_exporter Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /etc/systemd/system/node_exporter.service.
查看服務運行狀態
執行命令systemctl status node_exporter
能夠得到類似下文的回顯結果
主要看Active屬性值為active(running)
就好了
[root@master system]# systemctl status node_exporter ● node_exporter.service - node_exporter Loaded: loaded (/etc/systemd/system/node_exporter.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2020-10-22 14:20:44 CST; 6min ago Main PID: 27847 (node_exporter) CGroup: /system.slice/node_exporter.service └─27847 /usr/local/bin/node_exporter --collector.systemd --collector.processes
測試接口
在節點上使用命令curl -I {{節點IP}}:9100/metrics
測試訪問接口
能夠得到類似下文結果
[root@master system]# curl -I 192.168.150.166:9100/metrics HTTP/1.1 200 OK Content-Type: text/plain; version=0.0.4; charset=utf-8 Date: Thu, 22 Oct 2020 06:34:49 GMT
或直接使用瀏覽器訪問{{節點IP}}:9100/metrics
能夠看到相關指標信息則為正常