diff --git a/gp-scripts/ssacli-helper.sh b/gp-scripts/ssacli-helper.sh index 8cb5281..a3e5957 100644 --- a/gp-scripts/ssacli-helper.sh +++ b/gp-scripts/ssacli-helper.sh @@ -1,5 +1,4 @@ #!/bin/bash - if ! [ "${LOGNAME}" == "root" ]; then echo "Please run this script as root or with sudo..." exit 1 @@ -23,7 +22,10 @@ Usage: $1 [OPTION] Mandatory: Optionial: - -f|--free-space FREE_SPACE How many free space do the arrays provide + -a|--array-info ARRAY_INFO Info about arrays and how much free + space they provide + -l|--ld LD_INFO Info about logical drives + -p|--pd PD_INFO Info about physical drives HELP exit 0 @@ -35,15 +37,49 @@ get_controllers() { get_array_free_space() { for CONTROLLER in ${CONTROLLERS}; do + header2 "Controller slot=${CONTROLLER}" ssacli ctrl slot=${CONTROLLER} array all show | sed -e '/^$/d' + echo "" done } +get_logical_drives() { + for CONTROLLER in ${CONTROLLERS}; do + header2 "Controller slot=${CONTROLLER}" + ssacli ctrl slot=${CONTROLLER} ld all show | sed -e '/^$/d' + echo "" + done + +} + +get_physical_drives() { + for CONTROLLER in ${CONTROLLERS}; do + header2 "Controller slot=${CONTROLLER}" + ssacli ctrl slot=${CONTROLLER} pd all show | sed -e '/^$/d' + echo "" + done + +} + +header1() { +cat << HEADER1 +################################################################################ +# ${@} +################################################################################ +HEADER1 +} + +header2() { +cat << HEADER2 +# ${@} +HEADER2 +} + ################################################################################ # Argument parser ################################################################################ die() { - printf '%s\n' "$1" >&2 +printf '%s\n' "$1" >&2 exit 1 } @@ -53,9 +89,14 @@ while :; do show_help # Display a usage synopsis. exit ;; - -f|--free-space) - FREE_SPACE=true - shift + -a|--array-info) + ARRAY_INFO=true + ;; + -l|--ld) + LD_INFO=true + ;; + -p|--pd) + PD_INFO=true ;; --) # End of all options. shift @@ -64,7 +105,6 @@ while :; do *) # Default case: No more options, so break out of the loop. break esac - shift done @@ -72,12 +112,25 @@ done ################################################################################ # Main Main Main ################################################################################ - if ! get_controllers; then echo "Could not get list of controllers..." exit 1 fi -if [ "${FREE_SPACE}" == "true" ]; then +if [ "${ARRAY_INFO}" == "true" ]; then + header1 "Array Infos" get_array_free_space -fi \ No newline at end of file + echo "" +fi + +if [ "${LD_INFO}" == "true" ]; then + header1 "Logical Drive Infos" + get_logical_drives + echo "" +fi + +if [ "${PD_INFO}" == "true" ]; then + header1 "Physical Drive Infos" + get_physical_drives + echo "" +fi