mirror of https://github.com/tteck/Proxmox.git
Compare commits
7 Commits
2ca3e77bea
...
d51a8df90f
Author | SHA1 | Date |
---|---|---|
|
d51a8df90f | |
|
70ce72fcbf | |
|
e946f41890 | |
|
465cd75015 | |
|
1dc63002ad | |
|
15f5285120 | |
|
485444b07d |
|
@ -2,6 +2,14 @@
|
|||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 2023-04-30
|
||||
|
||||
### Changed
|
||||
|
||||
- **Proxmox VE Monitor-All**
|
||||
- NEW Script
|
||||
- Replaces Proxmox VE LXC Monitor
|
||||
|
||||
## 2023-04-28
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -375,6 +375,9 @@ install_script() {
|
|||
ssh_check
|
||||
arch_check
|
||||
pve_check
|
||||
if systemctl is-active -q ping-instances.service; then
|
||||
systemctl stop ping-instances.service
|
||||
fi
|
||||
NEXTID=$(pvesh get /cluster/nextid)
|
||||
timezone=$(cat /etc/timezone)
|
||||
header_info
|
||||
|
@ -508,4 +511,7 @@ description() {
|
|||
pct set "$CTID" -description "# ${APP} LXC
|
||||
### https://tteck.github.io/Proxmox/
|
||||
<a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-red' /></a>"
|
||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||
systemctl start ping-instances.service
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||
|
||||
function header_info() {
|
||||
clear
|
||||
cat <<"EOF"
|
||||
clear
|
||||
cat <<"EOF"
|
||||
________ __ _ ________
|
||||
/ ____/ /__ ____ _____ / / | |/ / ____/
|
||||
/ / / / _ \/ __ `/ __ \ / / | / /
|
||||
|
@ -34,7 +34,6 @@ while true; do
|
|||
esac
|
||||
done
|
||||
clear
|
||||
containers=$(pct list | tail -n +2 | cut -f1 -d' ')
|
||||
function clean_container() {
|
||||
container=$1
|
||||
header_info
|
||||
|
@ -43,7 +42,7 @@ function clean_container() {
|
|||
pct exec $container -- bash -c "apt-get -y --purge autoremove && apt-get -y autoclean && bash <(curl -fsSL https://github.com/tteck/Proxmox/raw/main/misc/clean.sh) && rm -rf /var/lib/apt/lists/* && apt-get update"
|
||||
}
|
||||
|
||||
for container in $containers; do
|
||||
for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
||||
os=$(pct config "$container" | awk '/^ostype/ {print $2}')
|
||||
if [ "$os" != "debian" ] && [ "$os" != "ubuntu" ]; then
|
||||
header_info
|
||||
|
@ -53,16 +52,16 @@ for container in $containers; do
|
|||
fi
|
||||
status=$(pct status $container)
|
||||
template=$(pct config $container | grep -q "template:" && echo "true" || echo "false")
|
||||
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
|
||||
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
|
||||
pct start $container
|
||||
echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n"
|
||||
sleep 5
|
||||
clean_container $container
|
||||
echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n"
|
||||
pct shutdown $container &
|
||||
elif [ "$status" == "status: running" ]; then
|
||||
clean_container $container
|
||||
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
|
||||
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
|
||||
pct start $container
|
||||
echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n"
|
||||
sleep 5
|
||||
clean_container $container
|
||||
echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n"
|
||||
pct shutdown $container &
|
||||
elif [ "$status" == "status: running" ]; then
|
||||
clean_container $container
|
||||
fi
|
||||
done
|
||||
wait
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
# Author: tteck (tteckster)
|
||||
# License: MIT
|
||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||
# Proxmox VE LXC Monitor All
|
||||
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/monitor-all.sh)" -s add
|
||||
|
||||
clear
|
||||
cat <<"EOF"
|
||||
|
@ -32,17 +30,9 @@ echo '#!/usr/bin/env bash
|
|||
excluded_instances=("$@")
|
||||
echo "Excluded instances: ${excluded_instances[@]}"
|
||||
|
||||
while true
|
||||
do
|
||||
# Get the list of containers and virtual machines
|
||||
containers=$(pct list | tail -n +2 | cut -f1 -d" ")
|
||||
virtual_machines=$(qm list | grep -oP "^\s*\K\d+(?=\s)")
|
||||
while true; do
|
||||
|
||||
# Combine the container and virtual machine lists
|
||||
all_instances="$containers $virtual_machines"
|
||||
|
||||
for instance in $all_instances
|
||||
do
|
||||
for instance in $(pct list | awk '\''{if(NR>1) print $1}'\''; qm list | awk '\''{if(NR>1) print $1}'\''); do
|
||||
# Skip excluded instances
|
||||
if [[ " ${excluded_instances[@]} " =~ " ${instance} " ]]; then
|
||||
continue
|
||||
|
@ -96,7 +86,7 @@ done >> /var/log/ping-instances.log 2>&1' >/usr/local/bin/ping-instances.sh
|
|||
# Change file permissions to executable
|
||||
chmod +x /usr/local/bin/ping-instances.sh
|
||||
|
||||
# Create ping-containers.service
|
||||
# Create ping-instances.service
|
||||
echo '[Unit]
|
||||
Description=Ping instances every 5 minutes and restarts if necessary
|
||||
|
||||
|
@ -112,7 +102,7 @@ StandardError=file:/var/log/ping-instances.log
|
|||
[Install]
|
||||
WantedBy=multi-user.target' >/etc/systemd/system/ping-instances.service
|
||||
|
||||
# Reload daemon, enable and start ping-containers.service
|
||||
# Reload daemon, enable and start ping-instances.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable -q --now ping-instances.service
|
||||
clear
|
||||
|
|
|
@ -49,7 +49,7 @@ function update_container() {
|
|||
esac
|
||||
}
|
||||
header_info
|
||||
for container in $(pct list | tail -n +2 | cut -f1 -d' '); do
|
||||
for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
||||
excluded=false
|
||||
for excluded_container in "${excluded_containers[@]}"; do
|
||||
if [ "$container" == "$excluded_container" ]; then
|
||||
|
|
Loading…
Reference in New Issue