User Tools

Site Tools


aix:scripts

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"

Clean paths and adapters

File_name:

clean_path.sh

Cleanup all unused paths and adapters:

#!/bin/ksh
#set -x
#############################################
#@(#) Remove all disk path not available
#############################################
# version 1.0 21-09-2015
#############################################

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

echo "Remove unused adapters and disks"
echo "=============================================================================="
for i in  $(lsdev -Cc adapter | grep -vi available | awk '{print $1}')
do
  rmdev -dl $i -R
done
for i in  $(lsdev -Cc disk | grep -vi available | awk '{print $1}')
do
  rmdev -dl $i
done

echo "Before cleaning "
pcmpath query adapter
echo "=============================================================================="
for i in  $(lspv|awk '{print $1}')
 do
 echo $i
 Actif_path=`lspath -l $i -F'status:parent:connection'|grep  Enabled`
 Inactif_path=`lspath -l $i -F'status:parent:connection'|grep -v Enabled`
 #echo $Actif_path
 if [ ! -z "$Actif_path" ] # only remove path when at least one actif path exist
  then
   if [ ! -z "$Inactif_path" ] # only continue if inactif paths exists
    then
     for j in $(lspath -l $i -F'status:parent:connection'|grep -v Enabled)
     do 
       STATUS=$(echo $j | awk -F: '{print $1}')
       PARENT=$(echo $j | awk -F: '{print $2}')
       CONNECTION=$(echo $j | awk -F: '{print $3}'|awk '{print $1}')
       # echo $j
       # echo $STATUS
       # echo $PARENT
       # echo $CONNECTION
       rmpath -l $i -p $PARENT -w $CONNECTION -d  
     done
    else
     echo " no inactif path to remove"
   fi

  else
    echo "No enabled path for $i, clean paths manually"
 fi
done
echo "=============================================================================="
echo "After cleaning"
pcmpath query adapter
exit

Centralize core

File_name:

centralize_core.sh

Centralize all cores from all users and system cores:

#!/bin/ksh
##################################################
#@(#) centralize all core from all users in /var/core
##################################################
#        chcore [-R load_module] [<options>] [<username>|-d]
#        where <options> is one or more of the following:
#                -c {on|off|default}      : setting for core compression
#                -p {on|off|default}      : setting for core location
#                -l {<path>|default}      : specify directory to use
#                -n <on|off|default}      : setting for core naming
#
#      The -d option will set the default value for the system.
# this script add an entrie in /etc/security/user
# create a filesystem /var/core 
# active at next user connection
# Check if a file is a core or just a file name do:
# /usr/lib/ras/check_core <core_file>
# version: 1.0 10-05-2012 Manu
##################################################

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

CORE_PATH=/var/core
CORELV=corelv
VG=rootvg
SZ=1G

###########################################################################
# usage ()
#
# Parameters:
###########################################################################
usage()
{
echo "Usage: $0 (start | stop | status)"
echo "\tcentralize all core from all users in /var/core"
}

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

case "$1" in
start)
	echo `date`" : Begin of "$sn" "$HOSTNAME"\n"
	lsfs -a | grep $CORE_PATH > /dev/null 2>&1
	if [ $? -ne 0 ]
        then
		NBR_COPIES=`lslv hd5 | grep COPIES | awk '{print $2}'`
		mklv -t jfs2 -c $NBR_COPIES -y $CORELV $VG $SZ
		crfs -vjfs2 -m $CORE_PATH -d $CORELV -Ayes
		mount $CORE_PATH
		chmod 777 $CORE_PATH
		chcore -c on -p on -l $CORE_PATH -n on -d
		syscorepath -p $CORE_PATH
	else
		lscore | grep "location" | grep $CORE_PATH > /dev/null 2>&1
		if [ $? -eq 0 ]
        	then
			chcore -c on -p on -n on
			syscorepath -p $CORE_PATH
		else
			chcore -c on -p on -l $CORE_PATH -n on -d
			syscorepath -p $CORE_PATH
		fi
	fi
	lscore
	echo "\n"`date`" : End of "$sn" "$HOSTNAME
        ;;
stop)
	echo `date`" : Begin of "$sn" "$HOSTNAME"\n"
        chcore -c off -p off -n off 
	lscore
	echo "\n"`date`" : End of "$sn" "$HOSTNAME
        ;;
status)
        lscore
        ;;
*)
        usage
        exit 1
	;;
esac

}

main $* 2>&1 | tee $logname 

Check disks path on vscsi

File_name:

show_path_mismatch.sh

Check the paths on vscsi and report error in case of bad mapping with 2 VIOS:

#!/usr/bin/ksh
#set -x
#############################################
#@(#) Check if path are correctly set on VIOS
#############################################
# check if a disk on LPAR has the same path
# ID on both VIOS
# version 1.0 2-10-2012 Manu
#############################################

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

#------------------------------------------------
# usage ()
#------------------------------------------------
usage()
{
rep=$*
case "$rep" in
* )
        echo "Usage: "$0
        echo "\tNo parameter required"
        echo "\tOption -v verbose"
        echo "\tCheck virtual disk address on each path print an error if the paths have different connection address"
        exit 1
        ;;
esac
}

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

#------------------------------------------------
# check_path ()
#------------------------------------------------
check_path() {
hdisk=$1

VSCSI0=`lspath -l $hdisk -F"parent" | head -1`
VSCSI1=`lspath -l $hdisk -F"parent" | tail -1`
if [[ "$VSCSI0" == "$VSCSI1" ]]
then
  echo $hdisk:
  type=$(lsattr -El sys0 -a modelname | cut -d " " -f2 | sed 's/IBM,//g')
  if [[ "$type" == "8406-70Y" ]]
  then 
    echo "******** $hdisk single path disk on IVM *********"
  else
    echo "******** ERROR $hdisk single path disk on dual VIOS Server *********"
  fi
else
  CONNECT0=`odmget -q "name=$hdisk and parent=$VSCSI0 and path_status=1" CuPath | grep connection | awk '{print $3}'` 
  PRIO0=`lspath -AEH -l $hdisk -p $VSCSI0 | grep priority | awk '{print $2}'`
  CONNECT1=`odmget -q "name=$hdisk and parent=$VSCSI1 and path_status=1" CuPath | grep connection | awk '{print $3}'`
  PRIO1=`lspath -AEH -l $hdisk -p $VSCSI1 | grep priority | awk '{print $2}'`

  if [[ "$CONNECT0" != "$CONNECT1" ]]
  then
    echo $hdisk:
    echo "******** ERROR on disk $hdisk paths missmatch on the 2 VIOS *********"
    dmsg "vscsi= $VSCSI0 connection= $CONNECT0 priority= $PRIO0 "
    dmsg "vscsi= $VSCSI1 connection= $CONNECT1 priority= $PRIO1 "
    echo "########################"
  else
    dmsg "$hdisk:"
    dmsg "vscsi= $VSCSI0 connection= $CONNECT0 priority= $PRIO0 "
    dmsg "vscsi= $VSCSI1 connection= $CONNECT1 priority= $PRIO1 "
    dmsg "########################"
  fi
fi
}


###########################################################################
# main ()
#
# Check if a disk is mapped on both VIOS with the same adress 0x8100000000000000
#
#root@nim]/root# ssh padmin@vio1 ioscli lsmap -vadapter vhost3
#SVSA            Physloc                                      Client Partition ID
#--------------- -------------------------------------------- ------------------
#vhost3          U9117.MMA.10579F0-V1-C16                     0x00000006
#
#VTD                   vtscsi3
#Status                Available
#LUN                   0x8100000000000000
#   
###########################################################################
main () {

debug=no

while [ $# -gt 0 ]
do
   case "$1" in
      -v) debug=yes ;;
      -h|help) usage
               exit 1;;
   esac
   shift
done

dmsg "`date` : Begin of $sn $(hostname)"


dmsg "########################"

for HDISK in $(lsdev -Cc disk | grep "Virtual" | awk '{print $1}')
do
  check_path $HDISK
done

dmsg "`date` : Begin of $sn $(hostname)"

}

main $* 2>&1 | tee $logname

DSH VIOS

File_name:

dshvio

Do an ssh on all VIOS, on padmin user or on root. Syntax: root@coenim:/:# dshvio -? Valid parameters are: -r for a root command -n for a list of VIO servers -n vios1 -n vios1,vios2 Examples: A regular VIOS command:

root@coenim:/:# dshvio ioslevel
=========================
VIO server --> coevios1
=========================
1.5.1.1-FP-10.1
=========================
VIO server --> coevios2
=========================
1.5.1.1-FP-10.1
#!/bin/ksh
# Created by DeanRowswell, IBM, April 26, 2006
# Modified by Dean Rowswell, IBM, October 11, 2007
# Added a check for the -r flag for a root user command
# NOTE: this flag will require the expect RPMpackage to be installed
# Modified by Dean Rowswell, IBM, October 12, 2007
# Added a check for the -n flag tospecify a singleor multiple VIO servers
#
#------------------------------------------------------------------------------
# Assumption: this server is a trusted host for running ssh commandsto
# the VIO server(s)
# To set this up:
# ssh-keygen -t dsa (press ENTER for all prompts)
# scp $HOME/.ssh/id_dsa.pub padmin@VIOserver:.ssh/authorized_keys2
#
# NOTE: if the VIO server respondswith "rksh: ioscli: not found" then
# login to the VIO server and change to the root shell via oem_setup_env.
# Edit /etc/ssh/sshd_config
# Change: PermitUserEnvironment no
# To: PermitUserEnvironment yes
# Run: stopsrc -s sshd ; startsrc -s sshd
#------------------------------------------------------------------------------
#===========================================================#
# Define the listof VIO servers in this variable
#===========================================================#
VIOS="vios1 vios3"
#===========================================================#
DisplayUsage() {
echo "Syntax: dshvio COMMAND\n Run dshvio -? for the valid parameters"
exit
}

if [ ${#*} -eq 0 ]
then
  DisplayUsage
else
  while getopts :rn: PARMS
  do
    case $PARMS in
             r) lslpp -L|grep -w expect >/dev/null
                if[ $? -ne 0 ]
                then
                  echo "ERROR: cannot use -r flag because expect\
                  RPM package is not installed"
                  exit 1
                else
                  ROOT=1
                fi;;
             n) VIOS=${OPTARG}
                VIOS=`echo ${VIOS}|sed 's/,/ /g'`;;
             ?) echo"Valid parameters are:\n -r for a root command\n\
                -n for a list of VIO servers\n  -n vios1\n -n vios1,vios2" ; exit;;
    esac
  done
  shift $(($OPTIND -1))
  VIOSCMD=${*}
  if [ ${#VIOSCMD} -eq 0 ]
  then
    DisplayUsage
  fi
fi

for VIO in ${VIOS}
do
  ping -c1 ${VIO}>/dev/null 2>/dev/null
  if [ $? -eq 0 ]
  then
    echo "======================\nVIO server --> ${VIO}\n\
    ======================"
    if [ ${ROOT:=0} -ne 1 ]
    then
      ssh padmin@${VIO} "ioscli${VIOSCMD}"
    else
      expect -c "spawn ssh padmin@${VIO} ;expect\"\$\*\";\
      send \"oem_setup_env\\r\";expect \"\#\*\";send \"${VIOSCMD}\\r\";\
      send \"exit\\r\";expect \"\$\*\";send \"exit\\r\""|egrep -v "^spawn\
      |^Last|oem_setup_env|^exit|^#"
    fi
  else
    echo "===================\\nVIO server --> ${VIO}\n\
    ==================="
    echo "VIOserver: ${VIO} is not responding"
  fi
done

mail_files

#!/bin/sh
#@(#) script to email files as attachments.
# ------------------------------------

# Additional documentation for this script, including a brief introdcution 
# to MIME can be found at:  http://home.clara.net/dwotton/unix/mail_files.htm

# Written: Dave Wotton, July 1998, (Cambridge UK)
#          This script comes with no warranty or support. You are
#          free to modify it as you wish, but please retain an
#          acknowledgement of my original authorship.

# Amended: Dave Wotton, 6/3/99
#          -t flag now optional. subject also optional
#
# Amended: Dave Wotton, 3/8/00
#          added -b and -u  options. By default a file-list which is not
#          preceded by a -n, -b, or -u flag is now NOT encoded (the previous
#          default was to base64 encode it.).
#
# Amended: Dave Wotton, 10/10/00
#          added a -c (cc:) option.
#          Added a tty -s test to prevent the prompt to enter the text body
#          being displayed when not connected to a tty. (The text body is
#          still required though. /dev/null will suffice.)
#
# Amended: Dave Wotton, 24/2/01
#          Now uses perl to perform the base64 encoding, as it comes as
#          standard on most modern Unixes. (You need the perl MIME package
#          though, which I believe is standard. )

# Amended: Dave Wotton, 22/09/01
#          Now creates a "To:" header and uses the sendmail -t flag to
#          duplicate this as the envelope recipients, rather than using the
#          user supplied list of addresses simply as envelope recipients.
#          This confused some mail clients, specifically Lotus Notes.

# Amended: Dave Wotton, 30/09/01
#          Now initialises the main variables, so that previously set
#          environment variable values (eg. $CC) aren't used instead.
#          Enable multiple occurrences of the -t and -c flags. Thanks to
#          Jason Judge for these suggestions.


# Usage:   mail_files [-t] mailid [ -c mailid ] [ -s subject ] [ -f mailid ] 
#          [-n file_list] [-u file_list] [-b file_list] [-r Reply-To] file_list
#
#    -f      : The mailid of the sender ( defaults to your userid )
#              Only userids that have been defined as "trusted" in the sendmail
#              config file can make use of the -f option. For non-trusted users
#              any value specified by this parameter will be ignored by 
#              sendmail.
#    -t      : The mailid of the recipient. Mandatory, no default
#              multiple mailids can be specified, separated by commas.
#    -c      : The mailid of any carbon-copy recipients. Optional.
#              multiple mailids can be specified, separated by commas.
#    -s      : The subject string. Optional, default = "Not specified".
#              Enclose in quotes.
#    -n      : no-encode: indicates a list of files which are NOT to be base64
#              or uuencode encoded. Multiple files may be enclosed in double
#              quotes. Usual wildcard notation can be used. This option is
#              for completeness and can be omitted because the default action 
#              is not to encode the file-list.
#    -b      : base64 encoding: indicates a list of files which are to be 
#              base64 encoded. Multiple files may be enclosed in double quotes.
#              Usual wildcard notation can be used.
#    -u      : uuencode encoding: indicates a list of files which are to be 
#              uuencode encoded. Multiple files may be enclosed in double 
#              quotes. Usual wildcard notation can be used.
#     -r     : Reply to. Used for a single reply to. Permit to force the 
#		reply to someone.
#     -e     : SMTPoriginator
#     -x     : The mailid of any blind copy recipients. Optional.
#              multiple mailids can be specified, separated by commas.
#  file_list : The list of files to send as attachments with no-encoding
#              (same as -n option, but the file list does not need to be
#              enclosed in quotes if more than one file specified). 
#              Usual wildcard notation can be used.

# The program will also prompt for text to be supplied on standard input
# as the main text of the message.

# eg.
#      1) mail_files Dave.Wotton -b file9.gif t*.htm < /dev/null
#
#         email file9.gif as a base64 encoded attachment and the t*.htm
#         files unencoded.
#
#      2) mail_files Dave.Wotton -s "my test" -b "file1.gif file2.gif" \
#                    < /dev/null
#
#         email file1.gif and file2.gif as base64 encoded attachments.

# The script makes use of perl's MIME package to perform the base-64 
# encoding/decoding. 

# Note that files destined for Windows environments should have a name of
# the form aaaa.bbb where aaaa is up to 8 characters long, and bbb is a
# 3 character sufix. The suffix determines which program is used to
# display/process the data at the remote end.

# Simple text files can be emailed unencoded. Binary files, or text files
# with long lines ( ie > 1000 chars ) should use the  base64 or uuencode 
# encoding procedures. Base64 is preferred because it is more universally
# supported. In particular, most PC mail-clients can automatically decode
# base64 encoded attachments. Note that simple text files with short lines 
# which are destined for PC environments should not be base64 encoded.
# This is because PCs use a different line-break character to Unix.
# If the text is base64 encoded, the line-breaks are not converted
# automatically and so the data arrives at the remote end without
# line-breaks.

# set up a 'usage' routine
# ------------------------
dir=`dirname $0`
. $dir/.env

max_size=1 	# max trace file size (MB)
tracefile=$logpath/$sn.trc
echo "==> $(date '+%d/%m/%y %H:%M:%S') $(pwd)#$0 $*" >> $tracefile

###########################################################################
# usage ()
#
# Parameters:
###########################################################################
usage()
usage()
{
  [ "$1" ] && ( echo $* ; echo "" )

  cat <<!
  Usage:   mail_files [-t] mailid [ -c mailid ] [ -s subject ] [ -f mailid ] 
           [-n file_list] [-u file_list] [-b file_list] file_list
!
  exit 4
}

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

if ! test -f $tracefile
then
  touch $tracefile
  chmod 666 $tracefile
fi
 
# Initialise main variables ...
# -------------------------

FROM=$LOGNAME
SUBJ=${SUBJ:-"Not specified"}

TO="" ; CC="" ; SUBJ="" ; NOENC="" ; BASE64="" ; UUE="" ; RPL="" ; SO="" ; BCC=""

# First parse the command line options. Using getopts means the parameters
# can be supplied in any order. But first we handle the first parameter,
# which may be a recipient, without a -t flag...

case "$1" in
   -* ) : ;;                   # ignore it, let getopts handle flags
    * ) TO=$1 ; shift ;;
esac

while getopts f:s:t:c:n:b:u:r:e:x: OPT
do
     case $OPT in
         "f" ) FROM=$OPTARG ;;
         "t" ) TO="$TO,$OPTARG" ;;
         "c" ) CC="$CC,$OPTARG" ;;
         "s" ) SUBJ=$OPTARG ;;
         "n" ) NOENC="$NOENC $OPTARG" ;;
         "b" ) BASE64="$BASE64 $OPTARG" ;;
         "u" ) UUE="$UUE $OPTARG" ;;
	 "r" ) RPL="$RPL,$OPTARG" ;;
	 "e" ) SO="-r $OPTARG" ;;
         "x" ) BCC="$BCC,$OPTARG" ;;
          *  ) usage ;;
     esac
done

#SO=${SO:-"-r $mail_undeliverable"}
#FROM=${FROM:-"$default_sender"}

shift `expr $OPTIND - 1`

if [ "$TO" = "" ]
then
    usage "An addressee must be specified"
fi

# All remaining parameters are files not requiring encoding ...
# ---------------------------------------------------------

# Build up $FILES as the list of non-encoded files. Use sed to remove
# any leading space from the variable.

FILES=`echo $NOENC $*|sed 's/^ //'`

Attachment="1" 
if [ "$BASE64" = "" -a "$FILES" = "" -a "$UUE" = "" ]
then
    # usage "At least one file must be specified"
    Attachment=""
fi

# Remove leading commas from TO, CC  ...
# ---------------------------------

TO=`echo $TO | sed 's/^,//'`
CC=`echo $CC | sed 's/^,//'`
BCC=`echo $BCC | sed 's/^,//'`

# Validate that the files exist ...
# -----------------------------

for F in $FILES $BASE64 $UUE
do
   if [ ! -r $F ]
   then
      echo "Error: File $F does not exist / is not readable."
      echo "Exiting. ( Mail not sent )."
      exit 5
   fi
done

tty -s && echo "Enter text of main message ( finish with CTRL-D ) ..."

# Now do the work ...
# ---------------

# The generated mail message is output onto standard out, which is then
# piped in to sendmail.

(
cat <<!
From: $FROM
Subject: $SUBJ
To: $TO
Reply-To: $RPL
!

[ "$CC" ] && echo "Cc: $CC" 

[ "$BCC" ] && echo "Bcc: $BCC"

[ "$Attachment" ] && cat <<!
Mime-Version: 1.0

Content-Type: multipart/mixed; boundary="DMW.Boundary.605592468"

This is a Mime message, which your mail program may not understand. Parts
of the message will appear as text. If the remainder appears as random
characters in the message body, instead of as attachments, then you'll
have to extract these parts and decode them manually.

--DMW.Boundary.605592468
Content-Type: text/plain; name="message.txt"; charset=iso-8859-1
Content-Disposition: inline; filename="message.txt"
Content-Transfer-Encoding: 7bit

!

# Read the standard input as the main text of the message ...
# -------------------------------------------------------
echo "\n"  # Avoid problems with  files starting with blanc
cat - 

# Now process the non-encrypted attachments ...
# -----------------------------------------

if [ "$FILES" ]
then
    for F in $FILES
    do

       BASE=`basename $F`

       echo --DMW.Boundary.605592468
       echo Content-Type: application/octet-stream\; name=\"$BASE\"
       echo Content-Disposition: attachment\; filename=\"$BASE\"
       echo Content-Transfer-Encoding: 7bit
       echo

       cat $F

    done
fi

# Now process the base64 encrypted attachments ...
# --------------------------------------------

if [ "$BASE64" ]
then
    for F in $BASE64
    do

       BASE=`basename $F`

       echo --DMW.Boundary.605592468
       echo Content-Type: application/octet-stream\; name=\"$BASE\"
       echo Content-Disposition: attachment\; filename=\"$BASE\"
       echo Content-Transfer-Encoding: base64
       echo

       perl -e '
       use MIME::Base64 qw(encode_base64);
       local($/) = undef;
       print encode_base64(<STDIN>);' < $F

    done
fi

# Now process the uuencode encrypted attachments ...
# ----------------------------------------------

# Sorry, this bit is untested - I haven't got a mail-client which can
# handle uuencoded MIME messages automatically, so can't test if the
# 'Content-Transfer-Encoding: uuencode' line is correct and whether I
# need the uuencode "begin" and "end" lines.

if [ "$UUE" ]
then
    for F in $UUE
    do

       BASE=`basename $F`

       echo --DMW.Boundary.605592468
       echo Content-Type: application/octet-stream\; name=\"$BASE\"
       echo Content-Disposition: attachment\; filename=\"$BASE\"
       echo Content-Transfer-Encoding: uuencode
       echo

       uuencode < $F xxx 

    done
fi

# append the final boundary line ...

[ "$Attachment" ] && echo --DMW.Boundary.605592468--

) | /usr/lib/sendmail -t $SO  -v >> $tracefile
exit $?

check_filesystems

check_fs.cfg

#filesystem_name:alert(%):alternate_email
#mail_default="$mail_system"
/tmp:80
/usr:96
/cdrom:100
/mnt:100
/db*:98

check_fs.sh

#!/usr/bin/ksh
#set -x
##################################################
#@(#) send an alert if filesystems usage is higher than threshold
##################################################
# associate file is checkfs.cfg (exceptions)
# please do not modify this script use checkfs.cfg 
# checkfs.cfg format: 
# fs_name:pct_threshold(:alternate_email)
# mail_default (default email address)
# check also GPFS quotas if used
# version: 1.1 10-02-2010 Manu
##################################################

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

pcalert_def=90  		# default value
logalt=$logpath/checkfs1.log    # alternate log for particular USERS
tmpcfg=$logpath/$sn.txt
tmpscript=$logpath/$sn.scr
nb_file=25
nb_dir=15

# eval to interpret the value of the vaiables set into config file
eval dest=$(cat $configfile | grep "^ *#" | grep "mail_default" | cut -d"=" -f2 | sed 's/"//g')

#------------------------------------------------
# check_gpfs ()
#------------------------------------------------
check_gpfs()
{
# test gpfs quota if applicable
lsfs -a | sed '1d' | awk '{print $4}' | grep "mmfs" > /dev/null 2>&1 
if [ $? -eq 0 ]
then
   quotaalert=2000000
   for i in sybase kplus
   do
        used=$(mmlsquota -u $i |grep clkpfs|awk '{print $3}')
        max=$(mmlsquota -u $i |grep clkpfs|awk '{print $4}')
        diff=$(expr $max - $used)
        if [ $diff -lt $quotaalert ]
                then 
                echo "***** GPFS Quota-WARNING *****" >> $logname
                echo " User $i has ounly $diff KB free quota " >> $logname
                echo " Reduce used space or use mmedquota -u $i to modifie quota" >> $logname
        fi
   done
fi
}

#------------------------------------------------
# info_fs ()
#------------------------------------------------
info_fs()
{
    echo "*******************"
    echo "***** WARNING ***** $(echo $fs) ---------> $(echo $i|cut -f 1 -d%) %" 
    echo "*******************"
    echo " "
    echo "les $nb_file + gros fichiers du filesystem $fs"  
    echo "les $nb_file + gros fichiers du filesystem $fs"  | sed "s/./-/g" 
    find $fs  -xdev -type f -ls | sort +6nr | head -$nb_file
    echo " "
    echo "les $nb_dir + gros répertoires du 1° niveau inférieur du filesystem $fs"       
    echo "les $nb_dir + gros répertoires du 1° niveau inférieur du filesystem $fs" | sed "s/./-/g"
    du -ms $fs/* | sort -nr | head -$nb_dir
    echo " ";echo " "
}

#------------------------------------------------
# generate_case_file ()
#------------------------------------------------
generate_case_file()
{
cat $configfile | grep -v "^ *#" > $tmpcfg
echo "" >> $tmpcfg
cat $tmpcfg | sed 's/:/)\ pct=/' | sed 's/:/\ mail=/' | sed '$s/^/\*)\ pct=pcalert_def/' | sed -e "s/pcalert_def/$pcalert_def/" | sed '2,$s/^/\\n/' | sed 's/$/;;/' > $tmpcfg
}

#------------------------------------------------
# check_fs ()
#------------------------------------------------
check_fs()
{
clauses=$(cat $tmpcfg)
for i in $(df -k | egrep -v "Filesystem|:|/proc" | grep -v ":" | grep "/dev/" | awk '{print $4 $7}')
do
  fs=`echo $i | cut -f 2 -d%`
  pct_fs=`echo $i | cut -f 1 -d%`
  log=$logname
  mail=""
  cmd="case $fs in \n $clauses                      \n esac"
  echo $cmd > $tmpscript
  . $tmpscript > /dev/null
  #echo "$fs  seuil=$pct  current_value=$pct_fs  $mail"
  if [ $pct_fs -gt $pct ]
  then
	echo "$fs alerte"
     if [[ $mail != "" ]]
     then
	log=$logalt
	altdest=$mail
     fi
     info_fs >> $log
  fi
done
}

#------------------------------------------------
# send_alert ()
#------------------------------------------------
send_alert()
{
test -e $logname && $path_script/mail_files $dest        -s "Filesystems on $(hostname)" -e $mail_undeliverable < $logname
test -e $logalt  && $path_script/mail_files $altdest     -s "Filesystems on $(hostname)" -e $mail_undeliverable < $logalt
}

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

main () {

cd $path_script
test -e $logname && rm $logname
test -e $logalt && rm $logalt

generate_case_file
check_fs
check_gpfs 
send_alert

test -e $tmpcfg && rm $tmpcfg
test -e $tmpscript && rm $tmpscript
}

main  > /dev/null 2>&1

List VIOS MAP disk

config_disk_vios.sh

#!/bin/ksh
#set -x
#@(#) Recupere le mapping des disks des serveurs sur le SAN
# Ce script doit être precede par une collecte d'info sur tous les 
# serveur NIM, en lancant collect_info_all_lpar.sh sur NIM.
# Collecte les informations sur les partitions, les VIOS, les DS
# les HMC, afin de reconstituer les ID des disques des LPARS 
# sur les DS et les VIOS associés
# Le fichier de sortie est au format HTML : $TMP_HTML_FILE
# version 1.0 20-09-2009 Manu

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

export LANG=C
TIME=`date`
NUM=`date +%d-%m-%Y`

HTML_CONFIG_DIR=$path_script/config_dir_vios_html

PATH_DATA=$logpath/config_lpar
TMP_DIR=$logpath/config_lpar/tmp
TMP_FILE=$TMP_DIR/list_serial
LIST_VIOS=$TMP_DIR/list_vios
LIST_VM=$TMP_DIR/list_vm
TMP_INFO=$TMP_DIR/info_vm_tmp
TMP_VIOS=$TMP_DIR/info_vios_tmp
TMP_HTML_FILE=$logpath/index_vios.html
RET_DAY="+15"

#####################################
# initialize
initialize()
{
if [ ! -d $PATH_DATA ]
then
        mkdir -p $PATH_DATA
fi
if [ ! -d $logpath ]
then
        mkdir -p $logpath
fi
if [ ! -d $TMP_DIR ]
then
        mkdir -p $TMP_DIR
fi
}

#####################################
# usage
usage()
{
rep=$*
case "$rep" in
* )
        echo "Usage: "$0
        echo "\tPas de paramètre requis"
        echo "\tce script créé un fichier de mapping des disks des LPARs sur les VIOS et les DS8000"
        echo "\tLe fichier de sortie est au format HTML : $TMP_HTML_FILE"
        exit 1
        ;;
esac
}

#####################################
# convert an id to hexadecimal
convert_to_hexa()
{
echo $1 > $TMP_DIR/TEST
perl -e 'printf ("%X",<STDIN>);' < $TMP_DIR/TEST
}

#####################################
# format an hexadecimal id
recreate_lpar_id()
{
id1=$1
id=`echo $id1 | tr 'A-Z' 'a-z'`
lenght_id=`echo $id | wc -c`
let lenght_id=9-lenght_id
id_begin=""
i=0
while (( $i < $lenght_id ))
do
        id_begin=`echo $id_begin"0"`
        let i="($i +1)"
done
full_id="0x$id_begin$id"
echo $full_id
}

#####################################
# function get VIOS info
get_vios()
{
vios=$1
vg=$2
# VIOS hdiskibm
COL_VIOS=""
COL_HDVIOS=""
if [[ "$vios" != "" ]]
then
  cat $TMP_INFO.$vg.pv | while read PV
  do
    # search for VIOS and hdisk name if Virtual Disk
    grep "$PV " $TMP_INFO"8" | grep "Virtual" > /dev/null 2>&1
    if [ $? -eq 0 ]
    then
        LUN_ID_VM=`cat $TMP_INFO"8" | grep "$PV " | awk '{print $3}'`
	HDVIOS=`grep -p "$PARTITION_ID" $TMP_VIOS.$vios.lsmap | grep "0x$LUN_ID_VM" | awk '{print $1}'`
        COL_HDVIOS="$COL_HDVIOS<br>$HDVIOS"
        COL_VIOS="$COL_VIOS<br>$vios"
    fi
  done
fi

COL_VIOS=`echo $COL_VIOS | cut -c5-`
COL_HDVIOS=`echo $COL_HDVIOS | cut -c5-`

if [[ $COL_HDVIOS = "" ]]
then
        COL_VIOS="<br>"
        COL_HDVIOS="<br>"
fi

cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_VIOS/g" >> $TMP_HTML_FILE
cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_HDVIOS/g" >> $TMP_HTML_FILE
}

#####################################
# function get VIOS info
get_lun_id()
{
vios1=$1

COL_IBMID=""
COL_LUNSZ=""
LUNSZ1=""
cat $TMP_INFO.$VG.pv | while read PV
do
    # search for LUN ID
    TYPE=`cat $TMP_INFO"8" | grep "$PV " | awk '{print $2}'`
    case "$TYPE" in
	Virtual)	HDVIRT=`cat $TMP_INFO"8" | grep "$PV " | awk '{print $3}'`
                        HDVIOS=`grep -p "$PARTITION_ID" $TMP_VIOS.$vios1.lsmap | grep "0x$HDVIRT" | awk '{print $1}'`
                        LUNID=`cat $TMP_VIOS.$vios1.pv | grep "$HDVIOS " | awk '{print $3}'`
                        COL_IBMID="$COL_IBMID<br>$LUNID"
			LUNSZ1=`cat $TMP_INFO"3" | grep -p "$PV:" | sed '/^$/d' | tail -1`
			if [[ "$LUNSZ1" == "" ]]
			then
				LUNSZ1=`grep $LUNID $TMP_DIR/DS.* | awk '{print $3}' | cut -d"." -f1`
			fi
			;;
        MPIO)           LUNID=`cat $TMP_INFO"8" | grep "$PV " | awk '{print $3}'`
                        COL_IBMID="$COL_IBMID<br>$LUNID"
			LUNSZ1=`cat $TMP_INFO"3" | grep -p "$PV:" | sed '/^$/d' | tail -1`
			if [[ `echo $LUNSZ1` == "" && `echo $LUNID` != "" ]] 
			then
				LUNSZ1=`cat $TMP_DIR/DS.* | grep "$LUNID" | awk '{print $3}' | cut -d"." -f1`
			fi
			echo $LUNSZ1;;
        SCSI)           COL_IBMID="$COL_IBMID<br>"
			LUNSZ1=`cat $TMP_INFO"3" | grep -p "$PV:" | sed '/^$/d' | tail -1`;;
    esac
    COL_LUNSZ="$COL_LUNSZ<br>$LUNSZ1 GB"
			#if [[ "$LUNID" -ne "" ]]
			#then
			#	LUNSZ1=`cat $TMP_DIR/DS.* | grep "$LUNID" | awk '{print $3}'`
			#fi

done

COL_IBMID=`echo $COL_IBMID | cut -c5-`
COL_LUNSZ=`echo $COL_LUNSZ | cut -c5-`
cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_IBMID/g" >> $TMP_HTML_FILE
cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_LUNSZ/g" >> $TMP_HTML_FILE

# Add free cell on the array
echo "   </tr>" >> $TMP_HTML_FILE
let CNT=1
while [ ${CNT} -lt ${ROW_SPAN_VG} ]
do
        echo "   <tr></tr>" >> $TMP_HTML_FILE
        let CNT=CNT+1
done
}

##########################
# create info_vm
create_info_vm()
{
# Create /tmp/info_vm_tmp<x> for each VM
        # info_vm_tmp1 : serial number and partition ID
        # info_vm_tmp2 : lspv
        # info_vm_tmp3 : lspv <hdiskx> give the pv size
        # info_vm_tmp4 : lsvg <vg> give the VG total and used space
        # info_vm_tmp5 : lsvg -l <vg>
        # info_vm_tmp6 : df -m
        # info_vm_tmp7 : lsps -a
        # info_vm_tmp8 : lscfg -vpl <hdiskx>
        # info_vm_tmp9 : lsvg -o
        # info_vm_tmp10 : lsvg -  lsvg -o (only inactive VG)
        find $TMP_DIR -name "info_vm_tmp*" -exec rm {} \;
        COUNT=0
        cat $PATH_DATA/collect_info.$VM_NAME | while read i
        do
                echo $i | grep "##########" > /dev/null 2>&1

                if [ $? -ne 0 ]
                then
                        echo $i >> $TMP_INFO$COUNT
                else
                        let "COUNT=COUNT+1"
                fi
        done

	# format info_vm_tmp3
	cat $TMP_INFO"3" | while read line
	do
		echo $line | grep ":" > /dev/null 2>&1
		if [[ $? -eq 0 ]]
		then
			print "\n"$line >> $TMP_INFO"3_1"
		else
			let "line1=line/1024"
			echo $line1 >> $TMP_INFO"3_1"
		fi
	done
	mv $TMP_INFO"3_1" $TMP_INFO"3"

        # format info_vm_tmp8 : hdisk<x> serial_number type (SCSI,MPIO,Virtual)
        HDISK=""
        cat $TMP_INFO"8" | egrep "hdisk|Serial Number" | while read line
        do
                if [[ `echo $HDISK` != "" ]]
                then
                        serial=`echo $line | grep "Serial Number" | sed -e 's/Serial Number//' | sed -e 's/\.//g' `
                        echo $HDISK $TYPE $serial >> $TMP_INFO"8_1"
                        HDISK=""
                fi
                echo $line | awk '{print $1}' | grep hdisk > /dev/null 2>&1
                if [ $? -eq 0 ]
                then
                        HDISK=`echo $line | awk '{print $1}' | grep hdisk`
                        echo $line | grep "Virtual SCSI" > /dev/null 2>&1
                        if [ $? -eq 0 ]
                        then
                                LUNID=`echo $line | awk '{print $2}' | cut -d- -f5 | sed "s/L//"`
                                TYPE="Virtual"
                                echo  $HDISK $TYPE $LUNID >> $TMP_INFO"8_1"
                                HDISK=""
                        else
                                echo $line | grep "2107" > /dev/null 2>&1
                                if [ $? -eq 0 ]
                                then
                                        TYPE="MPIO"
                                else
                                        TYPE="SCSI"
                                fi
                        fi
                fi
        done
        mv $TMP_INFO"8_1" $TMP_INFO"8"

        # read active volum groups
        cat $TMP_INFO"2" | egrep "active|concurrent" | awk '{print $3}' | grep -v rootvg > $TMP_INFO"10"
        echo "rootvg" > $TMP_INFO"9"
        for VGA in `cat $TMP_INFO"10"`
        do
                cat $TMP_INFO"9" | grep $VGA > /dev/null 2>&1
                if [ $? -ne 0 ]
                then
                        echo $VGA >> $TMP_INFO"9"
                fi
        done
        # read inactive volum groups
        cat $TMP_INFO"2" | egrep -v "active|concurrent" | awk '{print $3}' > $TMP_INFO"11"
        cat /dev/null > $TMP_INFO"10"
        for VGI in `cat $TMP_INFO"11"`
        do
                cat $TMP_INFO"10" | grep $VGI > /dev/null 2>&1
                if [ $? -ne 0 ]
                then
                        echo $VGI >> $TMP_INFO"10"
                fi
        done

        # collect information about filesystems in a VG (FSname, SIZE, % USED)
        cat $TMP_INFO"5" | grep -v "TYPE" | while read LINE
        do
                echo $LINE | grep ":" > /dev/null 2>&1
                if [ $? -eq 0 ]
                then
                        VG=`echo $LINE | cut -d: -f1`
                        TMP_FILE=$TMP_INFO.$VG
                        cat /dev/null > $TMP_INFO.$VG
                else
                        echo $LINE | awk '{print $2}' | egrep "boot|jfs2log|jfslog|sysdump" > /dev/null 2>&1
                        if [ $? -ne 0 ]
                        then
                                TYPE=`echo $LINE | awk '{print $2}'`
                                if [[ $TYPE = "jfs" ]] || [[ $TYPE = "jfs2" ]]
                                then
                                        LV_NAME=`echo $LINE | awk '{print $1}'`
                                        FS_NAME=`echo $LINE | awk '{print $7}'`
                                        FS_SIZE=`cat $TMP_INFO"6" | grep "$LV_NAME " | awk '{print $2}' | cut -d. -f1`
                                        FS_USED=`cat $TMP_INFO"6" | grep "$LV_NAME " | awk '{print $4}'`
                                        echo $FS_NAME $FS_SIZE"MB" $FS_USED >> $TMP_INFO.$VG
                                        echo $FS_NAME $FS_SIZE"MB" $FS_USED
                                else
                                        if [ $TYPE = "paging" ]
                                        then
                                                LV_NAME=`echo $LINE | awk '{print $1}'`
                                                FS_NAME=`echo $LV_NAME"-"$TYPE`
                                                FS_SIZE=`cat $TMP_INFO"7" | grep "$LV_NAME " | awk '{print $4}'`
                                                FS_USED=`cat $TMP_INFO"7" | grep "$LV_NAME " | awk '{print $5}'`
                                                echo $FS_NAME $FS_SIZE $FS_USED"%" >> $TMP_INFO.$VG
                                                echo $FS_NAME $FS_SIZE $FS_USED"%"
                                        fi
                                fi
                        fi
                fi
        done
        # collect information about VG (TOTAL size and % USED)
        cat $TMP_INFO"4" | while read LINE
        do
                echo $LINE | grep ":" > /dev/null 2>&1
                if [ $? -eq 0 ]
                then
                        VG=`echo $LINE | cut -d: -f1`
                        cat /dev/null > $TMP_INFO.$VG.size
                else
                        echo $LINE >> $TMP_INFO.$VG.size
                fi
                cat $TMP_INFO.$VG.size
        done

        # collect information about disk in a VG
        cat $TMP_INFO"2" | awk '{print $1" "$3}' | while read pv vg
        do
                echo $pv >> $TMP_INFO.$vg.pv
        done

        # Calculate the array ROW_SPAN to convert in HTML
        ROW_SPAN_VM=0
        cat $TMP_INFO"4" | grep ":" | cut -d":" -f1 | while read VG_NAME
        do
                echo $VG_NAME
                ROW_SPAN_VG=`cat $TMP_INFO.$VG_NAME | wc -l`
                ROW_SPAN_PV=`cat $TMP_INFO.$VG_NAME.pv | wc -l`
                if [ ${ROW_SPAN_VG} -lt 3 ]
                then
                        ROW_SPAN_VG=3
                fi
                if [ ${ROW_SPAN_VG} -gt ${ROW_SPAN_PV} ]
                then
                        let ROW_SPAN_VM=ROW_SPAN_VM+ROW_SPAN_VG
                        echo $ROW_SPAN_VG > $TMP_INFO.$VG_NAME.rowspan
                else
                        let ROW_SPAN_VM=ROW_SPAN_VM+ROW_SPAN_PV
                        echo $ROW_SPAN_PV > $TMP_INFO.$VG_NAME.rowspan
                fi

        done
############### A verifier#####################
        ROW_SPAN_PV_none=`cat $TMP_INFO"10" | wc -l`
        let ROW_SPAN_VM=ROW_SPAN_VM+ROW_SPAN_PV_none
        # create HTML file for each VM
	COL_VM=`echo $VM_NAME`
        cat $HTML_CONFIG_DIR/body1.txt | sed "s/row_span/$ROW_SPAN_VM/g" | sed "s/vm_name/$COL_VM/g" >> $TMP_HTML_FILE
#########################################
}

############################
# Inactive VG
inactive_vg()
{
vg=$1
# Inactive VG
	# VG informations
	ROW_SPAN_VG=`cat $TMP_INFO.$vg.pv | wc -l`
        echo "   <tr>" >> $TMP_HTML_FILE
        #COL_VG=`echo "$vg</span></big></td>"`
	#cat $HTML_CONFIG_DIR/body2.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/vg_name/$vg/g" | sed "s/size size_gb//g" | sed "s/used percent//g" >> $TMP_HTML_FILE
	#COL_VG=`echo "$VG</span></big></td>"`
	cat $HTML_CONFIG_DIR/body5.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/vg_name/$vg/g" >> $TMP_HTML_FILE


        # FS informations
        cat $HTML_CONFIG_DIR/body3.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/fs_name/<br>/g" >> $TMP_HTML_FILE
        # FS size
        cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/<br>/g" >> $TMP_HTML_FILE
        # FS used
        cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/<br>/g" >> $TMP_HTML_FILE
        # VM disk
	COL_PV=""
        cat $TMP_INFO.$VG.pv | while read PV
        do
        	COL_PV="$COL_PV<br>$PV"
        done
        COL_PV=`echo $COL_PV | cut -c5-`
        cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_PV/g" >> $TMP_HTML_FILE
        # VM disk ID
        COL_LUN_ID_VM=""
        echo "########### $TMP_INFO.$VG.pv"
        cat $TMP_INFO.$vg.pv | while read PV
        do
        	# search for LUN ID
        	TYPE=`cat $TMP_INFO"8" | grep "$PV " | awk '{print $2}'`
        	case "$TYPE" in
        		Virtual)        LUN_ID_VM=`cat $TMP_INFO"8" | grep "$PV " | awk '{print $3}' | cut -d- -f5 | sed "s/L//"`;;
        		MPIO)           LUN_ID_VM="MPIO";;
        		SCSI)           LUN_ID_VM="SCSI";;
        	esac
        	COL_LUN_ID_VM="$COL_LUN_ID_VM<br>$LUN_ID_VM"
	done

	COL_LUN_ID_VM=`echo $COL_LUN_ID_VM | cut -c5-`
	cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_LUN_ID_VM/g" >> $TMP_HTML_FILE
}

############################
# Active VG
active_vg()
{
                echo "rootvg  Active VG"
                # VG information
                if [ $VG != "rootvg" ]
                then
                        echo "   <tr>" >> $TMP_HTML_FILE
                fi
                VG_TOT_SIZE=`cat $TMP_INFO.$VG.size | head -1`
                VG_USED_SIZE=`cat $TMP_INFO.$VG.size | tail -1`
                let VG_USED_SIZE=VG_USED_SIZE*100/VG_TOT_SIZE
                VG_USED_SZ=`echo $VG_USED_SIZE "%"`
                let VG_TOT_SIZE=VG_TOT_SIZE/1024
                VG_TOT_SZ=`echo $VG_TOT_SIZE "GB"`
                ROW_SPAN_VG=`cat $TMP_INFO.$VG.rowspan`
                cat $HTML_CONFIG_DIR/body2.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/vg_name/$VG/g" | sed "s/size_gb/$VG_TOT_SZ/g" | sed "s/percent/$VG_USED_SZ/g" >> $TMP_HTML_FILE
                # Filesystems information
                COL_FS=`cat $TMP_INFO.$VG | grep -v "/" | awk '{print $1}' | head -1`
                if [[ $COL_FS != "" ]]
                then
                        cat $TMP_INFO.$VG | grep -v "/" | awk '{print $1}' | grep -v "`cat $TMP_INFO.$VG | grep -v / | awk '{print $1}' | head -1`" | while read TXT
                        do
                                COL_FS=$COL_FS"<br>"$TXT
                        done
                fi

                TXT1=""
                cat $TMP_INFO.$VG | grep / | awk '{print $1}' | while read LINE
                do
                        TXT=""
                        TEST=`echo $LINE | cut -d/ -f2`
                        if [[ $TEST = "" ]]
                        then
                                TXT=`echo "\/"`
                        else
                                for i in `echo $LINE | sed "s/\// /g"`
                                do
                                        TXT=`echo $TXT"\/"$i`
                                done
                        fi
                        TXT1=$TXT1"<br>"$TXT
                done
                COL_FS=$COL_FS$TXT1
                if [[ `echo $COL_FS | cut -c2-3` = "br" ]]
                then
                        COL_FS=`echo $COL_FS | cut -c5-`
                fi
                if [[ $COL_FS = "" ]]
                then
                        COL_FS="<br>"
                fi
                cat $HTML_CONFIG_DIR/body3.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/fs_name/$COL_FS/g" >> $TMP_HTML_FILE
                # FS size
                cat $TMP_INFO.$VG | grep -v "/" > $TMP_INFO.$VG"1"
                cat $TMP_INFO.$VG | grep "/" > $TMP_INFO.$VG"2"
                cat $TMP_INFO.$VG"1" > $TMP_INFO.$VG
                cat $TMP_INFO.$VG"2" >> $TMP_INFO.$VG

                COL_FS_SZ=""
                cat $TMP_INFO.$VG | awk '{print $2}' | while read FS_SZ
                do
                        COL_FS_SZ="$COL_FS_SZ<br>$FS_SZ"
                done
                COL_FS_SZ=`echo $COL_FS_SZ | cut -c5-`
                if [[ $COL_FS_SZ = "" ]]
                then
                        COL_FS_SZ="<br>"
                fi
                cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_FS_SZ/g" >> $TMP_HTML_FILE
                # FS used
                COL_FS_USED=""
                cat $TMP_INFO.$VG | awk '{print $3}' | while read FS_USED
                do
                        COL_FS_USED="$COL_FS_USED<br>$FS_USED"
                done
                COL_FS_USED=`echo $COL_FS_USED | cut -c5-`
                if [[ $COL_FS_USED = "" ]]
                then
                        COL_FS_USED="<br>"
                fi
                cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_FS_USED/g" >> $TMP_HTML_FILE
                # VM disk
                COL_PV=""
                cat $TMP_INFO.$VG.pv | while read PV
                do
                        COL_PV="$COL_PV<br>$PV"
                done
                COL_PV=`echo $COL_PV | cut -c5-`
                cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_PV/g" >> $TMP_HTML_FILE
                # VM disk ID
                COL_LUN_ID_VM=""
                echo "########### $TMP_INFO.$VG.pv"
		cat $TMP_INFO.$VG.pv | while read PV
		do
   			# search for LUN ID
			TYPE=`cat $TMP_INFO"8" | grep "$PV " | awk '{print $2}'`
			case "$TYPE" in
			Virtual)	LUN_ID_VM=`cat $TMP_INFO"8" | grep "$PV " | awk '{print $3}' | cut -d- -f5 | sed "s/L//"`;;
			MPIO)		LUN_ID_VM="MPIO";;
			SCSI)		LUN_ID_VM="SCSI";;
        		esac
                        COL_LUN_ID_VM="$COL_LUN_ID_VM<br>$LUN_ID_VM"
		done

                COL_LUN_ID_VM=`echo $COL_LUN_ID_VM | cut -c5-`
                cat $HTML_CONFIG_DIR/body4.txt | sed "s/row_span/$ROW_SPAN_VG/g" | sed "s/info/$COL_LUN_ID_VM/g" >> $TMP_HTML_FILE

}

###########################################
# Main
###########################################
if [ $# -gt 0 ]
then
        usage $*
fi
main()
{
echo "#########################"
echo `date`" : Begin of "$sn

initialize
rm $TMP_DIR/info_vm* > /dev/null 2>&1
rm $TMP_DIR/info_vios_tmp.* > /dev/null 2>&1
rm $TMP_DIR/list* > /dev/null 2>&1
mv $TMP_HTML_FILE $TMP_HTML_FILE.$NUM
find  $PATH_DATA -name '$TMP_HTML_FILE*' -mtime $RET_DAY | xargs rm -f 1>/dev/null 2>&1

#####################################
# List of all VIOS
ls $PATH_DATA | grep "iosclilsmap-all" | cut -d"." -f2 > $LIST_VIOS

#####################################
# list of all Virtual Machines
ls $PATH_DATA | grep "collect_info." | cut -d"." -f2 > $LIST_VM

#####################################
# list all disks from DS8000 and serial number
for DS in `ls $PATH_DATA/dscli_lsfbvol.*`
do
    DS_SN=`cat $DS |  head -1 | awk '{print $13}' | cut -d"-" -f2`
    cat /dev/null > $TMP_DIR/DS.$DS_SN
    cat $DS | while read line
    do
	LUN_NAME=`echo $line | awk '{print $1" "$2}' | sed "s/\///" | sed "s/IBM.2107-//"`
	SZ=`echo $line | awk '{print $12" "$13}' | sed "s/-//"`
	echo $LUN_NAME" "$SZ  >> $TMP_DIR/DS.$DS_SN
    done
done

#########################################
# Collect all servers serial number
grep systemid $PATH_DATA/iosclilsdev-devsys0-attr.* | awk '{print $2}' | cut -d"," -f2 | sort > $TMP_FILE"1"
grep "IBM," $PATH_DATA/collect_info.* | cut -d"," -f2 | sort >> $TMP_FILE"1"

# supress duplicate entries in servers serial number
cat $TMP_FILE"1" | sort | uniq > $TMP_FILE

#***********************************************
#******** Ajouter correction lsmap wrong lpar_id
#***********************************************

#########################################
# Collect lpar_id from HMC
for file in `ls $PATH_DATA/lshwres.*`
do
   hmc=`echo $file | cut -d"." -f2`
   rm $TMP_DIR/lshwres.$hmc > /dev/null 2>&1
   cat $file | while read i
   do
        vios=`echo $i | awk '{print $1}'`
        if [[ "$vios" != "" ]]
        then
                echo $i | grep "#####" > /dev/null 2>&1
                if [ $? -eq 0 ]
                then
                        SN=$i 
                        TEST=1
                else
                    vios_id=`echo $i | awk '{print $2}'`
                    vios_id_hexa1=`convert_to_hexa $vios_id`
			echo $vios_id_hexa1
                    vios_id_hexa=`recreate_lpar_id $vios_id_hexa1`
                    slot="C"`echo $i | awk '{print $3}'`
                    lpar_id=`echo $i | awk '{print $4}'`
                    if [[ "$lpar_id" != "any" ]]
                    then
                            lpar_id_hexa1=`convert_to_hexa $lpar_id`
                            lpar_id_hexa=`recreate_lpar_id $lpar_id_hexa1`
                    else
                            lpar_id_hexa=$lpar_id
                    fi
                        
                    if [[ "$TEST" == "1" ]]
                    then
                        echo $SN $vios_id_hexa >> $TMP_DIR/lshwres.$hmc
                        TEST=0
                    fi
                    echo $slot $lpar_id_hexa $lpar_id >> $TMP_DIR/lshwres.$hmc
                fi
        else
                echo >> $TMP_DIR/lshwres.$hmc
                SN=""
        fi              
   done
        
done


#########################################
# print lsmap on VIOS
HDISK=""
for vios in `cat $LIST_VIOS`
do
   cat $PATH_DATA/iosclilsmap-all.$vios | egrep "vhost|LUN|Backing device|-----" | while read line
   do
        TEXT=`echo $line | awk '{print $1}' | cut -c1-5`
        case $TEXT in
                #"vhost")        echo $line | awk '{print $1" "$3}' >> $TMP_VIOS.$vios.lsmap ;;
                "vhost")    vhost=`echo $line | awk '{print $1}'`
			    slot=`echo $line | awk '{print $2}' | cut -d"-" -f3`
			    sn_vios=`cat $PATH_DATA/iosclilsdev-devsys0-attr.$vios | grep systemid | awk '{print $2}' | cut -c7-`
			    vios_id1=`cat $PATH_DATA/iosclilsdev-devsys0-attr.$vios | grep id_to_partition | awk '{print $2}' | tr 'A-Z' 'a-z' | cut -c 14-`
			    vios_id=`echo "0x000"$vios_id1`
				echo $vios_id
			    lpar_id=`grep -p "$sn_vios"  $TMP_DIR/lshwres.hmc* | grep -p "$vios_id" | grep "$slot" | tail -1 | awk '{print $2}'`
			    echo $vhost" "$lpar_id >> $TMP_VIOS.$vios.lsmap ;;
                "-----")    echo >> $TMP_VIOS.$vios.lsmap ;;
                "Backi")    HDISK=`echo $line | awk '{print $3}'`
                            echo $HDISK $LUN >> $TMP_VIOS.$vios.lsmap
                            LUN="";;
                "LUN")      LUN=`echo $line | awk '{print $2}'`;;

        esac
   done
done



#########################################
# Create a list of LPAR per serial number
for serial in `cat $TMP_FILE`
do
        echo "********* VIOS *********" > $TMP_DIR/list_server_per_sn.$serial
        grep $serial $PATH_DATA/iosclilsdev-devsys0-attr.* | cut -d"." -f2 | cut -d":" -f1 | while read vios
        do
                LIST_ID=""
                #cat $PATH_DATA/iosclilsmap-all.$vios | grep vhost | awk '{print $1" "$3}' | sort | while read vhost id
		cat $TMP_VIOS.$vios.lsmap | grep vhost | awk '{print $1" "$2}' | sort | while read vhost id
                do
                        if [[ "$id" == "0x00000000" ]]
                        then
                                id=$vhost
                        fi
                        LIST_ID=`echo $LIST_ID";"$id`
                done
                echo $vios":0x000"`cat $PATH_DATA/iosclilsdev-devsys0-attr.$vios | grep id_to_partition | awk '{print $2}' | tr 'A-Z' 'a-z' | cut -c 14-`":"$LIST_ID >> $TMP_DIR/list_server_per_sn.$serial
        done
        echo "********* VM *********" >> $TMP_DIR/list_server_per_sn.$serial
        grep $serial $PATH_DATA/collect_info.* | cut -d"." -f2 | cut -d":" -f1 | while read vm
        do
                echo $vm":0x000"`cat $PATH_DATA/collect_info.$vm | head -3 | tail -1 | cut -c 14- | tr 'A-Z' 'a-z'` >> $TMP_DIR/list_server_per_sn.$serial
        done
done
 
#########################################
# print hdisk on VIOS
for vios in `cat $LIST_VIOS`
do
   HDISK=""
   cat $PATH_DATA/iosclilsdev-vpd.$vios | egrep "hdisk|Serial Number" | while read line
   do
       if [[ `echo $HDISK` != "" ]]
       then
                serial=`echo $line | grep "Serial Number" | sed -e 's/Serial Number//' | sed -e 's/\.//g' `
                echo $HDISK $TYPE $serial >> $TMP_VIOS.$vios.pv
                HDISK=""
       fi
        echo $line | awk '{print $1}' | grep hdisk > /dev/null 2>&1
        if [ $? -eq 0 ]
        then

                HDISK=`echo $line | awk '{print $1}' | grep hdisk`
                echo $line | egrep "SCSI|SAS" > /dev/null 2>&1
                if [ $? -eq 0 ]
                then
                        TYPE="SCSI"
                else
                        echo $line | grep "2107" > /dev/null 2>&1
                        if [ $? -eq 0 ]
                        then
                                TYPE="MPIO"
                        else
                                TYPE="Unknown"
                        fi


                fi
        fi
   done
done




#########################################
# Main
#########################################
cat $HTML_CONFIG_DIR/header.txt | sed "s/date/$NUM/g" > $TMP_HTML_FILE



#for VM_NAME in `echo "uc4rback"`  # tsmr clkpgpfh"`
cat $LIST_VM  | while read VM_NAME
do
        echo $VM_NAME
        SERIAL_NUM=`grep "$VM_NAME:" $TMP_DIR/list_server_per_sn.* | cut -d":" -f1 | cut -d"." -f2`
        PARTITION_ID=`cat $TMP_DIR/list_server_per_sn.$SERIAL_NUM | grep "$VM_NAME:" | cut -d":" -f2`
        cat $TMP_DIR/list_server_per_sn.$SERIAL_NUM | grep ";$PARTITION_ID" | cut -d":" -f1 > $TMP_INFO.vios
        cat $TMP_DIR/list_server_per_sn.$SERIAL_NUM | grep ";$PARTITION_ID" | cut -d":" -f1
        NUM_VIOS=`cat $TMP_INFO.vios | wc -l | awk '{print $1}'`
        case $NUM_VIOS in
                0)      VIOS1=""
                        VIOS2="";;
                1)      VIOS1=`cat $TMP_INFO.vios`
                        VIOS2="";;
                2)      VIOS1=`head -1 $TMP_INFO.vios`
                        VIOS2=`tail -1 $TMP_INFO.vios`;;
        esac

        echo $VM_NAME $SERIAL_NUM $PARTITION_ID $VIOS1 $VIOS2

	create_info_vm
	for VG in `cat $TMP_INFO"9" $TMP_INFO"10"`
        do
                echo "#####$VG#####"
           cat $TMP_INFO"9" | grep "$VG"
            if [ $? -eq 0 ]
            then
		echo "########################## Active $VG ########################"
		active_vg
	    else
		echo "########################## Inactive $VG ########################"
		inactive_vg $VG
	    fi
            get_vios $VIOS1 $VG
            get_vios $VIOS2 $VG
            get_lun_id $VIOS1
	done
	cat $HTML_CONFIG_DIR/body6.txt >> $TMP_HTML_FILE


done
cat $HTML_CONFIG_DIR/footer.txt >> $TMP_HTML_FILE

echo "\n"
echo `date`" : End of "$sn
}

main > $logname 2>&1

exit

collect_info_lpar.sh

#!/bin/ksh
#set -x
#@(#) Recupere la configuration disk de chaque VIOS et VIOC (VIO Client)
########################################################################
# version 1.1 5-01-2010 Manu
# Ce script est appellé par le script collect_info_all_lpar.sh sur
# NIMH1, il peut tre lancé aussi sur chaque serveur NIM
########################################################################

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

USER_VIOS=padmin				# user ssh to VIOS
USER_VIOC=root					# user ssh to VIOC
PATH_DATA=$logpath/config_lpar		# directory to store collected informations
RET_DAY=15
DSH_WCOLL_VIOC=${DSH_WCOLL:-"$path_script/dsh_wcoll_all.cfg"} 
DSH_WCOLL_VIOS=${DSH_WCOLL_VIOS:-"$path_script/dsh_wcoll_vios.cfg"} 

###########################################################################
# initialize ()
#
# Parameters:
###########################################################################
initialize()
{
if [ ! -d $PATH_DATA ]
then
	mkdir -p $PATH_DATA
fi
find $PATH_DATA -type f | grep -v "index" | xargs rm -f

if [ ! -d $logpath ]
then
        mkdir -p $logpath
fi
}

###########################################################################
# usage ()
#
# Parameters:
###########################################################################
usage()
{
rep=$*
case "$rep" in
* )
        echo "Usage: "$0
        echo "\tPas de paramètre requis"
        echo "\tce script est appelle par collect_info_all_lpar.sh sur NIMH1"
        exit 1
        ;;
esac
}

###########################################################################
# dsh_vios ()
#
# Parameters:
#   - command to VIOS
#   + user USER_VIOS
#   + remote host WCOLL_VIOS
###########################################################################
dsh_vios()
{
c=$*
log=$PATH_DATA/`echo $c | tr -d " "`
echo $c $log

sed  '/^$/d' $DSH_WCOLL_VIOS         > $logpath/dcp_$$.list
sed  '/^ *$/d' $logpath/dcp_$$.list > $logpath/dcp_$$.list2
grep -v "^ *#" $logpath/dcp_$$.list2 > $logpath/dcp_$$.list 
grep -v "$(hostname)" $logpath/dcp_$$.list > $logpath/dcp_$$.list2 ; mv $logpath/dcp_$$.list2  $logpath/dcp_$$.list  # pas d'exécution locale 
LIST=$(cat $logpath/dcp_$$.list); rm -f $logpath/dcp_$$.list

for i in $LIST
do
  echo "$i:$NOCR"
  ping -c 1 $i > /dev/null 2>&1
  if [ $? -eq 0 ]
  then 
    ssh $USER_VIOS@$i "$c" > $log.$i
  else
     echo "$i doesn't ping"
  fi
done
}

###########################################################################
# dsh_vioc ()
#
# Parameters:
#   + user USER_VIOC
#   + remote host WCOLL_VIOC and WCOLL_EXCEPTION
###########################################################################
dsh_vioc()
{
log=$PATH_DATA/collect_info

sed  '/^$/d' $DSH_WCOLL_VIOC         > $logpath/dcp_$$.list
sed  '/^ *$/d' $logpath/dcp_$$.list > $logpath/dcp_$$.list2
grep -v "^ *#" $logpath/dcp_$$.list2 > $logpath/dcp_$$.list 
grep -v "$(hostname)" $logpath/dcp_$$.list > $logpath/dcp_$$.list2 ; mv $logpath/dcp_$$.list2  $logpath/dcp_$$.list  # pas d'exécution locale 
LIST=$(cat $logpath/dcp_$$.list); rm -f $logpath/dcp_$$.list

for i in $(echo $LIST" "$(hostname))
do
  echo "$i:$NOCR"
  ping -c 1 $i > /dev/null 2>&1
  if [ $? -eq 0 ]
  then
    collect_vioc $USER_VIOC $i > $log.$i
  else
     echo "$i doesn't ping"
  fi
done
}

###########################################################################
# collect_vioc ()
#
# Parameters:
#   - user USER_VIOC
#   - remote host WCOLL_VIOC
###########################################################################
collect_vioc () {
u=$1
h=$2
list_disk=$logpath/list_disk.txt

echo "############# Serial Number - Partition ID #############"
ssh $u@$h lsattr -El sys0 -a systemid -a id_to_partition | awk '{print $2}'

echo "############# lspv #############"
ssh $u@$h lspv

echo "############# Disk Size MB #############"
ssh $u@$h lspv > $list_disk
for HDISK in `cat $list_disk | egrep "concurrent|active" | awk '{print $1}'`
do
        echo $HDISK":" 
        ssh $u@$h lspv $HDISK | grep "TOTAL PPs:" | awk '{print $4}' | sed "s/(//"
done

echo "############# VG Size #############"
# size of VG active or concurrent 
for VG in rootvg `ssh $u@$h lsvg | grep -v rootvg | sort`
do
        egrep "active|concurrent" $list_disk | awk '{print $3}' | grep "$VG" > /dev/null 2>&1
        if [ $? -eq 0 ]
        then
                echo "$VG:"
                ssh $u@$h lsvg $VG | grep "TOTAL PPs:" | awk '{print $7}' | sed "s/(//"
                ssh $u@$h lsvg $VG | grep "USED PPs:" | awk '{print $6}' | sed "s/(//"
        fi
done

echo "############# lsvg -l #############"
for VG in rootvg `ssh $u@$h lsvg -o | grep -v rootvg | sort`
do
        ssh $u@$h lsvg -l $VG | grep -v "LV NAME"
done

echo "############# df -m #############"
ssh $u@$h df -m | egrep -v "%Used|/proc"

echo "############# Paging Space #############"
ssh $u@$h lsps -a

echo "############# Disk ID #############"
for HDISK in `ssh $u@$h lspv | awk '{print $1}'`
do
        ssh $u@$h lscfg -vl $HDISK
done
test -f $list_disk && rm -f $list_disk

}


###########################################################################
# main ()
#
# Collect informations about VIOS and VIOC to be able to create a 
# disk mapping from storage to VIOC
#   
###########################################################################
if [ $# -gt 0 ]
then
        usage $*
fi
main () {
echo `date`" : Begin of "$sn" "$(hostname)

initialize
for CMD in "ioscli lsmap -all" "ioscli lsdev -vpd" "ioscli lsdev -dev sys0 -attr"
do
	dsh_vios $CMD 
done

dsh_vioc
echo `date`" : End of "$sn" "$(hostname)
}

main 2>&1 | tee $logname

collect_info_ds8000.sh

#!/bin/ksh
#set -x
#############################################
#@(#) Recupere la configuration disk des DS8000 
#############################################
# version 1.1 5-01-2010 Manu
#############################################

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

PATH_DATA=$logpath/config_lpar		# directory to store collected informations
RET_DAY=15

###########################################################################
# initialize ()
#
# Parameters:
###########################################################################
initialize()
{
if [ ! -d $PATH_DATA ]
then
	mkdir -p $PATH_DATA
fi
if [ ! -d $logpath ]
then
        mkdir -p $logpath
fi
}

###########################################################################
# usage ()
#
# Parameters:
###########################################################################
usage()
{
rep=$*
case "$rep" in
* )
        echo "Usage: "$0
	echo "\tPas de paramètre requis"
	echo "\tce script appelle le script collect_info_lpar.sh sur tous les serveurs"
	echo "\tNIM et centralise les logs sur $(hostname)"
        exit 1
        ;;
esac
}

###########################################################################
# collect_ds8000 ()
#
# Parameters:
###########################################################################
collect_ds8000() {
cmd=$1

for DS_PROFILE in `ls /opt/ibm/dscli/profile | grep "read" | grep DS`
do
        DS_NAME=`echo $DS_PROFILE | cut -d"_" -f1`
        /opt/ibm/dscli/dscli $cmd -l  -cfg /opt/ibm/dscli/profile/$DS_PROFILE > $PATH_DATA/dscli_$cmd.$DS_NAME
done

}


###########################################################################
# main ()
#
# Collect informations about VIOS and VIOC to be able to create a 
# disk mapping from storage to VIOC
#   
###########################################################################
if [ $# -gt 0 ]
then
	usage $*
fi
main () {
echo `date`" : Begin of "$sn" "$(hostname)


for COMMAND in lshostconnect lsextpool lsfbvol lsvolgrp
do
	collect_ds8000 "$COMMAND"
done


echo `date`" : End of "$sn" "$(hostname)

}

main 2>&1 | tee $logname

collect_info_all_lpar.sh

#!/bin/ksh
#set -x
#############################################
#@(#) Recupere la configuration disk de chaque VIOS et VIOC (VIO Client)
#############################################
# ce script appelle le script collect_info_lpar.sh sur tous les serveurs
# NIM et centralise les logs sur NIM
# Il faudra ensuite lancer le script ./config_disk_vios.sh sur NIM
# pour reconstituer le mapping des disks
# version 1.1 5-01-2010 Manu
#############################################

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

WCOLL_NIM="nim"		# list of NIM servers
WCOLL_HMC="hmc"
PATH_DATA=$logpath/config_lpar		# directory to store collected informations
CMD_COLLECT=$path_script/collect_info_lpar.sh
RET_DAY=15
dest="$mail_system"
swap_max=20	# Threshold for swap on HMC

###########################################################################
# initialize ()
#
# Parameters:
###########################################################################
initialize()
{
if [ ! -d $PATH_DATA ]
then
	mkdir -p $PATH_DATA
fi
if [ ! -d $logpath ]
then
        mkdir -p $logpath
fi
}

###########################################################################
# usage ()
#
# Parameters:
###########################################################################
usage()
{
rep=$*
case "$rep" in
* )
        echo "Usage: "$0
	echo "\tPas de paramètre requis"
	echo "\tce script appelle le script collect_info_lpar.sh sur tous les serveurs"
	echo "\tNIM et centralise les logs sur $(hostname)"
        exit 1
        ;;
esac
}

###########################################################################
# dsh_nim ()
#
# Parameters:
#   + user USER_VIOC
#   + remote host WCOLL_VIOC and WCOLL_EXCEPTION
###########################################################################
dsh_nim()
{
host=$1

echo "$host:"
ping -c 1 $host > /dev/null 2>&1
if [ $? -eq 0 ]
then
	collect_nim $host 
else
	echo "$host doesn't ping"
fi
}

###########################################################################
# collect_nim ()
#
# Parameters:
#   - remote host WCOLL_VIOC
###########################################################################
collect_nim() {
h=$1

############# scp $h:$PATH_DATA/* $PATH_DATA #############
ssh $h $CMD_COLLECT
scp -p $h:$PATH_DATA/* $PATH_DATA

}


###########################################################################
# main ()
#
# Collect informations about VIOS and VIOC to be able to create a 
# disk mapping from storage to VIOC
#   
###########################################################################
if [ $# -gt 0 ]
then
	usage $*
fi
main () {
echo `date`" : Begin of "$sn" "$(hostname)

initialize

lsnim master > /dev/null 2>&1
if [ $? -ne 0 ]
then
	echo "Ce serveur n'est pas un NIM Master"
	exit 1
fi

# start the collection script on NIM
echo "$(hostname):"
$CMD_COLLECT

# start the collection script on the other NIM servers
#for HOST in $(echo $WCOLL_NIM | sed "s/$(hostname)//")
#do
#	dsh_nim $HOST
#done

# Collect disk informations
for DS_PROFILE in `ls /opt/ibm/dscli/profile | grep "read" | grep DS`
do
	DS_NAME=`echo $DS_PROFILE | cut -d"_" -f1`
	echo "$DS_NAME:"
	/opt/ibm/dscli/dscli lsfbvol -l  -cfg /opt/ibm/dscli/profile/$DS_PROFILE > $PATH_DATA/dscli_lsfbvol.$DS_NAME
done

# Collect HMC informations
for hmc in $(echo $WCOLL_HMC)
do
	echo "$hmc:"
        echo > $PATH_DATA/lshwres.$hmc
        ssh hscroot@$hmc "lssyscfg -r sys -F name serial_num" > $PATH_DATA/lssyscfg
        for sysname in `cat $PATH_DATA/lssyscfg | awk '{print $1}'`
        do
                sys=`cat $PATH_DATA/lssyscfg | grep "$sysname"`
                for vios in `ssh hscroot@$hmc "lssyscfg -r lpar -m $sysname -F name lpar_env" | grep "vioserver" | sed "s/vioserver//"`
                do
                        echo "\n""##### "$sys >> $PATH_DATA/lshwres.$hmc
                        ssh hscroot@$hmc "lshwres -r virtualio --rsubtype scsi -m $sysname --filter lpar_names=$vios -F lpar_name lpar_id slot_num remote_lpar_id remote_lpar_name" | grep -v "No results were found" >> $PATH_DATA/lshwres.$hmc
                done
        done
	# Send message is swap is higher than threshold
	ssh hscroot@$hmc "cat /proc/swaps" | grep partition | awk '{print $3" "$4}' > $logpath/swap_hmc.log
	swap_kb=`cat $logpath/swap_hmc.log | awk '{print $1}'`
	swap_used=`cat $logpath/swap_hmc.log | awk '{print $2}'`
	let swap_pct="(100 * $swap_used / $swap_kb)"
	if [ $swap_pct -gt $swap_max ]
	then
        	mail -s "Swap used on HMC $hmc is $swap_pct%" $dest < /dev/null
		echo "Swap used on HMC $hmc is $swap_pct%"
	fi
	rm $logpath/swap_hmc.log

done

test -f $PATH_DATA/lssyscfg && rm -f $PATH_DATA/lssyscfg

echo `date`" : End of "$sn" "$(hostname)

}

main 2>&1 | tee $logname

HTML directory config_dir_vios_html body1.txt

    <tr>
      <td style="border: 1px solid rgb(0, 0, 0); color: red;"
 rowspan="row_span" align="left" height="240"
 valign="top"><b><font size="3">vm_name</font></b></td>

body2.txt

      <td style="border: 1px solid rgb(0, 0, 0);" rowspan="row_span"
 align="left" valign="top"><big><span
 style="font-weight: bold;">vg_name</span><br>
size size_gb<br>
used percent</big></td>

body3.txt

      <td style="border: 1px solid rgb(0, 0, 0);" rowspan="row_span"
 align="left" valign="top"><big><font
 face="Times New Roman" size="2">fs_name
</font></big></td>

body4.txt

     <td style="border: 1px solid rgb(0, 0, 0);" rowspan="row_span"
 align="center" valign="top"><big><font
 face="Times New Roman" size="2">info
</font></big></td> 

body5.txt

      <td style="border: 1px solid rgb(0, 0, 0);" rowspan="row_span"
 align="left" valign="top"><big><span
 style="font-weight: bold;">vg_name</span>
</big></td>

body6.txt

    <tr>
	<td align="left" height="17"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
	<td align="left"><br>
	</td>
    </tr>

footer.txt

  </tbody>
</table>
<!-- ************************************************************************** -->
</body>
</html>

header.txt

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
  <meta content="text/html; charset=windows-1252"
 http-equiv="CONTENT-TYPE">
  <title></title>
  <meta content="OpenOffice.org 2.3 (Win32)" name="GENERATOR">
  <meta content="ei" name="AUTHOR">
  <meta content="20070919;21330673" name="CREATED">
  <meta content="ei" name="CHANGEDBY">
  <meta content="20070919;21512178" name="CHANGED">
  <style>
<!-- BODY,DIV,TABLE,THEAD,TBODY,TFOOT,TR,TH,TD,P { font-family:"Arial"; font-size:x-small }
-->
  </style>
</head>
<body style="color: rgb(0, 0, 0);">
<br>
<h1 style="text-align: left;">&nbsp;&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span
 style="text-decoration: underline;">Configuration
disk des machines virtuelles AIX        date
</span></h1>
<br>
<table border="0" cellspacing="0" cols="13"
 frame="void" rules="none">
  <colgroup><col width="102"><col width="86"><col
 width="230"><col width="86"><col width="86"><col
 width="86"><col width="121"><col width="86"><col
 width="86"><col width="86"><col width="86"><col
 width="123"><col width="86"></colgroup> <tbody>
    <tr>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" height="21" width="102"><b><font
 face="Times New Roman" size="2">VM name</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="86"><b><font
 face="Times New Roman" size="2">VG name</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="230"><b><font
 face="Times New Roman" size="2">filesystems</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="86"><b><font
 face="Times New Roman" size="2">FS SIZE</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="86"><b><font
 face="Times New Roman" size="2">% used</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="86"><b><font
 face="Times New Roman" size="2">VM hdisk</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="121"><b><font
 face="Times New Roman" size="2">VM disk ID</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="86"><b><font
 face="Times New Roman" size="2">VIOS1</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="86"><font
 face="Times New Roman"><br>
      </font></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="86"><b><font
 face="Times New Roman" size="2">VIOS2</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="86"><font
 face="Times New Roman"><br>
      </font></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="123"><b><font
 face="Times New Roman" size="2">IBM LUN ID</font></b></td>
      <td style="border: 1px solid rgb(0, 0, 0);"
 align="center" width="86"><b><font
 face="Times New Roman" size="2">LUN size</font></b></td>
    </tr>
    <tr>
      <td align="left" height="17"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
      <td align="left"><br>
      </td>
    </tr>
aix/scripts.txt · Last modified: 2021/01/01 21:21 (external edit)