Prometheus + Alertmanager: Unify scripts for easier maintenance (#1402)
This commit is contained in:
		
							parent
							
								
									b7a8d3453a
								
							
						
					
					
						commit
						9a4d35b1f2
					
				| @ -42,18 +42,17 @@ function update_script() { | |||||||
|     cd /opt |     cd /opt | ||||||
|     wget -q https://github.com/prometheus/alertmanager/releases/download/v${RELEASE}/alertmanager-${RELEASE}.linux-amd64.tar.gz |     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 |     tar -xf alertmanager-${RELEASE}.linux-amd64.tar.gz | ||||||
|     cd alertmanager-${RELEASE}.linux-amd64 |     cp -rf alertmanager-${RELEASE}.linux-amd64/alertmanager alertmanager-${RELEASE}.linux-amd64/amtool /usr/local/bin/ | ||||||
|     cp -rf alertmanager amtool /usr/local/bin/ |  | ||||||
|     rm -rf alertmanager-${RELEASE}.linux-amd64 alertmanager-${RELEASE}.linux-amd64.tar.gz |     rm -rf alertmanager-${RELEASE}.linux-amd64 alertmanager-${RELEASE}.linux-amd64.tar.gz | ||||||
|     echo "${RELEASE}" >/opt/${APP}_version.txt |     echo "${RELEASE}" >/opt/${APP}_version.txt | ||||||
|     msg_ok "Updated ${APP} to ${RELEASE}" |     msg_ok "Updated ${APP} to v${RELEASE}" | ||||||
| 
 | 
 | ||||||
|     msg_info "Starting ${APP}" |     msg_info "Starting ${APP}" | ||||||
|     systemctl start prometheus-alertmanager |     systemctl start prometheus-alertmanager | ||||||
|     msg_ok "Started ${APP}" |     msg_ok "Started ${APP}" | ||||||
|     msg_ok "Updated Successfully" |     msg_ok "Updated Successfully" | ||||||
|   else |   else | ||||||
|     msg_ok "No update required. ${APP} is already at ${RELEASE}" |     msg_ok "No update required. ${APP} is already at v${RELEASE}" | ||||||
|   fi |   fi | ||||||
|   exit |   exit | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| #!/usr/bin/env bash | #!/usr/bin/env bash | ||||||
| source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) | 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) | # 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: https://prometheus.io/ | ||||||
| @ -38,22 +38,21 @@ function update_script() { | |||||||
|     systemctl stop prometheus |     systemctl stop prometheus | ||||||
|     msg_ok "Stopped ${APP}" |     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 |     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 |     tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz | ||||||
|     cd prometheus-${RELEASE}.linux-amd64 |     cp -rf prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/ | ||||||
|     cp -rf prometheus promtool /usr/local/bin/ |  | ||||||
|     cd ~ |  | ||||||
|     rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz |     rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz | ||||||
|     echo "${RELEASE}" >/opt/${APP}_version.txt |     echo "${RELEASE}" >/opt/${APP}_version.txt | ||||||
|     msg_ok "Updated ${APP} to ${RELEASE}" |     msg_ok "Updated ${APP} to v${RELEASE}" | ||||||
| 
 | 
 | ||||||
|     msg_info "Starting ${APP}" |     msg_info "Starting ${APP}" | ||||||
|     systemctl start prometheus |     systemctl start prometheus | ||||||
|     msg_ok "Started ${APP}" |     msg_ok "Started ${APP}" | ||||||
|     msg_ok "Updated Successfully" |     msg_ok "Updated Successfully" | ||||||
|   else |   else | ||||||
|     msg_ok "No update required. ${APP} is already at ${RELEASE}" |     msg_ok "No update required. ${APP} is already at v${RELEASE}" | ||||||
|   fi |   fi | ||||||
|   exit |   exit | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| #!/usr/bin/env bash | #!/usr/bin/env bash | ||||||
| 
 | 
 | ||||||
| # Copyright (c) 2021-2025 tteck | # Copyright (c) 2021-2025 community-scripts ORG | ||||||
| # Author: tteck (tteckster) | # Author: tteck (tteckster) | ||||||
| # License: MIT | # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE | ||||||
| # https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE | # Source: https://prometheus.io/ | ||||||
| 
 | 
 | ||||||
| source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" | source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" | ||||||
| color | color | ||||||
| @ -14,9 +14,10 @@ network_check | |||||||
| update_os | update_os | ||||||
| 
 | 
 | ||||||
| msg_info "Installing Dependencies" | msg_info "Installing Dependencies" | ||||||
| $STD apt-get install -y curl | $STD apt-get install -y \ | ||||||
| $STD apt-get install -y sudo |   curl \ | ||||||
| $STD apt-get install -y mc |   sudo \ | ||||||
|  |   mc | ||||||
| msg_ok "Installed Dependencies" | msg_ok "Installed Dependencies" | ||||||
| 
 | 
 | ||||||
| msg_info "Installing Prometheus" | msg_info "Installing Prometheus" | ||||||
| @ -25,14 +26,13 @@ mkdir -p /etc/prometheus | |||||||
| mkdir -p /var/lib/prometheus | mkdir -p /var/lib/prometheus | ||||||
| wget -q https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz | 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 | tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz | ||||||
| cd prometheus-${RELEASE}.linux-amd64 | mv prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/ | ||||||
| mv prometheus promtool /usr/local/bin/ | mv prometheus-${RELEASE}.linux-amd64/prometheus.yml /etc/prometheus/prometheus.yml | ||||||
| mv prometheus.yml /etc/prometheus/prometheus.yml |  | ||||||
| echo "${RELEASE}" >/opt/${APPLICATION}_version.txt | echo "${RELEASE}" >/opt/${APPLICATION}_version.txt | ||||||
| msg_ok "Installed Prometheus" | msg_ok "Installed Prometheus" | ||||||
| 
 | 
 | ||||||
| msg_info "Creating Service" | msg_info "Creating Service" | ||||||
| service_path="/etc/systemd/system/prometheus.service" | cat <<EOF >/etc/systemd/system/prometheus.service" | ||||||
| echo "[Unit] | echo "[Unit] | ||||||
| Description=Prometheus | Description=Prometheus | ||||||
| Wants=network-online.target | Wants=network-online.target | ||||||
| @ -49,7 +49,8 @@ ExecStart=/usr/local/bin/prometheus \ | |||||||
| ExecReload=/bin/kill -HUP \$MAINPID | ExecReload=/bin/kill -HUP \$MAINPID | ||||||
| 
 | 
 | ||||||
| [Install] | [Install] | ||||||
| WantedBy=multi-user.target" >$service_path | WantedBy=multi-user.target" | ||||||
|  | EOF | ||||||
| systemctl enable -q --now prometheus | systemctl enable -q --now prometheus | ||||||
| msg_ok "Created Service" | msg_ok "Created Service" | ||||||
| 
 | 
 | ||||||
| @ -59,5 +60,5 @@ customize | |||||||
| msg_info "Cleaning up" | msg_info "Cleaning up" | ||||||
| $STD apt-get -y autoremove | $STD apt-get -y autoremove | ||||||
| $STD apt-get -y autoclean | $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" | msg_ok "Cleaned" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Andy Grunwald
						Andy Grunwald