mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-06-30 02:57:38 +00:00
Update prometheus-pve-exporter.sh
This commit is contained in:
@ -25,21 +25,64 @@ function update_script() {
|
||||
check_container_resources
|
||||
if [[ ! -f /etc/systemd/system/prometheus-pve-exporter.service ]]; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msg_info "Stopping ${APP}"
|
||||
systemctl stop prometheus-pve-exporter
|
||||
msg_ok "Stopped ${APP}"
|
||||
|
||||
msg_info "Updating ${APP}"
|
||||
$STD pip install prometheus-pve-exporter --default-timeout=300 --upgrade --root-user-action=ignore
|
||||
msg_ok "Updated ${APP}"
|
||||
export PVE_VENV_PATH="/opt/prometheus-pve-exporter/.venv"
|
||||
export PVE_EXPORTER_BIN="${PVE_VENV_PATH}/bin/pve_exporter"
|
||||
|
||||
if [[ ! -d "$PVE_VENV_PATH" || ! -x "$PVE_EXPORTER_BIN" ]]; then
|
||||
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
|
||||
exit 0
|
||||
}
|
||||
|
||||
start
|
||||
|
Reference in New Issue
Block a user