Compare commits

..

7 Commits

Author SHA1 Message Date
tteckster d51a8df90f
Update CHANGELOG.MD 2023-04-30 06:24:27 -04:00
tteckster 70ce72fcbf
Update monitor-all.sh
final tweak
2023-04-30 05:59:26 -04:00
tteckster e946f41890
Update build.func
Check if the Monitor-All service is currently active. If it is, stop the service until the creation process is complete. Once the creation process is finished, start the Monitor-All service again.
2023-04-30 05:56:05 -04:00
tteckster 465cd75015
Update monitor-all.sh
tweak
2023-04-30 04:48:05 -04:00
tteckster 1dc63002ad
Update clean-lxcs.sh
tweak
2023-04-30 04:43:52 -04:00
tteckster 15f5285120
Update monitor-all.sh
Code refactoring
2023-04-30 04:22:09 -04:00
tteckster 485444b07d
Update update-lxcs.sh
tweak
2023-04-30 04:20:16 -04:00
5 changed files with 32 additions and 29 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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