Skip to content

Commit

Permalink
Prometheus + Alertmanager: Unify scripts for easier maintenance (#1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrunwald authored Jan 10, 2025
1 parent b7a8d34 commit 9a4d35b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
7 changes: 3 additions & 4 deletions ct/prometheus-alertmanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@ function update_script() {
cd /opt
wget -q https://github.com/prometheus/alertmanager/releases/download/v${RELEASE}/alertmanager-${RELEASE}.linux-amd64.tar.gz
tar -xf alertmanager-${RELEASE}.linux-amd64.tar.gz
cd alertmanager-${RELEASE}.linux-amd64
cp -rf alertmanager amtool /usr/local/bin/
cp -rf alertmanager-${RELEASE}.linux-amd64/alertmanager alertmanager-${RELEASE}.linux-amd64/amtool /usr/local/bin/
rm -rf alertmanager-${RELEASE}.linux-amd64 alertmanager-${RELEASE}.linux-amd64.tar.gz
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP} to ${RELEASE}"
msg_ok "Updated ${APP} to v${RELEASE}"

msg_info "Starting ${APP}"
systemctl start prometheus-alertmanager
msg_ok "Started ${APP}"
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
}
Expand Down
13 changes: 6 additions & 7 deletions ct/prometheus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 tteck
# Copyright (c) 2021-2025 community-scripts ORG
# Author: tteck (tteckster)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://prometheus.io/
Expand Down Expand Up @@ -38,22 +38,21 @@ function update_script() {
systemctl stop prometheus
msg_ok "Stopped ${APP}"

msg_info "Updating ${APP} to ${RELEASE}"
msg_info "Updating ${APP} to v${RELEASE}"
cd /opt
wget -q https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz
tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz
cd prometheus-${RELEASE}.linux-amd64
cp -rf prometheus promtool /usr/local/bin/
cd ~
cp -rf prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/
rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP} to ${RELEASE}"
msg_ok "Updated ${APP} to v${RELEASE}"

msg_info "Starting ${APP}"
systemctl start prometheus
msg_ok "Started ${APP}"
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
}
Expand Down
25 changes: 13 additions & 12 deletions install/prometheus-install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

# Copyright (c) 2021-2025 tteck
# Copyright (c) 2021-2025 community-scripts ORG
# Author: tteck (tteckster)
# License: MIT
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://prometheus.io/

source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
Expand All @@ -14,9 +14,10 @@ network_check
update_os

msg_info "Installing Dependencies"
$STD apt-get install -y curl
$STD apt-get install -y sudo
$STD apt-get install -y mc
$STD apt-get install -y \
curl \
sudo \
mc
msg_ok "Installed Dependencies"

msg_info "Installing Prometheus"
Expand All @@ -25,14 +26,13 @@ mkdir -p /etc/prometheus
mkdir -p /var/lib/prometheus
wget -q https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz
tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz
cd prometheus-${RELEASE}.linux-amd64
mv prometheus promtool /usr/local/bin/
mv prometheus.yml /etc/prometheus/prometheus.yml
mv prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/
mv prometheus-${RELEASE}.linux-amd64/prometheus.yml /etc/prometheus/prometheus.yml
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed Prometheus"

msg_info "Creating Service"
service_path="/etc/systemd/system/prometheus.service"
cat <<EOF >/etc/systemd/system/prometheus.service"
echo "[Unit]
Description=Prometheus
Wants=network-online.target
Expand All @@ -49,7 +49,8 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP \$MAINPID
[Install]
WantedBy=multi-user.target" >$service_path
WantedBy=multi-user.target"
EOF
systemctl enable -q --now prometheus
msg_ok "Created Service"

Expand All @@ -59,5 +60,5 @@ customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
rm -rf ../prometheus-${RELEASE}.linux-amd64 ../prometheus-${RELEASE}.linux-amd64.tar.gz
rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz
msg_ok "Cleaned"

0 comments on commit 9a4d35b

Please sign in to comment.