#!/bin/bash

# Simple VM Health Monitor
# Checks if http://www.your-domain.com responds, reboots VM 105 if not

URL="http://www.your-domain.com"
VM_ID="105"

# Check if URL responds (with 10 second timeout)
if ! curl -s --connect-timeout 10 --max-time 10 "$URL" > /dev/null 2>&1; then
    echo "$(date): Service not responding, rebooting VM $VM_ID"
    qm reboot "$VM_ID" && sleep 30 && qm start "$VM_ID"
    echo "$(date): VM reboot completed"
else
    echo "$(date): Service is responding normally"
fi