Add Veritas VxVM and VCS storage expansion toolkit
This commit is contained in:
+94
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=00_env.sh
|
||||
source "$SCRIPT_DIR/00_env.sh"
|
||||
|
||||
parse_common_args "$@"
|
||||
require_inputs sg dg vol mount
|
||||
|
||||
missing=0
|
||||
for cmd in hastatus hagrp hares vxdisk vxdg vxprint df findmnt; do
|
||||
require_cmd "$cmd" || missing=1
|
||||
done
|
||||
|
||||
if (( missing != 0 )); then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
status=0
|
||||
ok "Precheck started for service group '$SERVICE_GROUP', diskgroup '$DISKGROUP', volume '$VOLUME'"
|
||||
log "INFO" "log file: $LOG_FILE"
|
||||
|
||||
if hastatus -sum >/dev/null 2>&1; then
|
||||
ok "VCS status is available"
|
||||
else
|
||||
critical "VCS does not appear to be running or hastatus failed"
|
||||
status=1
|
||||
fi
|
||||
|
||||
if hagrp -display "$SERVICE_GROUP" >/dev/null 2>&1; then
|
||||
ok "service group exists: $SERVICE_GROUP"
|
||||
else
|
||||
critical "service group not found: $SERVICE_GROUP"
|
||||
status=1
|
||||
fi
|
||||
|
||||
group_state="$(hagrp -state "$SERVICE_GROUP" 2>/dev/null || true)"
|
||||
printf '%s\n' "$group_state" | tee -a "$LOG_FILE"
|
||||
if printf '%s\n' "$group_state" | grep -qi "ONLINE"; then
|
||||
ok "service group is online"
|
||||
else
|
||||
critical "service group is not online"
|
||||
status=1
|
||||
fi
|
||||
|
||||
online_node="$(printf '%s\n' "$group_state" | awk '/ONLINE/ {print $NF; exit}')"
|
||||
if [[ -n "$online_node" ]]; then
|
||||
ok "possible online node: $online_node"
|
||||
else
|
||||
warning "unable to identify online node from hagrp output"
|
||||
fi
|
||||
|
||||
if vxdg list "$DISKGROUP" >/dev/null 2>&1; then
|
||||
ok "diskgroup exists: $DISKGROUP"
|
||||
else
|
||||
critical "diskgroup not found: $DISKGROUP"
|
||||
status=1
|
||||
fi
|
||||
|
||||
if vxprint -g "$DISKGROUP" "$VOLUME" >/dev/null 2>&1; then
|
||||
ok "volume exists: $VOLUME"
|
||||
else
|
||||
critical "volume not found in diskgroup: $VOLUME"
|
||||
status=1
|
||||
fi
|
||||
|
||||
if findmnt --target "$MOUNTPOINT" >/dev/null 2>&1; then
|
||||
ok "mountpoint is mounted: $MOUNTPOINT"
|
||||
fs_type="$(findmnt --noheadings --output FSTYPE --target "$MOUNTPOINT" | awk 'NR == 1 {print $1}')"
|
||||
ok "filesystem type: ${fs_type:-unknown}"
|
||||
else
|
||||
critical "mountpoint is not mounted: $MOUNTPOINT"
|
||||
status=1
|
||||
fi
|
||||
|
||||
capture_cmd "Current filesystem usage" df -h "$MOUNTPOINT" || status=1
|
||||
capture_cmd "Current VxVM layout" vxprint -g "$DISKGROUP" -ht || status=1
|
||||
capture_cmd "Current VCS service group display" hagrp -display "$SERVICE_GROUP" || status=1
|
||||
if hares -display 2>/dev/null | grep -F "$SERVICE_GROUP" | tee -a "$LOG_FILE"; then
|
||||
ok "displayed VCS resources related to service group: $SERVICE_GROUP"
|
||||
else
|
||||
warning "no VCS resource display rows matched service group: $SERVICE_GROUP"
|
||||
fi
|
||||
|
||||
if (( status == 0 )); then
|
||||
ok "precheck completed successfully"
|
||||
else
|
||||
critical "precheck found one or more issues"
|
||||
fi
|
||||
|
||||
exit "$status"
|
||||
Reference in New Issue
Block a user