Refactor: Prometheus PVE Exporter to uv based install (#5412)
This commit is contained in:
parent
66ab254fb2
commit
0efa83ff48
@ -20,26 +20,69 @@ color
|
|||||||
catch_errors
|
catch_errors
|
||||||
|
|
||||||
function update_script() {
|
function update_script() {
|
||||||
header_info
|
header_info
|
||||||
check_container_storage
|
check_container_storage
|
||||||
check_container_resources
|
check_container_resources
|
||||||
if [[ ! -f /etc/systemd/system/prometheus-pve-exporter.service ]]; then
|
if [[ ! -f /etc/systemd/system/prometheus-pve-exporter.service ]]; then
|
||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit 1
|
||||||
fi
|
fi
|
||||||
msg_info "Stopping ${APP}"
|
|
||||||
systemctl stop prometheus-pve-exporter
|
|
||||||
msg_ok "Stopped ${APP}"
|
|
||||||
|
|
||||||
msg_info "Updating ${APP}"
|
msg_info "Stopping ${APP}"
|
||||||
$STD pip install prometheus-pve-exporter --default-timeout=300 --upgrade --root-user-action=ignore
|
systemctl stop prometheus-pve-exporter
|
||||||
msg_ok "Updated ${APP}"
|
msg_ok "Stopped ${APP}"
|
||||||
|
|
||||||
msg_info "Starting ${APP}"
|
export PVE_VENV_PATH="/opt/prometheus-pve-exporter/.venv"
|
||||||
systemctl start prometheus-pve-exporter
|
export PVE_EXPORTER_BIN="${PVE_VENV_PATH}/bin/pve_exporter"
|
||||||
msg_ok "Started ${APP}"
|
|
||||||
msg_ok "Updated Successfully"
|
if [[ ! -d "$PVE_VENV_PATH" || ! -x "$PVE_EXPORTER_BIN" ]]; then
|
||||||
exit
|
PYTHON_VERSION="3.12" setup_uv
|
||||||
|
msg_info "Migrating to uv/venv"
|
||||||
|
rm -rf "$PVE_VENV_PATH"
|
||||||
|
mkdir -p /opt/prometheus-pve-exporter
|
||||||
|
cd /opt/prometheus-pve-exporter
|
||||||
|
$STD uv venv "$PVE_VENV_PATH"
|
||||||
|
$STD "$PVE_VENV_PATH/bin/python" -m ensurepip --upgrade
|
||||||
|
$STD "$PVE_VENV_PATH/bin/python" -m pip install --upgrade pip
|
||||||
|
$STD "$PVE_VENV_PATH/bin/python" -m pip install prometheus-pve-exporter
|
||||||
|
msg_ok "Migrated to uv/venv"
|
||||||
|
else
|
||||||
|
msg_info "Updating Prometheus Proxmox VE Exporter"
|
||||||
|
PYTHON_VERSION="3.12" setup_uv
|
||||||
|
$STD "$PVE_VENV_PATH/bin/python" -m pip install --upgrade prometheus-pve-exporter
|
||||||
|
msg_ok "Updated Prometheus Proxmox VE Exporter"
|
||||||
|
fi
|
||||||
|
local service_file="/etc/systemd/system/prometheus-pve-exporter.service"
|
||||||
|
if ! grep -q "${PVE_VENV_PATH}/bin/pve_exporter" "$service_file"; then
|
||||||
|
msg_info "Updating systemd service"
|
||||||
|
cat <<EOF >"$service_file"
|
||||||
|
[Unit]
|
||||||
|
Description=Prometheus Proxmox VE Exporter
|
||||||
|
Documentation=https://github.com/znerol/prometheus-pve-exporter
|
||||||
|
After=syslog.target network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
Restart=always
|
||||||
|
Type=simple
|
||||||
|
ExecStart=${PVE_VENV_PATH}/bin/pve_exporter \\
|
||||||
|
--config.file=/opt/prometheus-pve-exporter/pve.yml \\
|
||||||
|
--web.listen-address=0.0.0.0:9221
|
||||||
|
ExecReload=/bin/kill -HUP \$MAINPID
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
$STD systemctl daemon-reload
|
||||||
|
msg_ok "Updated systemd service"
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg_info "Starting ${APP}"
|
||||||
|
systemctl start prometheus-pve-exporter
|
||||||
|
msg_ok "Started ${APP}"
|
||||||
|
|
||||||
|
msg_ok "Updated Successfully"
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
start
|
start
|
||||||
@ -49,4 +92,4 @@ description
|
|||||||
msg_ok "Completed Successfully!\n"
|
msg_ok "Completed Successfully!\n"
|
||||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9221${CL}"
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9221${CL}"
|
||||||
|
@ -13,16 +13,16 @@ setting_up_container
|
|||||||
network_check
|
network_check
|
||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Setup Python3"
|
PYTHON_VERSION="3.12" setup_uv
|
||||||
$STD apt-get install -y \
|
|
||||||
python3 \
|
|
||||||
python3-pip
|
|
||||||
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
|
||||||
msg_ok "Setup Python3"
|
|
||||||
|
|
||||||
msg_info "Installing Prometheus Proxmox VE Exporter"
|
msg_info "Installing Prometheus Proxmox VE Exporter"
|
||||||
python3 -m pip install --default-timeout=300 --quiet --root-user-action=ignore prometheus-pve-exporter
|
|
||||||
mkdir -p /opt/prometheus-pve-exporter
|
mkdir -p /opt/prometheus-pve-exporter
|
||||||
|
cd /opt/prometheus-pve-exporter
|
||||||
|
|
||||||
|
$STD uv venv /opt/prometheus-pve-exporter/.venv
|
||||||
|
$STD /opt/prometheus-pve-exporter/.venv/bin/python -m ensurepip --upgrade
|
||||||
|
$STD /opt/prometheus-pve-exporter/.venv/bin/python -m pip install --upgrade pip
|
||||||
|
$STD /opt/prometheus-pve-exporter/.venv/bin/python -m pip install prometheus-pve-exporter
|
||||||
cat <<EOF >/opt/prometheus-pve-exporter/pve.yml
|
cat <<EOF >/opt/prometheus-pve-exporter/pve.yml
|
||||||
default:
|
default:
|
||||||
user: prometheus@pve
|
user: prometheus@pve
|
||||||
@ -42,7 +42,7 @@ After=syslog.target network.target
|
|||||||
User=root
|
User=root
|
||||||
Restart=always
|
Restart=always
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=pve_exporter \
|
ExecStart=/opt/prometheus-pve-exporter/.venv/bin/pve_exporter \
|
||||||
--config.file=/opt/prometheus-pve-exporter/pve.yml \
|
--config.file=/opt/prometheus-pve-exporter/pve.yml \
|
||||||
--web.listen-address=0.0.0.0:9221
|
--web.listen-address=0.0.0.0:9221
|
||||||
ExecReload=/bin/kill -HUP \$MAINPID
|
ExecReload=/bin/kill -HUP \$MAINPID
|
||||||
|
Loading…
x
Reference in New Issue
Block a user