blackbox_exporter之安装

  • 环境:centos7, blackbox_exporter 0.12.0

前言

这里使用blackbox_exporter的ssh和ping的检测功能.

Build with Binary And Config Systemd

Build with Binary

  • Download
    1
    2
    3
    $ cd /opt
    $ wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.12.0/blackbox_exporter-0.12.0.linux-amd64.tar.gz
    $ tar -xvf blackbox_exporter-0.12.0.linux-amd64.tar.gz && mv blackbox_exporter-0.12.0.linux-amd64 blackbox_exporter-0.12.0

Config blackbox.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
$ vim /opt/blackbox_exporter-0.12.0/blackbox.yml
modules:
ssh_banner:
prober: tcp
timeout: 15s
tcp:
query_response:
- expect: "^SSH-2.0-"
icmp:
prober: icmp
timeout: 5s
icmp:
preferred_ip_protocol: "ip4"

Config Systemd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ vim /usr/lib/systemd/system/blackbox.service
[Unit]
Description=blackbox.service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
ExecStart=/opt/blackbox_exporter-0.12.0/blackbox_exporter --config.file=/opt/blackbox_exporter-0.12.0/blackbox.yml
Restart=on-failure
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID

[Install]
WantedBy=multi-user.target

# 启动
$ systemctl enable blackbox && systemctl start blackbox

Test blackbox

在浏览器中查看:http://10.1.1.26:9115

Build with Docker

坚持原创技术分享,您的支持将鼓励我继续创作!
Fork me on GitHub