From 8645c8e78870765eeec92ad796e6319d5890aeb3 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 11:55:59 +0100 Subject: [PATCH 01/10] New Script: Prometheus Proxmox VE Exporter See https://github.com/prometheus-pve/prometheus-pve-exporter --- ct/prometheus-pve-exporter.sh | 60 ++++++++++++++++++ install/prometheus-pve-exporter-install.sh | 73 ++++++++++++++++++++++ json/prometheus-pve-exporter.json | 33 ++++++++++ 3 files changed, 166 insertions(+) create mode 100644 ct/prometheus-pve-exporter.sh create mode 100644 install/prometheus-pve-exporter-install.sh create mode 100644 json/prometheus-pve-exporter.json diff --git a/ct/prometheus-pve-exporter.sh b/ct/prometheus-pve-exporter.sh new file mode 100644 index 00000000..e94b03ae --- /dev/null +++ b/ct/prometheus-pve-exporter.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Andy Grunwald (andygrunwald) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/prometheus-pve/prometheus-pve-exporter + +# App Default Values +APP="Prometheus-Proxmox-VE-Exporter" +var_tags="monitoring" +var_cpu="1" +var_ram="1024" +var_disk="2" +var_os="debian" +var_version="12" +var_unprivileged="1" + +# App Output & Base Settings +header_info "$APP" +base_settings + +# Core +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -f /etc/systemd/system/prometheus-pve-exporter.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Stopping ${APP}" + systemctl stop prometheus-pve-exporter + msg_ok "Stopped ${APP}" + + msg_info "Updating ${APP}" + pip install prometheus-pve-exporter --upgrade &>/dev/null + msg_ok "Updated ${APP}" + + msg_info "Starting ${APP}" + systemctl start prometheus-pve-exporter + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9221${CL}" +echo -e "${INFO}${YW} Please adjust the credentials in the configuration file:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}/etc/prometheus-pve-exporter/pve.yml" \ No newline at end of file diff --git a/install/prometheus-pve-exporter-install.sh b/install/prometheus-pve-exporter-install.sh new file mode 100644 index 00000000..8ced7d07 --- /dev/null +++ b/install/prometheus-pve-exporter-install.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Andy Grunwald (andygrunwald) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/prometheus-pve/prometheus-pve-exporter + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + sudo \ + mc +msg_ok "Installed Dependencies" + +msg_info "Updating Python3" +$STD apt-get install -y \ + python3 \ + #python3-dev \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Installing Prometheus Proxmox VE Exporter" +python3 -m pip install --quiet prometheus-pve-exporter + +mkdir -p /etc/prometheus-pve-exporter +cat < /etc/prometheus-pve-exporter/pve.yml +default: + user: prometheus@pve + password: sEcr3T! + verify_ssl: false +EOF + +msg_ok "Installed Prometheus Proxmox VE Exporter" + +msg_info "Creating Service" +cat </etc/systemd/system/prometheus-pve-exporter.service +[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_exporter \ + --config.file=/etc/prometheus-pve-exporter/pve.yml \ + --web.listen-address=0.0.0.0:9221 +ExecReload=/bin/kill -HUP \$MAINPID + +[Install] +WantedBy=multi-user.target +EOF + +systemctl enable -q --now prometheus-pve-exporter +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/json/prometheus-pve-exporter.json b/json/prometheus-pve-exporter.json new file mode 100644 index 00000000..3e88667a --- /dev/null +++ b/json/prometheus-pve-exporter.json @@ -0,0 +1,33 @@ +{ + "name": "Prometheus Proxmox VE Exporter", + "slug": "prometheus-proxmox-ve-exporter", + "categories": [ + 9 + ], + "date_created": "2025-01-28", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 9221, + "documentation": "https://github.com/prometheus-pve/prometheus-pve-exporter", + "website": "https://github.com/prometheus-pve/prometheus-pve-exporter", + "description": "An exporter that exposes information gathered from Proxmox VE node for use by the Prometheus monitoring system.", + "install_methods": [ + { + "type": "default", + "script": "ct/prometheus-pve-exporter.sh", + "resources": { + "cpu": 1, + "ram": 1024, + "hdd": 2, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} From a6f450ceae69d02371fa32f0fdc631e2da11af4c Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 12:10:53 +0100 Subject: [PATCH 02/10] Fix formatting of config file output after installation --- ct/prometheus-pve-exporter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/prometheus-pve-exporter.sh b/ct/prometheus-pve-exporter.sh index e94b03ae..106b094f 100644 --- a/ct/prometheus-pve-exporter.sh +++ b/ct/prometheus-pve-exporter.sh @@ -57,4 +57,4 @@ echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9221${CL}" echo -e "${INFO}${YW} Please adjust the credentials in the configuration file:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}/etc/prometheus-pve-exporter/pve.yml" \ No newline at end of file +echo -e "${INFO}${YW} /etc/prometheus-pve-exporter/pve.yml${CL}" \ No newline at end of file From 90ea9cc0ab22059df7a507ff424d2248c84952d4 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 13:15:35 +0100 Subject: [PATCH 03/10] Prometheus Proxmox VE Exporter: Set category 1 for Website --- json/prometheus-pve-exporter.json | 1 + 1 file changed, 1 insertion(+) diff --git a/json/prometheus-pve-exporter.json b/json/prometheus-pve-exporter.json index 3e88667a..34fa90d4 100644 --- a/json/prometheus-pve-exporter.json +++ b/json/prometheus-pve-exporter.json @@ -2,6 +2,7 @@ "name": "Prometheus Proxmox VE Exporter", "slug": "prometheus-proxmox-ve-exporter", "categories": [ + 1, 9 ], "date_created": "2025-01-28", From 4c894d24c0b5fb725f036a202518c09f08b8443c Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 13:19:38 +0100 Subject: [PATCH 04/10] Removed blank lines --- install/prometheus-pve-exporter-install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/install/prometheus-pve-exporter-install.sh b/install/prometheus-pve-exporter-install.sh index 8ced7d07..6451b328 100644 --- a/install/prometheus-pve-exporter-install.sh +++ b/install/prometheus-pve-exporter-install.sh @@ -30,7 +30,6 @@ msg_ok "Updated Python3" msg_info "Installing Prometheus Proxmox VE Exporter" python3 -m pip install --quiet prometheus-pve-exporter - mkdir -p /etc/prometheus-pve-exporter cat < /etc/prometheus-pve-exporter/pve.yml default: @@ -38,7 +37,6 @@ default: password: sEcr3T! verify_ssl: false EOF - msg_ok "Installed Prometheus Proxmox VE Exporter" msg_info "Creating Service" From fdc09aca1f650688056c4e4aef21202484c80cc8 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 13:20:49 +0100 Subject: [PATCH 05/10] Remove `python3-dev`, as it was commented out --- install/prometheus-pve-exporter-install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install/prometheus-pve-exporter-install.sh b/install/prometheus-pve-exporter-install.sh index 6451b328..9160acc6 100644 --- a/install/prometheus-pve-exporter-install.sh +++ b/install/prometheus-pve-exporter-install.sh @@ -23,7 +23,6 @@ msg_ok "Installed Dependencies" msg_info "Updating Python3" $STD apt-get install -y \ python3 \ - #python3-dev \ python3-pip rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED msg_ok "Updated Python3" From 0fd95c67d135aba6c2f6cd37501bd50f59858a82 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 13:22:30 +0100 Subject: [PATCH 06/10] Prometheus Proxmox VE Exporter: Move configuration under /opt --- ct/prometheus-pve-exporter.sh | 2 +- install/prometheus-pve-exporter-install.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ct/prometheus-pve-exporter.sh b/ct/prometheus-pve-exporter.sh index 106b094f..ac646585 100644 --- a/ct/prometheus-pve-exporter.sh +++ b/ct/prometheus-pve-exporter.sh @@ -57,4 +57,4 @@ echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9221${CL}" echo -e "${INFO}${YW} Please adjust the credentials in the configuration file:${CL}" -echo -e "${INFO}${YW} /etc/prometheus-pve-exporter/pve.yml${CL}" \ No newline at end of file +echo -e "${INFO}${YW} /opt/prometheus-pve-exporter/pve.yml${CL}" \ No newline at end of file diff --git a/install/prometheus-pve-exporter-install.sh b/install/prometheus-pve-exporter-install.sh index 9160acc6..2be6bfb1 100644 --- a/install/prometheus-pve-exporter-install.sh +++ b/install/prometheus-pve-exporter-install.sh @@ -29,8 +29,8 @@ msg_ok "Updated Python3" msg_info "Installing Prometheus Proxmox VE Exporter" python3 -m pip install --quiet prometheus-pve-exporter -mkdir -p /etc/prometheus-pve-exporter -cat < /etc/prometheus-pve-exporter/pve.yml +mkdir -p /opt/prometheus-pve-exporter +cat < /opt/prometheus-pve-exporter/pve.yml default: user: prometheus@pve password: sEcr3T! @@ -50,7 +50,7 @@ User=root Restart=always Type=simple ExecStart=pve_exporter \ - --config.file=/etc/prometheus-pve-exporter/pve.yml \ + --config.file=/opt/prometheus-pve-exporter/pve.yml \ --web.listen-address=0.0.0.0:9221 ExecReload=/bin/kill -HUP \$MAINPID From 8fb1fe5db0ecbd7d1ec3342840fcc7716350dc3d Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 13:24:40 +0100 Subject: [PATCH 07/10] Prometheus Proxmox VE Exporter: Add logo --- json/prometheus-pve-exporter.json | 1 + 1 file changed, 1 insertion(+) diff --git a/json/prometheus-pve-exporter.json b/json/prometheus-pve-exporter.json index 34fa90d4..6590575e 100644 --- a/json/prometheus-pve-exporter.json +++ b/json/prometheus-pve-exporter.json @@ -12,6 +12,7 @@ "interface_port": 9221, "documentation": "https://github.com/prometheus-pve/prometheus-pve-exporter", "website": "https://github.com/prometheus-pve/prometheus-pve-exporter", + "logo": "https://raw.githubusercontent.com/home-assistant/brands/master/core_integrations/proxmoxve/icon.png", "description": "An exporter that exposes information gathered from Proxmox VE node for use by the Prometheus monitoring system.", "install_methods": [ { From 88846c6df1167755aa5f61fd2d58d4cdd2d6f95c Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 13:39:58 +0100 Subject: [PATCH 08/10] Change `msg_info "Updating Python3"` to `msg_info "Setup Python3"` --- install/prometheus-pve-exporter-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/prometheus-pve-exporter-install.sh b/install/prometheus-pve-exporter-install.sh index 2be6bfb1..ddc100c1 100644 --- a/install/prometheus-pve-exporter-install.sh +++ b/install/prometheus-pve-exporter-install.sh @@ -20,12 +20,12 @@ $STD apt-get install -y \ mc msg_ok "Installed Dependencies" -msg_info "Updating Python3" +msg_info "Setup Python3" $STD apt-get install -y \ python3 \ python3-pip rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED -msg_ok "Updated Python3" +msg_ok "Setup Python3" msg_info "Installing Prometheus Proxmox VE Exporter" python3 -m pip install --quiet prometheus-pve-exporter From eac423cea96928d8d92911322ab8c158d4ef3bf5 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 13:55:39 +0100 Subject: [PATCH 09/10] Removed empty line --- ct/prometheus-pve-exporter.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ct/prometheus-pve-exporter.sh b/ct/prometheus-pve-exporter.sh index ac646585..ca96e656 100644 --- a/ct/prometheus-pve-exporter.sh +++ b/ct/prometheus-pve-exporter.sh @@ -32,7 +32,6 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - msg_info "Stopping ${APP}" systemctl stop prometheus-pve-exporter msg_ok "Stopped ${APP}" From 94d465cf92dc678a37a62f7c921df856e994cc24 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 28 Jan 2025 13:57:34 +0100 Subject: [PATCH 10/10] Add note about Proxmox credentials into the website --- ct/prometheus-pve-exporter.sh | 4 +--- json/prometheus-pve-exporter.json | 9 +++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ct/prometheus-pve-exporter.sh b/ct/prometheus-pve-exporter.sh index ca96e656..6d795bd0 100644 --- a/ct/prometheus-pve-exporter.sh +++ b/ct/prometheus-pve-exporter.sh @@ -54,6 +54,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9221${CL}" -echo -e "${INFO}${YW} Please adjust the credentials in the configuration file:${CL}" -echo -e "${INFO}${YW} /opt/prometheus-pve-exporter/pve.yml${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9221${CL}" \ No newline at end of file diff --git a/json/prometheus-pve-exporter.json b/json/prometheus-pve-exporter.json index 6590575e..cc028b4b 100644 --- a/json/prometheus-pve-exporter.json +++ b/json/prometheus-pve-exporter.json @@ -31,5 +31,10 @@ "username": null, "password": null }, - "notes": [] -} + "notes": [ + { + "text": "Please adjust the Proxmox credentials in the configuration file: /opt/prometheus-pve-exporter/pve.yml", + "type": "info" + } + ] +} \ No newline at end of file