Prometheus blackbox exporter install script

by michael
2 minutes
Prometheus blackbox exporter install script

Same as for the node exporter...

-> https://github.com/prometheus/blackbox_exporter

!#/bin/sh

sudo useradd --no-create-home --shell /bin/false blackbox_exporter
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.18.0/blackbox_exporter-0.18.0.linux-amd64.tar.gz
tar xvf blackbox_exporter-0.18.0.linux-amd64.tar.gz
sudo cp blackbox_exporter-0.18.0.linux-amd64/blackbox_exporter /usr/local/bin
sudo chown blackbox_exporter:blackbox_exporter /usr/local/bin/blackbox_exporter
sudo mkdir /etc/blackbox
sudo cp blackbox_exporter-0.18.0.linux-amd64/blackbox.yml /etc/blackbox
sudo chown blackbox_exporter:blackbox_exporter /etc/blackbox
sudo chown blackbox_exporter:blackbox_exporter /etc/blackbox/blackbox.yml 
rm -rf blackbox_exporter-0.18.0.linux-amd64.tar.gz blackbox_exporter-0.18.0.linux-amd64
sudo touch /etc/systemd/system/blackbox_exporter.service

echo "[Unit]
Description=Blackbox Exporter Service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=blackbox_exporter
Group=blackbox_exporter
ExecStart=/usr/local/bin/blackbox_exporter \
  --config.file=/etc/blackbox/blackbox.yml \
  --web.listen-address=\":9115\"

Restart=always

[Install]
WantedBy=multi-user.target" > /etc/systemd/system/blackbox.service

sudo systemctl daemon-reload
sudo systemctl start blackbox
sudo systemctl status blackbox
sudo systemctl enable blackbox

Simple blackbox.yml:

modules:
  http_2xx:
    prober: http
  http_post_2xx:
    prober: http
    http:
      method: POST
  tcp_connect:
    prober: tcp
  pop3s_banner:
    prober: tcp
    tcp:
      query_response:
      - expect: "^+OK"
      tls: true
      tls_config:
        insecure_skip_verify: false
  ssh_banner:
    prober: tcp
    tcp:
      query_response:
      - expect: "^SSH-2.0-"
  irc_banner:
    prober: tcp
    tcp:
      query_response:
      - send: "NICK prober"
      - send: "USER prober prober prober :prober"
      - expect: "PING :([^ ]+)"
        send: "PONG ${1}"
      - expect: "^:[^ ]+ 001"
  icmp:
    prober: icmp

Currently there are no comments, so be the first!