Skip to main content
Community Scripts logo
Skip to Content
Tools & Add-onsPVE Tools

PVE Monitor-All

Install a systemd service that restarts tagged containers and VMs when they stop responding.

monitor-all.sh installs a service on the host that checks guests every five minutes and starts or restarts the ones that are down or unresponsive. Only guests with the tag mon-restart and onboot: 1 are watched.

Website entry: monitor-all. Source: tools/pve/monitor-all.sh.

Run

In the Proxmox VE host shell, as root:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/monitor-all.sh)"
EntryWhat it does
AddExplains the tag requirement, asks "This script will add Monitor All to Proxmox VE. Proceed (y/n)?" and installs and starts the service.
RemoveStops and disables the service and deletes its files. No confirmation.
CancelPrints "Exiting..." and exits.

Mark guests for monitoring

pct set <ctid> -tags mon-restart
qm set <vmid> -tags mon-restart

pct set and qm set replace the whole tag list, so include the tags a guest already has, separated by ;. In the web interface, add the tag to the guest's tag list instead.

How a guest is checked

The service loops over all IDs from pct list and qm list and skips a guest when:

  • its ID was passed as an argument to ping-instances.sh (excluded, see below),
  • onboot is not 1,
  • it is a template,
  • it does not have the tag mon-restart (the whole tag must match).

For the rest:

GuestCheckReaction
VM, not runningqm statusqm start
VM, runningqm guest cmd <id> pingOn failure: qm stop, wait 5 seconds, qm start
Container, not runningpct statuspct start
Container, runningOne ping to the first IPv4 address from lxc-info -n <id> -iH that is not loopback or link-localOn failure or when no address is found: pct stop, wait 5 seconds, pct start

After each pass the service sleeps for 300 seconds.

Files and service

PathPurpose
/usr/local/bin/ping-instances.shThe monitoring loop.
/etc/systemd/system/ping-instances.serviceService, enabled and started by Add. Restart=always.
/var/log/ping-instances.logLog.

Add also removes /etc/systemd/system/ping-instances.timer if an older version installed it.

Change the setup

systemctl stop ping-instances
nano /usr/local/bin/ping-instances.sh              # pause time: sleep 300
nano /etc/systemd/system/ping-instances.service    # exclusions
systemctl daemon-reload
systemctl start ping-instances

To exclude guests, append their IDs to ExecStart, as the comment in the unit file shows:

ExecStart=/usr/local/bin/ping-instances.sh 100 200

Undo

Run the script again and choose Remove. It deletes the service, the timer, the script and the log.

Environment variables

VariableDefaultPurpose
COMMUNITY_SCRIPTS_CORE_URLhttps://raw.githubusercontent.com/community-scripts/core/mainBase URL the installer loads api/api.func from.

Limits

  • A VM without a running QEMU guest agent never answers the ping and is restarted every five minutes. Do not tag such VMs.
  • qm stop and pct stop are hard stops, not clean shutdowns.
  • A container that blocks ICMP, or that has no IPv4 address yet, counts as unresponsive.
  • Stop the service (systemctl stop ping-instances) before maintenance on a tagged guest, otherwise it is started again.
  • Running Add again overwrites the script and the unit file, including exclusions you added.