Compare commits

..

No commits in common. "d51a8df90f611e9e2aff52cc090f93c946fe39cc" and "2ca3e77bea73561c70c088fa731cf7435c0e0963" have entirely different histories.

5 changed files with 29 additions and 32 deletions

View File

@ -2,14 +2,6 @@
# Change Log # Change Log
All notable changes to this project will be documented in this file. 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 ## 2023-04-28
### Changed ### Changed

View File

@ -375,9 +375,6 @@ install_script() {
ssh_check ssh_check
arch_check arch_check
pve_check pve_check
if systemctl is-active -q ping-instances.service; then
systemctl stop ping-instances.service
fi
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
timezone=$(cat /etc/timezone) timezone=$(cat /etc/timezone)
header_info header_info
@ -511,7 +508,4 @@ description() {
pct set "$CTID" -description "# ${APP} LXC pct set "$CTID" -description "# ${APP} LXC
### https://tteck.github.io/Proxmox/ ### 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>" <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
} }

View File

@ -6,8 +6,8 @@
# https://github.com/tteck/Proxmox/raw/main/LICENSE # https://github.com/tteck/Proxmox/raw/main/LICENSE
function header_info() { function header_info() {
clear clear
cat <<"EOF" cat <<"EOF"
________ __ _ ________ ________ __ _ ________
/ ____/ /__ ____ _____ / / | |/ / ____/ / ____/ /__ ____ _____ / / | |/ / ____/
/ / / / _ \/ __ `/ __ \ / / | / / / / / / _ \/ __ `/ __ \ / / | / /
@ -34,6 +34,7 @@ while true; do
esac esac
done done
clear clear
containers=$(pct list | tail -n +2 | cut -f1 -d' ')
function clean_container() { function clean_container() {
container=$1 container=$1
header_info header_info
@ -42,7 +43,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" 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 $(pct list | awk '{if(NR>1) print $1}'); do for container in $containers; do
os=$(pct config "$container" | awk '/^ostype/ {print $2}') os=$(pct config "$container" | awk '/^ostype/ {print $2}')
if [ "$os" != "debian" ] && [ "$os" != "ubuntu" ]; then if [ "$os" != "debian" ] && [ "$os" != "ubuntu" ]; then
header_info header_info
@ -52,16 +53,16 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do
fi fi
status=$(pct status $container) status=$(pct status $container)
template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") template=$(pct config $container | grep -q "template:" && echo "true" || echo "false")
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
pct start $container pct start $container
echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n"
sleep 5 sleep 5
clean_container $container clean_container $container
echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n" echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n"
pct shutdown $container & pct shutdown $container &
elif [ "$status" == "status: running" ]; then elif [ "$status" == "status: running" ]; then
clean_container $container clean_container $container
fi fi
done done
wait wait

View File

@ -4,6 +4,8 @@
# Author: tteck (tteckster) # Author: tteck (tteckster)
# License: MIT # License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE # 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 clear
cat <<"EOF" cat <<"EOF"
@ -30,9 +32,17 @@ echo '#!/usr/bin/env bash
excluded_instances=("$@") excluded_instances=("$@")
echo "Excluded instances: ${excluded_instances[@]}" echo "Excluded instances: ${excluded_instances[@]}"
while true; do 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)")
for instance in $(pct list | awk '\''{if(NR>1) print $1}'\''; qm list | awk '\''{if(NR>1) print $1}'\''); do # Combine the container and virtual machine lists
all_instances="$containers $virtual_machines"
for instance in $all_instances
do
# Skip excluded instances # Skip excluded instances
if [[ " ${excluded_instances[@]} " =~ " ${instance} " ]]; then if [[ " ${excluded_instances[@]} " =~ " ${instance} " ]]; then
continue continue
@ -86,7 +96,7 @@ done >> /var/log/ping-instances.log 2>&1' >/usr/local/bin/ping-instances.sh
# Change file permissions to executable # Change file permissions to executable
chmod +x /usr/local/bin/ping-instances.sh chmod +x /usr/local/bin/ping-instances.sh
# Create ping-instances.service # Create ping-containers.service
echo '[Unit] echo '[Unit]
Description=Ping instances every 5 minutes and restarts if necessary Description=Ping instances every 5 minutes and restarts if necessary
@ -102,7 +112,7 @@ StandardError=file:/var/log/ping-instances.log
[Install] [Install]
WantedBy=multi-user.target' >/etc/systemd/system/ping-instances.service WantedBy=multi-user.target' >/etc/systemd/system/ping-instances.service
# Reload daemon, enable and start ping-instances.service # Reload daemon, enable and start ping-containers.service
systemctl daemon-reload systemctl daemon-reload
systemctl enable -q --now ping-instances.service systemctl enable -q --now ping-instances.service
clear clear

View File

@ -49,7 +49,7 @@ function update_container() {
esac esac
} }
header_info header_info
for container in $(pct list | awk '{if(NR>1) print $1}'); do for container in $(pct list | tail -n +2 | cut -f1 -d' '); do
excluded=false excluded=false
for excluded_container in "${excluded_containers[@]}"; do for excluded_container in "${excluded_containers[@]}"; do
if [ "$container" == "$excluded_container" ]; then if [ "$container" == "$excluded_container" ]; then