retire-emc-dgc-disk-removal

retire_emc_dgc_disk_removal

 * OBSELETE** - updated and incorporated into MASTER Retirement Scripts

code format="bash"
 * 1) !/bin/bash

export PATH="/usr/sbin:/usr/ccs/bin:/usr/bin:/usr/lib:$PATH:/etc:/usr/platform/$(/bin/uname -m)/sbin:/usr/tools/bin:/usr/bin"

if $EUID -ne 0 ; then echo "This script must be run as root" 1>&2 exit 1 fi
 * 1) Check to see if the user is root

/etc/init.d/oracle stop;/etc/init.d/syslog stop;/etc/init.d/nqmdaemon stop
 * 1) Stop Services

rm -rf /var/tmp/emc mkdir /var/tmp/emc cp /net/gutstools/guts_dev/distr/scripts/emc_remove_devices.pl /var/tmp/emc || { echo "emc_remove_devices.pl couldn't be copied down...exiting."; exit 1; } cd /var/tmp/emc || { echo "/var/tmp/emc doesn't exist, exiting."; exit 1; } rm device_file

mount | grep -v "/ " | grep -v "/usr " | grep -v "/proc" | grep -v "/home" | \ grep -v "/var " | grep -v "/tmp" | grep -v "/opt " | grep -v "/var/run" | \ grep -v "/dev/fd" | grep -v "/etc/mnttab" | grep -v "/usr/tools" | awk '{print $1}' >> /mount.list
 * 1) Unmount all extra filesytems

COUNT=1 while $COUNT < 6 ; do                for i in `cat /mount.list`; do                        umount $i 2> output #echo "Mount point is $i" done #COUNT=$(($COUNT + 1)) let COUNT=COUNT+1 done mount echo "Are all extra filesystems unmounted? [y/n]" read answer
 * 1) Run mount again to visually verify everything removed

if [ "$answer" = "n" ]; then echo "Please manually unmount what's left and then re-run the script." echo "Also, please report the offending filesystem(s) to Chad" echo "to be included the script for future use." exit 1 fi

/usr/tools/emc/inq -nocapacity | grep EMC | tr 'd' ' ' | tr 's' ' ' >> emc_tmp /usr/tools/emc/inq -nocapacity | grep DGC | tr 'd' ' ' | tr 's' ' ' >> dgc_tmp
 * 1) Generate tmp files for each storage type

if [ -s emc_tmp ]; then echo "EMC devices found. Processing..."

while read LINE do           DEVICE=`echo $LINE | awk '{print $4}'` SERIAL=`echo $LINE | awk '{print $(NF-0)}'`

echo "d$DEVICE $SERIAL" >> devfile_tmp done < "emc_tmp"

cat devfile_tmp | sort | uniq >> device_file

# Clean up   rm emc_tmp; rm devfile_tmp

# Create the necessary files perl emc_remove_devices.pl -d device_file > remove.log

# Email yourself the info that goes in the CR   echo "Enter your Lilly email address:" read EMAIL echo -ne "`cat *.output *.log *.ksh` \n\nPer UNX-OSI-504, the disk removal data above must be reviewed and approved.\nReviewer will indicate review by placing the word reviewed in the\nDescription/Notes field and will indicate approval by adding an approval on\nthe Approval tab." | mailx -s "EMC Disk Removal for $(uname -n)" $EMAIL echo -ne "Copy the below input into the 2nd EMC Disk Removal CR (the one you cut to GSMO)\n\n `cat device_file`" | mailx -s "2nd CR for $(uname -n)" $EMAIL echo "Email sent"

# Spit out the final command to run after the CR is approved echo "Run the following command on the server AFTER the CR is approved:" echo "ksh /var/tmp/emc/*.ksh" else echo "No EMC devices found." fi

if [ -s dgc_tmp ]; then echo "DGC devices found. Processing..."

# Deport the DG   for i in `vxdisk list | awk '{print $4}' | sort | uniq | grep -v GROUP | grep -vi ootdg | grep -v "-"`; do vxdg deport $i; done # Unsetup all the disks for i in `vxdisk list | awk -Fs '{print $1}'`; do /usr/lib/vxvm/bin/vxdiskunsetup -C $i; done

vxprint -Aht
 * 1) Verify vxprint looks good

echo "Do you see only local disks listed in the 2nd to last column? [y/n]" read answer

if [ "$answer" = "y" ]; then # Email yourself the info that goes in the CR           echo "Enter your Lilly email address:" read EMAIL

echo -ne "INQ output: \n\n `/usr/tools/emc/inq -nocapacity | grep DGC` \n\n VXPRINT -Aht output: \n\n `vxprint -Aht` \n\nReviewer will indicate review by placing the word reviewed in the\nDescription/Notes field." | mailx -s "DGC Disk Removal for $(uname -n)" $EMAIL echo "Email sent" else echo "There is probably at least one filesystem in use." echo "Please use the fuser command to identify and free it up and then re-run this script" else echo "No DGC devices found." fi

code

emc_removal.txt notes
code format="perl" rm -rf /var/tmp/emc cp -r /net/goober/scratch/emc /var/tmp cd /var/tmp/emc rm device_file vxdisk list


 * 1) Paste all the relevant lines from vxdisk list into waiting screen
 * 2) Then CTRL-D to kick it off

cat | perl -e 'for $i (<>) { $i =~ s/\s+.*$//s; for (`/usr/tools/emc/inq`) { next if (/d0s/||!/rdsk\/$i/); split(/[\sds]+/,$_); print"d$_[3] $_[-2]\n"; }}' \ >device_file cat device_file

perl emc_remove_devices.pl -d device_file >remove.log

echo -ne "`cat *.output *.log *.ksh` \n\nPer UNX-OSI-504, the disk removal data above must be reviewed and approved.\nReviewer will indicate review by placing the word reviewed in the\nDescription/Notes field and will indicate approval by adding an approval on\nthe Approval tab." | mailx -s $(uname -n) criderch@lilly.com

ksh /var/tmp/emc/*.ksh


 * 1) Per UNX-OSI-504, the disk removal data above must be reviewed and approved.
 * 2) Reviewer will indicate review by placing the word reviewed in the
 * 3) Description/Notes field and will indicate approval by adding an approval on
 * 4) the Approval tab.

code

retire_emc_disk_removal
code format="bash"
 * 1) !/bin/bash

export PATH="/usr/sbin:/usr/ccs/bin:/usr/bin:/usr/lib:$PATH:/etc:/usr/platform/$(/bin/uname -m)/sbin:/usr/tools/bin:/usr/bin"

/etc/init.d/oracle stop;/etc/init.d/syslog stop;/etc/init.d/nqmdaemon stop
 * 1) Stop Services

rm -rf /var/tmp/emc cp -r /net/goober/scratch/emc /var/tmp cd /var/tmp/emc || { echo "/var/tmp/emc doesn't exist, exiting."; exit 1; } rm device_file

/usr/tools/emc/inq -nocapacity | grep EMC | tr 'd' ' ' | tr 's' ' ' >> inq_tmp /usr/tools/emc/inq -nocapacity | grep DGC | tr 'd' ' ' | tr 's' ' ' >> inq_tmp

while read LINE do DEVICE=`echo $LINE | awk '{print $4}'` SERIAL=`echo $LINE | awk '{print $(NF-0)}'`

echo "d$DEVICE $SERIAL" >> devfile_tmp done < "inq_tmp"

cat devfile_tmp | sort | uniq >> device_file

rm inq_tmp; rm devfile_tmp
 * 1) Clean up

perl emc_remove_devices.pl -d device_file >remove.log
 * 1) Create the necessary files

echo "Enter your Lilly email address:" read EMAIL echo -ne "`cat *.output *.log *.ksh` \n\nPer UNX-OSI-504, the disk removal data above must be  reviewed and approved.\nReviewer will indicate review by placing the word reviewed in           the\nDescription/Notes field and will indicate approval by adding an approval on\nthe Approval  tab." | mailx -s "EMC Disk Removal for $(uname -n)" $EMAIL echo -ne "Copy the below input into the 2nd EMC Disk Removal CR (the one you cut to GSMO)\n\n `cat device_file`" | mailx -s "2nd CR for $(uname -n)" $EMAIL echo "Email sent"
 * 1) Email yourself the info that goes in the CR

echo "Run the following command on the server AFTER the CR is approved:" echo "ksh /var/tmp/emc/*.ksh"
 * 1) Spit out the final command to run after the CR is approved

code