mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-09-21 11:55:53 +02:00
fix(monitor-all): reduce polling CPU overhead (#15907)
This commit is contained in:
@@ -54,18 +54,24 @@ while true; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine type and set config command
|
# Determine type and read the current config directly from Proxmox's pmxcfs.
|
||||||
if pct status $instance >/dev/null 2>&1; then
|
# Ignore snapshot sections, matching the current config shown by pct/qm config.
|
||||||
|
if [ -r "/etc/pve/lxc/$instance.conf" ]; then
|
||||||
type="ct"
|
type="ct"
|
||||||
config_cmd="pct config"
|
config_file="/etc/pve/lxc/$instance.conf"
|
||||||
else
|
else
|
||||||
type="vm"
|
type="vm"
|
||||||
config_cmd="qm config"
|
config_file="/etc/pve/qemu-server/$instance.conf"
|
||||||
fi
|
fi
|
||||||
|
config=$(sed '/^\[/,$d' "$config_file")
|
||||||
|
|
||||||
# Skip templates and onboot-disabled
|
# Skip templates and onboot-disabled
|
||||||
onboot=$($config_cmd $instance | grep -q "onboot: 0" || ( ! $config_cmd $instance | grep -q "onboot" ) && echo "true" || echo "false")
|
if grep -q "onboot: 0" <<<"$config" || ! grep -q "onboot" <<<"$config"; then
|
||||||
template=$($config_cmd $instance | grep -q "^template:" && echo "true" || echo "false")
|
onboot="true"
|
||||||
|
else
|
||||||
|
onboot="false"
|
||||||
|
fi
|
||||||
|
template=$(grep -q "^template:" <<<"$config" && echo "true" || echo "false")
|
||||||
|
|
||||||
if [ "$onboot" == "true" ]; then
|
if [ "$onboot" == "true" ]; then
|
||||||
echo "Skipping $instance because it is set not to boot"
|
echo "Skipping $instance because it is set not to boot"
|
||||||
@@ -76,7 +82,7 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for mon-restart tag
|
# Check for mon-restart tag
|
||||||
has_tag=$($config_cmd $instance | grep -q "tags:.*mon-restart" && echo "true" || echo "false")
|
has_tag=$(grep -q "tags:.*mon-restart" <<<"$config" && echo "true" || echo "false")
|
||||||
if [ "$has_tag" != "true" ]; then
|
if [ "$has_tag" != "true" ]; then
|
||||||
echo "Skipping $instance because it does not have 'mon-restart' tag"
|
echo "Skipping $instance because it does not have 'mon-restart' tag"
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user