Watch and Reboot is a lightweight Python script, watchdog and remediation tool designed for MeshMonitor and Meshstatic based deployments.
It can:
- Watch a target device by IP (ping + optional SSH)
- Watch a Meshtastic node reached via a BLE bridge TCP proxy (e.g., Yeraze/meshtastic-ble-bridge)
- Automatically remediate by:
- Restarting the BLE bridge (systemd or docker/compose)
- Restarting MeshMonitor (systemd or docker/compose)
- Rebooting the actual target device (via SSH + shutdown -r now)
- Emit “unhealthy”, “action”, and “recovered” events via:
- MQTT (mosquitto_pub)
- Webhook (curl)
- Optional Meshtastic text message (via meshtastic Python library)
It is:
- Cron-friendly
- Capability-aware
- Cooldown-protected (prevents reboot storms)
- Self-contained (replaces prior MeshTools scripts)
This capability originally existed as an internal MeshTools script set.
v2.0 is the simplified public release:
- Single executable script
- No dependency on external management scripts
- Cleaner remediation order
- Safer defaults
- Easier to deploy across nodes
This tool replaces previous management helpers such as:
- meshmonitor-manage.sh
- meshtastic-manage.sh
Everything is now unified into:
meshmonitor-watchandreboot
Copy the script to:
/usr/local/sbin/meshmonitor-watchandreboot
Then make it executable:
sudo chmod +x /usr/local/sbin/meshmonitor-watchandreboot
meshmonitor-watchandreboot status
IP mode:
meshmonitor-watchandreboot watch-once 10.0.0.10 --mode ip --user pi
BLE bridge mode:
meshmonitor-watchandreboot watch-once bridge-host --mode ble --ble-bridge-host 127.0.0.1 --ble-bridge-port 4403
Health check:
- ping
- ssh
Default remediation order:
- Restart MeshMonitor (optional)
- Reboot device (if allowed)
Use this for:
- Raspberry Pi nodes
- SDR feeders
- Remote Linux boxes
- Field repeaters
Health check:
- TCP connect to bridge_host:port (default 127.0.0.1:4403)
Default remediation order:
- Restart BLE bridge
- Restart MeshMonitor
- Reboot host
Use this for:
- Meshtastic nodes accessed via BLE bridge
- USB-attached radios
- Adapter instability recovery
Run every 5 minutes:
*/5 * * * * /usr/local/sbin/meshmonitor-watchandreboot watch-once 10.0.0.10 --mode ip --user pi
Watch BLE bridge every 2 minutes:
*/2 * * * * /usr/local/sbin/meshmonitor-watchandreboot watch-once bridge-host --mode ble --ble-bridge-restart-mode local
All configuration can be done via environment variables.
MM_MODE=ip|ble
MM_TARGET_HOST=10.0.0.10
MM_REMOTE_USER=pi
MM_SSH_PORT=22
MM_FAIL_THRESHOLD=3
MM_COOLDOWN_SECONDS=1800
MM_RECOVERY_TIMEOUT=600
MM_CHECK_INTERVAL=20
MM_REQUIRE_PING=1
MM_REQUIRE_SSH=1
MM_RESTART_MODE=local|remote|off
MM_SYSTEMD_SERVICE=meshmonitor
MM_COMPOSE_DIR=/opt/meshmonitor
MM_CONTAINER_NAME=meshmonitor
MM_BLE_BRIDGE_HOST=127.0.0.1
MM_BLE_BRIDGE_PORT=4403
MM_BLE_BRIDGE_RESTART_MODE=local|remote|off
MM_BLE_BRIDGE_SYSTEMD_SERVICE=
MM_BLE_BRIDGE_COMPOSE_DIR=/opt/meshmonitor
MM_BLE_BRIDGE_CONTAINER_NAME=meshmonitor-ble-bridge
MM_ALLOW_REBOOT=1
Set to 0 if you want restart-only behavior.
MM_MQTT_HOST=10.0.0.5
MM_MQTT_PORT=1883
MM_MQTT_TOPIC_PREFIX=meshwatch
MM_WEBHOOK_URL=https://example.com/webhook
MM_NOTIFY_CMD=echo "{EVENT} {HOST} {DETAILS}"
Requires Python meshtastic library installed.
MM_MESHTASTIC_NOTIFY=1
MM_MESHTASTIC_TEXT=Recovered: {HOST} is back online
MM_MESHTASTIC_TCP_HOST=127.0.0.1
MM_MESHTASTIC_TCP_PORT=4403
MM_MESHTASTIC_SERIAL=/dev/ttyUSB0
MM_MESHTASTIC_DEST=
If MM_MESHTASTIC_DEST is empty, it broadcasts.
This tool can:
- Restart services
- Restart containers
- Execute remote SSH commands
- Reboot devices
Best practices:
- Use SSH keys (BatchMode)
- Restrict sudo permissions
- Keep cooldown enabled
- Avoid very low fail thresholds
- Prefer private/VPN networks
Cooldown prevents reboot storms.
- KISS (Keep It Simple)
- Capability-aware
- Infrastructure-safe defaults
- Replace multiple scripts with one unified tool
- MeshMonitor-native thinking
Default locations:
State: /var/tmp/meshmonitor-watchandreboot
Log: /var/log/meshmonitor-watchandreboot.log
Falls back to state directory if /var/log is not writable.
This project is licensed under the MIT License.
See the LICENSE file for details.
Full license text: https://opensource.org/licenses/MIT
Pull requests are welcome. Open an issue first to discuss ideas or report bugs.
- MeshMonitor built by Yeraze
Discover other community-contributed scripts for MeshMonitor: https://meshmonitor.org/user-scripts.html
