#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=00_env.sh . "$SCRIPT_DIR/00_env.sh" REPORT_FILE="" usage() { printf 'Usage: %s --fs \n' "$(basename "$0")" } while [[ "$#" -gt 0 ]]; do case "$1" in --fs) FILESYSTEM="${2:-}"; shift 2 ;; -h|--help) usage; exit 0 ;; *) critical "Unknown argument: $1"; usage; exit 2 ;; esac done if [[ -z "$FILESYSTEM" ]]; then critical "Missing required --fs " usage exit 2 fi REPORT_FILE="/tmp/gpfs_extend_report_${FILESYSTEM}_${TIMESTAMP}.txt" append_section() { local title="$1" shift { printf '\n== %s ==\n' "$title" if command -v "$1" >/dev/null 2>&1; then "$@" 2>&1 || printf 'WARNING: command failed: %s\n' "$*" else printf 'WARNING: command not available: %s\n' "$1" fi } >> "$REPORT_FILE" } { printf 'GPFS / Spectrum Scale Filesystem Expansion Report\n' printf 'Hostname: %s\n' "$(hostname 2>/dev/null || printf 'unknown')" printf 'Date: %s\n' "$(date)" printf 'Target filesystem: %s\n' "$FILESYSTEM" } > "$REPORT_FILE" append_section "GPFS daemon state" mmgetstate -a append_section "Cluster definition" mmlscluster append_section "Managers and quorum" mmlsmgr append_section "Target filesystem mount state" mmlsmount "$FILESYSTEM" append_section "Target filesystem disks" mmlsdisk "$FILESYSTEM" append_section "NSD inventory" mmlsnsd append_section "Filesystem capacity" df -h if command -v mmhealth >/dev/null 2>&1; then append_section "Cluster health" mmhealth cluster show else printf '\n== Cluster health ==\nWARNING: mmhealth command not available\n' >> "$REPORT_FILE" fi if command -v journalctl >/dev/null 2>&1; then append_section "Recent GPFS journal entries" journalctl -u 'gpfs*' -n 50 --no-pager fi if command -v dmesg >/dev/null 2>&1; then { printf '\n== Recent kernel messages ==\n' dmesg -T 2>/dev/null | tail -50 || printf 'WARNING: dmesg query failed\n' } >> "$REPORT_FILE" fi ok "Generated report: $REPORT_FILE"