Prometheus监控sshd服务运行状态

571 阅读1分钟

监控系统服务运行状态

5.1 查看node_exporter帮忙获取需要的参数选项

# ./node_exporter --help
--collector.systemd                         # Enable the systemd collector (default: disabled).
--collector.systemd.unit-whitelist=".+"     # Regexp of systemd units to whitelist. Units must both match whitelist and not match blacklist to be included.

5.2 修改node_exporter服务启动参数(监控sshd和nginx服务)

# cat /usr/lib/systemd/system/node_exporter.service 
[Unit]
Description=https://prometheus.io

[Service]
Restart=on-failure
ExecStart=/usr/local/node_exporter/node_exporter --collector.systemd --collector.systemd.unit-whitelist=(sshd|nginx).service

[Install]
WantedBy=multi-user.target

# systemctl daemon-reload
# systemctl restart node_exporter.service 
  # ps aux | grep node  root     2993957  0.2  0.5 115760 10216 ?        Ssl  20:46   0:00 /usr/local/node_exporter/node_exporter --collector.systemd --collector.systemd.unit-whitelist=(sshd|nginx).service

5.3 查看prometheus端是否成功

图片.png