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)"Menu
| Entry | What it does |
|---|---|
Add | Explains the tag requirement, asks "This script will add Monitor All to Proxmox VE. Proceed (y/n)?" and installs and starts the service. |
Remove | Stops and disables the service and deletes its files. No confirmation. |
| Cancel | Prints "Exiting..." and exits. |
Mark guests for monitoring
pct set <ctid> -tags mon-restart
qm set <vmid> -tags mon-restartpct 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), onbootis not1,- it is a template,
- it does not have the tag
mon-restart(the whole tag must match).
For the rest:
| Guest | Check | Reaction |
|---|---|---|
| VM, not running | qm status | qm start |
| VM, running | qm guest cmd <id> ping | On failure: qm stop, wait 5 seconds, qm start |
| Container, not running | pct status | pct start |
| Container, running | One ping to the first IPv4 address from lxc-info -n <id> -iH that is not loopback or link-local | On 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
| Path | Purpose |
|---|---|
/usr/local/bin/ping-instances.sh | The monitoring loop. |
/etc/systemd/system/ping-instances.service | Service, enabled and started by Add. Restart=always. |
/var/log/ping-instances.log | Log. |
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-instancesTo exclude guests, append their IDs to ExecStart, as the comment in the unit file shows:
ExecStart=/usr/local/bin/ping-instances.sh 100 200Undo
Run the script again and choose Remove. It deletes the service, the timer, the script and the log.
Environment variables
| Variable | Default | Purpose |
|---|---|---|
COMMUNITY_SCRIPTS_CORE_URL | https://raw.githubusercontent.com/community-scripts/core/main | Base 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 stopandpct stopare 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
Addagain overwrites the script and the unit file, including exclusions you added.