39 lines
815 B
Bash
Executable file
39 lines
815 B
Bash
Executable file
#!/bin/bash
|
|
# Script Name: check-remote-disk-usage.sh
|
|
# Description:
|
|
# v1.1.0 - 2026-06-09: Require explicit paths; remove environment-specific defaults.
|
|
# v1.0.0 - 2026-06-08: Initial release.
|
|
#
|
|
# Usage:
|
|
# check-remote-disk-usage.sh -p /,/opt host1 [host2 ...]
|
|
|
|
set -euo pipefail
|
|
|
|
PATHS=""
|
|
|
|
usage() {
|
|
echo "Usage: $0 -p comma,separated,paths host1 [host2 ...]"
|
|
echo "Example: $0 -p /,/opt/data server-a server-b"
|
|
}
|
|
|
|
while getopts ":hp:" opt; do
|
|
case "$opt" in
|
|
h) usage; exit 0 ;;
|
|
p) PATHS="${OPTARG//,/$' '}" ;;
|
|
*) usage; exit 1 ;;
|
|
esac
|
|
done
|
|
shift $((OPTIND - 1))
|
|
|
|
if [ -z "${PATHS}" ] || [ "$#" -lt 1 ]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
CMD="df -h ${PATHS}"
|
|
|
|
for host in "$@"; do
|
|
echo "Host: ${host}"
|
|
ssh "${host}" "${CMD}"
|
|
echo "---------------------------------------------------"
|
|
done
|