1
This commit is contained in:
commit
80149da0f8
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
blackbox.tar.gz
|
||||
blackbox_exporter-*
|
46
install-blackbox.sh
Executable file
46
install-blackbox.sh
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DOWNLOAD_URL="https://github.com/prometheus/blackbox_exporter/releases/download/v0.24.0/blackbox_exporter-0.24.0.linux-amd64.tar.gz"
|
||||
|
||||
wget "${DOWNLOAD_URL}" -O "blackbox.tar.gz"
|
||||
|
||||
tar xvf blackbox.tar.gz
|
||||
|
||||
cd blackbox_exporter-*linux-amd64
|
||||
mv blackbox_exporter /usr/local/bin
|
||||
|
||||
mkdir -p /etc/blackbox
|
||||
|
||||
mv blackbox.yml /etc/blackbox
|
||||
cd -
|
||||
|
||||
useradd -rs /bin/false blackbox
|
||||
|
||||
chown blackbox:blackbox /usr/local/bin/blackbox_exporter
|
||||
|
||||
chown -R blackbox:blackbox /etc/blackbox/*
|
||||
|
||||
cat >/etc/systemd/system/blackbox.service <<EOF
|
||||
[Unit]
|
||||
Description=Blackbox Exporter Service
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=blackbox
|
||||
Group=blackbox
|
||||
ExecStart=/usr/local/bin/blackbox_exporter \
|
||||
--config.file=/etc/blackbox/blackbox.yml \
|
||||
--web.listen-address=":9115"
|
||||
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl enable blackbox.service
|
||||
systemctl start blackbox.service
|
||||
|
||||
systemctl status blackbox --no-pager
|
88
install-prometheus.sh
Executable file
88
install-prometheus.sh
Executable file
@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
|
||||
|
||||
DOWNLOAD_URL="https://github.com/prometheus/prometheus/releases/download/v2.50.1/prometheus-2.50.1.linux-amd64.tar.gz"
|
||||
|
||||
groupadd --system prometheus
|
||||
|
||||
useradd -s /sbin/nologin --system -g prometheus prometheus
|
||||
|
||||
mkdir /var/lib/prometheus
|
||||
|
||||
for i in rules rules.d files_sd
|
||||
do
|
||||
mkdir -p /etc/prometheus/${i}
|
||||
done
|
||||
|
||||
|
||||
mkdir -p /tmp/prometheus
|
||||
|
||||
cd /tmp/prometheus
|
||||
#curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -
|
||||
wget "${DOWNLOAD_URL}" -O "prometheus.tar.gz"
|
||||
|
||||
tar xvf prometheus.tar.gz
|
||||
|
||||
cd prometheus*/
|
||||
|
||||
mv prometheus promtool /usr/local/bin/
|
||||
|
||||
prometheus --version
|
||||
|
||||
mv prometheus.yml /etc/prometheus/prometheus.yml
|
||||
|
||||
mv consoles/ console_libraries/ /etc/prometheus/
|
||||
|
||||
cd ${HOME}
|
||||
|
||||
cat >/etc/systemd/system/prometheus.service <<EOF
|
||||
[Unit]
|
||||
Description=Prometheus
|
||||
Documentation=https://prometheus.io/docs/introduction/overview/
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=prometheus
|
||||
Group=prometheus
|
||||
ExecReload=/bin/kill -HUP \$MAINPID
|
||||
ExecStart=/usr/local/bin/prometheus \
|
||||
--config.file=/etc/prometheus/prometheus.yml \
|
||||
--storage.tsdb.path=/var/lib/prometheus \
|
||||
--web.console.templates=/etc/prometheus/consoles \
|
||||
--web.console.libraries=/etc/prometheus/console_libraries \
|
||||
--web.listen-address=0.0.0.0:9090 \
|
||||
--web.external-url=
|
||||
|
||||
SyslogIdentifier=prometheus
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
for i in rules rules.d files_sd
|
||||
do
|
||||
chown -R prometheus:prometheus /etc/prometheus/${i}
|
||||
done
|
||||
|
||||
for i in rules rules.d files_sd
|
||||
do
|
||||
chmod -R 775 /etc/prometheus/${i}
|
||||
done
|
||||
|
||||
chown -R prometheus:prometheus /var/lib/prometheus/
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
systemctl start prometheus
|
||||
|
||||
systemctl enable prometheus
|
||||
|
||||
systemctl status prometheus --no-pager
|
||||
|
||||
|
||||
set +x
|
Loading…
Reference in New Issue
Block a user