```bash
#!/usr/bin/env bash
#
# disk_monitor.sh
#
# A production-quality bash script to monitor disk usage on a specific mountpoint.
# It checks if the usage percentage exceeds a configurable threshold and logs
# warnings accordingly.
#
# Usage:
#   ./disk_monitor.sh [-t threshold] [-m mountpoint] [-h]
#
# Options:
#   -t threshold   Set the warning threshold percentage (default: 80)
#   -m mountpoint  Set the target mountpoint to monitor (default: /)
#   -h             Show this help message
#
# Exit Codes:
#   0 - OK (usage below threshold)
#   1 - WARNING (usage at or above threshold)
#   2 - ERROR (script execution error, e.g., invalid input or df failure)
#
# Author: Assistant
# Date: 2023-10-27

set -euo pipefail

# Default configuration
THRESHOLD=80
MOUNTPOINT="/"
LOG_FILE=""

# Function to print usage/help
usage() {
    cat <<EOF
Usage: $(basename "$0") [-t threshold] [-m mountpoint] [-h]

Options:
  -t threshold   Set the warning threshold percentage (default: 80)
  -m mountpoint  Set the target mountpoint to monitor (default: /)
  -h             Show this help message

Exit Codes:
  0 - OK (usage below threshold)
  1 - WARNING (usage at or above threshold)
  2 - ERROR (script execution error)
EOF
}

# Function to log messages with ISO-8601 timestamp
log_message() {
    local level="$1"
    local message="$2"
    local timestamp
    timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
    local log_entry="${timestamp} [${level}] ${message}"

    # Try to write to /var/log/disk_monitor.log first
    if [[ -w "/var/log/disk_monitor.log" ]]; then
        echo "$log_entry" >> "/var/log/disk_monitor.log"
    else
        # Fallback to local file if permission denied or file doesn't exist
        local fallback_log="./disk_monitor.log"
        echo "$log_entry" >> "$fallback_log"
    fi
}

# Parse command line arguments
while getopts ":t:m:h" opt; do
    case ${opt} in
        t )
            if ! [[ "$OPTARG" =~ ^[0-9]+$ ]]; then
                echo "Error: Threshold must be an integer." >&2
                usage
                exit 2
            fi
            THRESHOLD="$OPTARG"
            ;;
        m )
            MOUNTPOINT="$OPTARG"
            ;;
        h )
            usage
            exit 0
            ;;
        \? )
            echo "Invalid option: -$OPTARG" >&2
            usage
            exit 2
            ;;
        : )
            echo "Option -$OPTARG requires an argument." >&2
            usage
            exit 2
            ;;
    esac
done

# Validate mountpoint exists
if ! mountpoint -q "$MOUNTPOINT" 2>/dev/null; then
    # If mountpoint command is not available or fails, try df
    if ! df "$MOUNTPOINT" >/dev/null 2>&1; then
        log_message "ERROR" "Mountpoint '$MOUNTPOINT' does not exist or is not accessible."
        echo "Error: Mountpoint '$MOUNTPOINT' does not exist or is not accessible." >&2
        exit 2
    fi
fi

# Get disk usage percentage using df
# -P ensures POSIX output format for easier parsing
# We extract the Use% column (5th column) and remove the '%' sign
usage_percent=$(df -P "$MOUNTPOINT" | awk 'NR==2 {print $5}' | tr -d '%')

# Check if df command succeeded and returned a valid number
if [[ -z "$usage_percent" ]] || ! [[ "$usage_percent" =~ ^[0-9]+$ ]]; then
    log_message "ERROR" "Failed to retrieve disk usage for '$MOUNTPOINT'."
    echo "Error: Failed to retrieve disk usage for '$MOUNTPOINT'." >&2
    exit 2
fi

# Compare usage with threshold
if (( usage_percent >= THRESHOLD )); then
    log_message "WARNING" "Disk usage on '$MOUNTPOINT' is ${usage_percent}%, which is >= threshold ${THRESHOLD}%."
    echo "WARNING: Disk usage on '$MOUNTPOINT' is ${usage_percent}% (threshold: ${THRESHOLD}%)"
    exit 1
else
    log_message "INFO" "Disk usage on '$MOUNTPOINT' is ${usage_percent}%, which is < threshold ${THRESHOLD}%."
    echo "OK: Disk usage on '$MOUNTPOINT' is ${usage_percent}% (threshold: ${THRESHOLD}%)"
    exit 0
fi
```