Check those attributes!

This is a script I wrote purely from the frustutation of verifying each and every adapter/device attribute which one sets after an AIX installation. What this script does is loop through the list of user defined attributes, and verifies each and every adapter/device against them. The beauty of the script is that it’s very easy to add/modify or remove checks.

For those with any expierence in scripting or coding will understand how array’s work. The script allows you to define your own array elements to add/modify or remove checks against certain adapters/devices.

Currently, the script checks for the following:

    Virtual SCSI Adapters (vscsiX)
    Virtual FC Adapters (fscsiX)
    Hdisk Devices (hdiskX)
    VMO Values
    Number of paths to a disk (=>2)


Below is the script, and after I’ll show you how easily additional checks can be added.

#!/bin/ksh
#
# Name:
#       attrib_check.sh
#
# Description:
#       This script performs checks against attributes set
#       post AIX installation.
#
# Usage:
#       # ./attrib_check.sh
#
 
#############
# Variables #
#############
BORDER="echo ==================================================="
OK="\033[1;32mOK:\033[m"
FAIL="\033[1;31mFAIL:\033[m"
 
###############################
# Variables - Server Specific #
###############################
# Virtual SCSI attributes
vscsi[0]="vscsi_err_recov,fast_fail"
vscsi[1]="vscsi_path_to,30"
# Virtual FC attributes
fscsi[0]="dyntrk,yes"
fscsi[1]="fc_err_recov,fast_fail"
# hdisk attributes
hdisk[0]="hcheck_interval,60"
hdisk[1]="queue_depth,32"
# VMO
vmo[0]="lru_file_repage,0"
vmo[1]="strict_maxperm,0"
vmo[2]="strict_maxclient,1"
vmo[3]="maxperm%,90"
vmo[4]="minperm%,5"
vmo[5]="maxclient%,90"
 
 
 
########
# Main #
########
 
# Verify disk adapter attributes
$BORDER
echo "=> Verify disk adapter attributes"
$BORDER
 
## Check vscsi adapter attributes
echo "Virtual SCSI Adapter Attributes"
echo "-------------------------------"
lsdev | grep vscsi > /dev/null 2>&1
if [ $? -eq 0 ]; then
  echo "Server contains vscsi adapters with the following attributes:"
    for vscsi_adapter in `lsdev | grep vscsi | awk '{ print $1 }'`; do
     echo "${vscsi_adapter}:"
     count=0
       while (( $count < ${#vscsi[*]} )); do
          VSCSI_VAR1=`echo ${vscsi[$count]} | awk -F , '{ print $1 }'`
          VSCSI_VAR2=`echo ${vscsi[$count]} | awk -F , '{ print $2 }'`
 
          VSCSI_CURRENT=`lsattr -l $vscsi_adapter -a $VSCSI_VAR1 -E | awk '{ print $2 }'`
 
          if [ "$VSCSI_CURRENT" != "$VSCSI_VAR2" ]; then
            echo "   $FAIL $VSCSI_VAR1 must be set to \"$VSCSI_VAR2\""
            let count="count + 1"
          else
            echo "   $OK $VSCSI_VAR1 = $VSCSI_VAR2"
            let count="count + 1"
          fi
       done
    done
else
   echo "Server does not contain any vscsi adapters"
fi
 
 
## Check fc adapter attributes
echo "\n"
echo "Virtual FC Adapter Attributes"
echo "-----------------------------"
lsdev | grep fscsi > /dev/null 2>&1
if [ $? -eq 0 ]; then
  echo "Server contains fscsi adapters with the following attributes:"
    for fscsi_adapter in `lsdev | grep fscsi | awk '{ print $1 }'`; do
     echo "${fscsi_adapter}:"
     count=0
       while (( $count < ${#fscsi[*]} )); do
          FSCSI_VAR1=`echo ${fscsi[$count]} | awk -F , '{ print $1 }'`
          FSCSI_VAR2=`echo ${fscsi[$count]} | awk -F , '{ print $2 }'`
 
          FSCSI_CURRENT=`lsattr -l $fscsi_adapter -a $FSCSI_VAR1 -E | awk '{ print $2 }'`
 
          if [ "$FSCSI_CURRENT" != "$FSCSI_VAR2" ]; then
            echo "   $FAIL $FSCSI_VAR1 must be set to \"$FSCSI_VAR2\""
            let count="count + 1"
          else
            echo "   $OK $FSCSI_VAR1 = $FSCSI_VAR2"
            let count="count + 1"
          fi
       done
    done
else
   echo "Server does not contain any fscsi adapters"
fi
 
 
 
# Verify hdisks
echo "\n\n"
$BORDER
echo "=> Verify hdisk attributes"
$BORDER
 
## Check hdisk attributes
echo "hdisk attributes"
echo "----------------"
    for pv in `lspv | grep hdisk | awk '{ print $1 }'`; do
     echo "${pv}:"
     count=0
       while (( $count < ${#hdisk[*]} )); do
          HDISK_VAR1=`echo ${hdisk[$count]} | awk -F , '{ print $1 }'`
          HDISK_VAR2=`echo ${hdisk[$count]} | awk -F , '{ print $2 }'`
 
          HDISK_CURRENT=`lsattr -l $pv -a $HDISK_VAR1 -E | awk '{ print $2 }'`
 
          if [ "$HDISK_CURRENT" != "$HDISK_VAR2" ]; then
            echo "   $FAIL $HDISK_VAR1 must be set to \"$HDISK_VAR2\""
            let count="count + 1"
          else
            echo "   $OK $HDISK_VAR1 = $HDISK_VAR2"
            let count="count + 1"
          fi
       done
    done
 
 
 
## Check number of path's to disk
echo "\n"
echo "Disk paths"
echo "----------"
for hdisk in `lspv | grep hdisk | awk '{ print $1 }'`; do
      PATHS=`lspath -l $hdisk | wc -l | sed 's,^ *,,'`
 
      if [ $PATHS -lt 2 ]; then
        echo "${hdisk}:"
        echo "   $FAIL There is only $PATHS path to the disk"
      else
        echo "${hdisk}:"
        echo "   $OK Paths to disk = $PATHS"
      fi
done
 
 
# Check VMO settings
echo "\n\n"
$BORDER
echo "=> Check VMO settings"
$BORDER
 
count=0
  while (( $count < ${#vmo[*]} )); do
   VMO_VAR1=`echo ${vmo[$count]} | awk -F , '{ print $1 }'`
   VMO_VAR2=`echo ${vmo[$count]} | awk -F , '{ print $2 }'`
 
   VMO_CURRENT=`vmo -x $VMO_VAR1 | awk -F , '{ print $4 }'`
 
    if [ "$VMO_CURRENT" != "$VMO_VAR2" ]; then
      echo "   $FAIL $VMO_VAR1 must be set to \"$VMO_VAR2\""
      let count="count + 1"
    else
      echo "   $OK $VMO_VAR1 = $VMO_VAR2"
      let count="count + 1"
    fi
  done
 
echo "\n\n\n"
 
exit

So, let’s add another check.
For example, by default, the follow hdisk attributes are checked.

    hcheck_interval = 60
    queue_depth = 32

If you wanted to add an aditional check, say the hcheck_mode attribute, all you need to do is add another element into the array.

hdisk[0]="hcheck_interval,60"
hdisk[1]="queue_depth,32"
hdisk[2]="hcheck_mode,nonactive"

Line #3 shows the additional check. Just make sure you increase the array element id by one.

It’s pretty trivial to add other checks, say for ioo or no. You’ll just need to look at the current code blocks and add further ones. Or just leave a comment on this page and I can add them for you.

The following image shows the script running against a host where all attibutes validate.

The following image shows the script running against a host where some failures were detected.

I guess this script could even be modified to actually make the changes to those adapters/devices for you. Quite easily in fact…so if anyone is interested in something like that, let me know and I’ll throw something together.

As always, use/abuse/mock and enjoy.

Leave a Reply

Your email address will not be published. Required fields are marked *


*