User Tools

Site Tools


aix:scripts_tuning_devices

Change devices parameters for tuning

This script can be executed on LPAR, and also on root, without argument, it's just a preview. With '-f' it will FIX all changes, it possible it's directly applied, else at the end it report all parameters currently set that will be changed after the reboot.

Environment variables

Centralize variables for all scripts: .env file

# global variables for all scripts
export binpath=/root/script/bin
export sn=`basename $0 | cut -d. -f1`
export HOSTNAME=`hostname`
export logpath=/root/script/log
export logname=$logpath/$sn.log
export configfile=$binpath/$sn.cfg
export destination="test@test.com"

File_name

change_devices_param.sh

Change disks and adapter settings:

#!/bin/ksh93
#set -x
#############################################
#@(#) Change disk and adapter attribute on a host
#############################################
# check if a disk on LPAR has the same path
# version 1.0 08-04-2010 Manu
# version 1.1 21-09-2015
#############################################

dir=`dirname $0`
. $dir/.env

#------------------------------------------------
# usage ()
#------------------------------------------------
usage()
{
echo "Usage: (" "|-v|-f)"
echo "\tChange disks and adapter parameters on LPAR or VIOS if needed"
echo "\tFirst try to change, if not succeed, change to ODM only"
echo "\t-v: verbose (default yes)"
echo "\t-f: fix correct parameter (default no)"
}

#------------------------------------------------
# chhostval ()
# try to change a value on a device, if it
# doesn't succeed, then change in ODM only
#------------------------------------------------
chhostval()
{
dev=$1
attr=$2
val=$3
difference=$4

if [ ${#} -ne 4 ]
then
  difference="equal"
fi

val1=$(echo $val | sed 's/^0x//')

value=$(lsattr -El $dev | grep "^$attr " | awk '{print $2}')
value1=$(echo $value | sed 's/^0x//')
  
if [ $difference == "higher" ]
then
  if [ $(expr ${value1} \< ${val1}) -eq 1 ]
  then
    if [ $fix != "yes" ]
    then
      printf "\E[31;1m""!!! FIX. $attr need to be changed from $value to $val !!!"" $1\E[0m\n"
    else
      printf "\E[31;1m""FIX. $attr will be changed from $value to $val"" $1\E[0m\n"
      chdev -l $dev -a $attr=$val > /dev/null 2>&1
      if [ "$?" -ne 0 ]
      then
        chdev -l $dev -a $attr=$val -P
        echo "must be rebooted before changes applies"
      else
        printf "\E[32;1m""OK. $attr for $dev changed to $val"" $1\E[0m\n"
      fi
      sleep 1
    fi
  else
    printf "\E[32;1m""OK. $attr for $dev is already $value"" $1\E[0m\n"
  fi
else
  if [ $difference == "lower" ]
  then
    if [ $(expr ${value1} \> ${val1}) -eq 1 ]
    then    
      if [ $fix != "yes" ]
      then 
        printf "\E[31;1m""!!! FIX. $attr need to be changed from $value to $val !!!"" $1\E[0m\n"
      else
        printf "\E[31;1m""FIX. $attr will be changed from $value to $val"" $1\E[0m\n"
        chdev -l $dev -a $attr=$val > /dev/null 2>&1
        if [ "$?" -ne 0 ]
        then
          chdev -l $dev -a $attr=$val -P
          echo "must be rebooted before changes applies"
        else
          printf "\E[32;1m""OK. $attr for $dev changed to $val"" $1\E[0m\n"
        fi
        sleep 1
      fi
    else
      printf "\E[32;1m""OK. $attr for $dev is already $value"" $1\E[0m\n"
    fi
  else
    if [ $difference == "equal" ]
    then
      if [[ ${value1} != ${val1} ]]
      then
        if [ $fix != "yes" ]
        then
          printf "\E[31;1m""!!! FIX. $attr need to be changed from $value to $val !!!"" $1\E[0m\n"
        else
          printf "\E[31;1m""FIX. $attr will be changed from $value to $val"" $1\E[0m\n"
          chdev -l $dev -a $attr=$val > /dev/null 2>&1
          if [ "$?" -ne 0 ]
          then
            chdev -l $dev -a $attr=$val -P
            echo "must be rebooted before changes applies"
          else
            printf "\E[32;1m""OK. $attr for $dev changed to $val"" $1\E[0m\n"
          fi
          sleep 1
        fi
      else
        printf "\E[32;1m""OK. $attr for $dev is already $value"" $1\E[0m\n"
      fi
    fi 
  fi
fi
}

#------------------------------------------------
# change_path ()
#------------------------------------------------
change_path()
{
dev=$1
parent=$2
prio=$3

if [ `lspath -AEH -l $dev -p $parent | grep priority | awk '{print $2}'` != "$prio" ]
then
        connect=`odmget -q "name=$dev and parent=$parent and path_status=1" CuPath | grep connection | awk '{print $3}'`
        if [ $fix != "yes" ]
        then
           printf "\E[31;1m""!!! FIX. path priority need to be changed on $dev $parent to $prio !!!"" $1\E[0m\n"
        else
           chpath -l $dev -p $parent -w $connect -a priority=$prio > /dev/null 2>&1
           if [ "$?" -ne 0 ]
           then
             printf "\E[31;1m""!!!ERROR cannot change path priority on $dev $parent to $prio"" $1\E[0m\n"
           else
             printf "\E[31;1m""FIX. changed priority on $dev $parent Priority `lspath -AEH -l $dev -p $parent | grep priority | awk '{print $2}'`"" $1\E[0m\n"
           fi
        fi
else
        printf "\E[32;1m""OK. No change to priority required on $dev $parent Priority `lspath -AEH -l $dev -p $parent | grep priority | awk '{print $2}'`"" $1\E[0m\n"
fi
}

#------------------------------------------------
# dmsg ()
#------------------------------------------------
dmsg()
{
if [ $debug == "yes" ]
then
   echo "$1"
fi
}


#------------------------------------------------
# check_lpar_param ()
#------------------------------------------------
check_lpar_param ()
{
#********************************
# Check on LPAR or pSeries

   #--------------------------------
   # Check ent Virtual adapter attributes

   list=""
   lsdev -C | grep '^ent' | grep -i 'virtual' | while read line
   do 
     echo $line | read dev dummy
     list="$list $dev"
   done

   for device in $list
   do
     echo ""
     echo "----- Check ENT $device on $HOSTNAME -----"
     echo ""

     attribut="max_buf_huge"
     goodval="128"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_huge"
     goodval="64"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="max_buf_large"
     goodval="128"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_large"
     goodval="64"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="max_buf_medium"
     goodval="512"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_medium"
     goodval="256"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="max_buf_small"
     goodval="4096"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_small"
     goodval="2048"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="max_buf_tiny"
     goodval="4096"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_tiny"
     goodval="2048"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval
     
     attribut="poll_uplink"
     goodval="yes"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval     
   done

   #--------------------------------
   # Check en Virtual adapter attributes

   list=""
   lsdev -C | grep '^ent' | grep -i virtual | sed 's/^ent/en/' | while read line
   do      
     echo $line | read dev dummy
     list="$list $dev"
   done

   for device in $list
   do
     echo ""
     echo "----- Check EN $device on $HOSTNAME -----"
     echo ""

     attribut="mtu_bypass"
     goodval="on"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval
   done

   #--------------------------------
   # Check fcs attributes

   list=""
   lsdev -C | grep '^fcs' | while read line
   do
      echo $line | read dev dummy
      list="$list $dev"
   done

   for device in $list
   do
      echo ""
      echo "----- Check FCS $device on $HOSTNAME -----"
      echo ""

      attribut="max_xfer_size"
      goodval="0x200000"
      diffval="higher"
      chhostval $device $attribut $goodval $diffval

      attribut="num_cmd_elems"
      goodval="256"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
   done

   #--------------------------------
   # Check fscsi attributes

   list=""
   lsdev -C | grep fscsi | while read line
   do
      echo $line | read dev dummy
      list="$list $dev"
   done

   for device in $list
   do
      echo ""
      echo "----- Check FSCSI $device on $HOSTNAME -----"
      echo ""

      lsdev -p $device | grep rmt  
      if [ $? != 0 ]
      then
         attribut="fc_err_recov"
         goodval="fast_fail"
         diffval="equal"
         chhostval $device $attribut $goodval $diffval

         attribut="dyntrk"
         goodval="yes"
         diffval="equal"
         chhostval $device $attribut $goodval $diffval
      else
         echo "FSCSI $device on $HOSTNAME has tapes as child devices"
      fi
   done

   #--------------------------------
   # Check Virtual SCSI Client Adapter

   list=""
   lsdev -Cc adapter |grep 'Virtual SCSI Client Adapter' | while read line
   do
      echo $line | read dev dummy
      list="$list $dev"
   done

   for device in $list
   do
      echo ""
      echo "----- Check Virtual SCSI Client Adapter $device on $HOSTNAME -----"
      echo ""

      attribut="vscsi_path_to"
      goodval="30"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval     

      attribut="vscsi_err_recov"
      goodval="fast_fail"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
   done

   #--------------------------------
   # Check 2107 disk attributes

   list=""
   lsdev -Cc disk |grep 'IBM MPIO FC 2107' | while read line
   do
      echo $line | read dev dummy
      list="$list $dev"
   done
 
   for device in $list
   do
      echo ""
      echo "----- Check IBM MPIO FC 2107 $device on $HOSTNAME -----"
      echo ""

      attribut="algorithm"
      goodval="load_balance"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval     

      attribut="hcheck_interval"
      goodval="60"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval     

      attribut="hcheck_mode"
      goodval="nonactive"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
   done
 
   #--------------------------------
   # Check Virtual SCSI Disk Drive attributes

   list=""
   lsdev -Cc disk |grep 'Virtual SCSI Disk Drive' | while read line
   do
      echo $line | read dev dummy
      list="$list $dev"
   done
 
   for device in $list
   do
      echo ""
      echo "----- Check Virtual SCSI Disk Drive $device on $HOSTNAME -----"
      echo ""

      attribut="algorithm"
      goodval="fail_over"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval

      attribut="hcheck_interval"
      goodval="60"    # IBM support recommendation
      diffval="equal"
      chhostval $device $attribut $goodval $diffval

      attribut="hcheck_mode"
      goodval="nonactive"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval

      attribut="reserve_policy"
      goodval="no_reserve"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
 
      attribut="queue_depth"
      goodval="20"
      diffval="higher"
      chhostval $device $attribut $goodval $diffval

      # Alternate path on the 2 VIOS
      # Calcul disk pair ou impair
      nbscsi=0
      if [ $(lspath -l $device | grep vscsi | wc -l | awk '{print $1}') -eq "2" ]
      then
        for line in $(lspath -l $device | sort | awk '{print $3}')
        do
          vscsi[$nbscsi]=$line
          let nbscsi="($nbscsi +1)"
        done
        num=`echo $device | sed "s/hdisk//"`
        let "num1=num/2"
        # Priorite 1 pour chiffre pair sur VSCSI1 et 2 sur VSCSI2 (inversement sur chiffre impair)
        let "priority=num-num1*2+1"
        case $priority in
                  "1")    change_path $device ${vscsi[0]} 1
                          change_path $device ${vscsi[1]} 2
                          ;;
                  "2")    change_path $device ${vscsi[0]} 2
                          change_path $device ${vscsi[1]} 1
                          ;;
                  "*")    echo "**** ERROR ****"
                          ;;
        esac
      fi

   done
}

#------------------------------------------------
# check_vios_param ()
#------------------------------------------------
check_vios_param ()
{
#********************************
# Check on VIO Servers

   #--------------------------------
   # Check ent Virtual adapter attributes

   list=""
   lsdev -C | grep '^ent' | grep -i 'virtual' | while read line
   do 
     echo $line | read dev dummy
     list="$list $dev"
   done

   for device in $list
   do
     echo ""
     echo "----- Check ENT $device on $HOSTNAME -----"
     echo ""

     attribut="max_buf_huge"
     goodval="128"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_huge"
     goodval="64"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="max_buf_large"
     goodval="128"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_large"
     goodval="64"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="max_buf_medium"
     goodval="512"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_medium"
     goodval="256"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="max_buf_small"
     goodval="4096"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_small"
     goodval="2048"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="max_buf_tiny"
     goodval="4096"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval

     attribut="min_buf_tiny"
     goodval="2048"
     diffval="higher"
     chhostval $device $attribut $goodval $diffval
     
     attribut="poll_uplink"
     goodval="yes"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval     
   done

   #--------------------------------
   # Check en Virtual adapter attributes

   list=""
   lsdev -C | grep '^ent' | grep -i virtual | sed 's/^ent/en/' | while read line
   do      
     echo $line | read dev dummy
     list="$list $dev"
   done

   for device in $list
   do
     echo ""
     echo "----- Check EN $device on $HOSTNAME -----"
     echo ""

     attribut="mtu_bypass"
     goodval="on"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval
   done
   
   #--------------------------------
   # Check ent SEA attributes

   list=""
   lsdev -C | grep '^ent' | grep -i 'shared ethernet adapter' | while read line
   do 
     echo $line | read dev dummy
     list="$list $dev"
   done

   for device in $list
   do
     echo ""
     echo "----- Check ENT SEA $device on $HOSTNAME -----"
     echo ""
     
     attribut="adapter_reset"
     goodval="yes"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval

     attribut="jumbo_frames"
     goodval="yes"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval

     attribut="large_receive"
     goodval="yes"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval

     attribut="largesend"
     goodval="1"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval
   done

   #--------------------------------
   # Check ent 10GbE adapter attributes

   list=""
   lsdev -C | grep '^ent' | grep '10GbE' | while read line
   do
     echo $line | read dev dummy
     list="$list $dev"
   done

   for device in $list
   do
     echo ""
     echo "----- Check ENT $device on $HOSTNAME -----"
     echo ""

     attribut="flow_ctrl"
     goodval="no"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval

     attribut="jumbo_frames"
     goodval="yes"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval

     attribut="large_receive"
     goodval="yes"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval

     attribut="large_send"
     goodval="yes"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval
   done
   
   #--------------------------------
   # Check ent Etherchannel adapter attributes

   list=""
   lsdev -C | grep '^ent' | grep 'Etherchannel' | while read line
   do
     echo $line | read dev dummy
     list="$list $dev"
   done

   for device in $list
   do
     echo ""
     echo "----- Check ENT $device on $HOSTNAME -----"
     echo ""

     attribut="use_jumbo_frame"
     goodval="yes"
     diffval="equal"
     chhostval $device $attribut $goodval $diffval
   done
   
   #--------------------------------
   # Check fcs attributes

   list=""
   lsdev -C | grep '^fcs' | while read line
   do
      echo $line | read dev dummy
      list="$list $dev"
   done

   for device in $list
   do
      echo ""
      echo "----- Check FCS $device on $HOSTNAME -----"
      echo ""

      attribut="max_xfer_size"
      goodval="0x200000"
      diffval="higher"
      chhostval $device $attribut $goodval $diffval

      attribut="num_cmd_elems"
      goodval="1600"
      diffval="higher"
      chhostval $device $attribut $goodval $diffval
   done
   
   #--------------------------------
   # Check fscsi attributes

   list=""
   lsdev -C |grep fscsi | while read line
   do
      echo $line | read dev dummy
      list="$list $dev"
   done
  
   for device in $list
   do
      echo ""
      echo "----- Check FSCSI $device on $HOSTNAME -----"
      echo ""

      attribut="fc_err_recov"
      goodval="fast_fail"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
     
      attribut="dyntrk"
      goodval="yes"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
   done

   #--------------------------------
   # Check 2107 disk attributes

   list=""
   lsdev -Cc disk |grep 'IBM MPIO FC 2107' | while read line
   do
      echo $line | read dev dummy
      list="$list $dev"
   done
 
   for device in $list
   do
      echo ""
      echo "----- Check IBM MPIO FC 2107 $device on $HOSTNAME -----"
      echo ""

      attribut="algorithm"
      goodval="load_balance"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval

      attribut="hcheck_interval"
      goodval="60"
      diffval="higher"
      chhostval $device $attribut $goodval $diffval
     
      attribut="hcheck_mode"
      goodval="nonactive"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval

      attribut="reserve_policy"
      goodval="no_reserve"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
   done

   #--------------------------------
   # Check DS3xxx disk attributes

   list=""
   lsdev -Cc disk |grep 'MPIO DS3' | while read line
   do 
      echo $line | read dev dummy
      list="$list $dev"
   done
      
   for device in $list
   do
      echo ""
      echo "----- Check IBM MPIO DS3xxx $device on $HOSTNAME -----"
      echo ""

      attribut="reserve_policy"
      goodval="no_reserve"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
   done
   
   #--------------------------------
   # Check Hitachi disk attributes

   list=""
   lsdev -Cc disk |grep 'Hitachi Disk Array' | while read line
   do 
      echo $line | read dev dummy
      list="$list $dev"
   done
      
   for device in $list
   do
      echo ""
      echo "----- Check HITACHI DISK ARRAY $device on $HOSTNAME -----"
      echo ""

      attribut="queue_depth"
      goodval="20"
      diffval="higher"
      chhostval $device $attribut $goodval $diffval

      attribut="algorithm"
      goodval="round_robin"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
      
      attribut="reserve_policy"
      goodval="no_reserve"
      diffval="equal"
      chhostval $device $attribut $goodval $diffval
   done
}

###########################################################################
#
# main ()
#
###########################################################################

main () {

cd $path_script

# Read and check scripts arguments
debug=yes
fix=no
while [ $# -gt 0 ]
do
   case "$1" in
      -f) fix=yes ;;
      -v) debug=yes ;;
      -h|help) usage 
               exit 1;;
   esac
   shift
done

echo `date`" : Begin of "$sn" "$HOSTNAME
echo "**********************\n"

# Check if LPAR is a VIOS
ls /usr/ios/cli/ioscli  > /dev/null 2>&1
if [ $? -eq 0 ]
then
        check_vios_param
else
        check_lpar_param 
fi

echo "\n**********************"
nb=$(odmget CuAtSav | grep name | wc -l | awk '{print $1}')
if [ "$nb" -ne "0" ]
then
  printf "\E[31;1m""!!! FIX. A reboot is required to apply $nb device(s) parameter(s) !!!"" $1\E[0m\n"
  odmget CuAtSav | egrep "name|attribute|value" | paste - - -
  echo "\n**********************"
fi
echo `date`" : End of "$sn" "$HOSTNAME

}

main $* 2>&1 | tee $logname
aix/scripts_tuning_devices.txt · Last modified: 2021/01/01 21:21 (external edit)