Thursday 15 January 2009

Storage configuration management for 3510 and 2540

OS: solaris 10 intel
Server: x4150 , x4100 M2
Storage: SAN(HITACHI,EMC), StorageTek 3510, StorageTek 2540

I need to do kind of configuration management or change management. In case of any problem I want to know what was it before. So my script collects generic information like df, ifconfig, cfgadm,vfstab,luxadm outputs,. If you have storage device 2540 then collect information sscs , if you have 3510 then collects information with sccli command. I added information related to aLom and iLom via ipmitool.
I scp info to central machine. You can find how to do it from this blog, check previous articles.


#!/usr/bin/bash
command=/opt/SUNWstkcam/bin/sscs
OUTPUT=/path/storageinfo_$(hostname)_$(date +%Y%m%d)
echo /dev/null > $OUTPUT
date >> $OUTPUT
prtdiag >> $OUTPUT
df -h >> $OUTPUT
cat /etc/vfstab >> $OUTPUT
ifconfig -a >> $OUTPUT
netstat -rn >> $OUTPUT
cfgadm -al >> $OUTPUT
luxadm display $(luxadm probe | grep "Logical Path" | awk -F: '{print $2}') >> $OUTPUT
luxadm -e port | awk '{print $1}' | while read dump_map
do
luxadm -e dump_map $dump_map >> $OUTPUT
done

# Sun StorageTek 2540 Array part
if [[ $(luxadm display $(luxadm probe | grep "Logical Path" | awk -F: '{print $2}') | grep "Product ID" | grep -v Universal | awk -F: '{print $2}' | grep LCSM100_F |wc -l) -ge 1 ]]
then
$command list array | awk '{print $2}' | while read array
do
$command list -a $array controller >> $OUTPUT
$command list -a $array date >> $OUTPUT
$command list -a $array disk >> $OUTPUT
$command list -a $array fcport >> $OUTPUT
$command list -a $array firmware >> $OUTPUT
$command list -a $array host >> $OUTPUT
$command list -a $array hostgroup >> $OUTPUT
$command list -a $array initiator >> $OUTPUT
$command list -a $array jobs >> $OUTPUT
$command list -a $array license >> $OUTPUT
$command list -a $array mapping >> $OUTPUT
$command list -a $array os-type >> $OUTPUT
$command list -a $array pool >> $OUTPUT
$command list -a $array profile >> $OUTPUT
$command list -a $array registeredarray >> $OUTPUT
$command list -a $array snapshot >> $OUTPUT
$command list -a $array tray >> $OUTPUT
$command list -a $array vdisk >> $OUTPUT
$command list -a $array volume >> $OUTPUT
$command list -a $array volume-copy >> $OUTPUT
$command list -d $array fru
done

$command list alarm >> $OUTPUT
$command list array >> $OUTPUT
$command list device >> $OUTPUT
$command list devices >> $OUTPUT
$command list event >> $OUTPUT
$command list log >> $OUTPUT
$command list mgmt-sw >> $OUTPUT
$command list notification >> $OUTPUT
$command list site >> $OUTPUT
$command list storage-system >> $OUTPUT
$command list userrole >> $OUTPUT
fi


if [[ $(luxadm display $(luxadm probe | grep "Logical Path" | awk -F: '{print $2}') | grep "Product ID" | grep -v Universal | awk -F: '{print $2}' | grep "StorEdge 3510" |wc -l) -ge 1 ]]
then
command="sccli $(sccli -l|awk '{print $1}' | head -n 1)"
$command show access-mode >> $OUTPUT
$command show auto-write-through-trigger >> $OUTPUT
$command show battery-status >> $OUTPUT
$command show bypass raid >> $OUTPUT
$command show cache-parameters >> $OUTPUT
$command show channels >> $OUTPUT
$command show clone >> $OUTPUT
$command show controller-date >> $OUTPUT
$command show controller-name >> $OUTPUT
$command show disks >> $OUTPUT
$command show disk-array >> $OUTPUT
$command show drive-parameters >> $OUTPUT
$command show enclosure-status >> $OUTPUT
$command show events >> $OUTPUT
$command show frus >> $OUTPUT
$command show host-parameters >> $OUTPUT
$command show host-wwn-names >> $OUTPUT
$command show inquiry-data >> $OUTPUT
$command show ip-address >> $OUTPUT
$command show logical-drives >> $OUTPUT
$command show logical-volumes >> $OUTPUT
$command show lun-maps >> $OUTPUT
$command show media-check >> $OUTPUT
$command show network-parameter >> $OUTPUT
$command show partitions >> $OUTPUT
$command show peripheral-device-status >> $OUTPUT
$command show port-wwns >> $OUTPUT
$command show protocol >> $OUTPUT
$command show redundancy-mode >> $OUTPUT
$command show redundant-controller-configuration >> $OUTPUT
$command show rs232-configuration >> $OUTPUT
$command show safte-devices >> $OUTPUT
$command show sata-mux >> $OUTPUT
$command show sata-router >> $OUTPUT
$command show ses-devices >> $OUTPUT
$command show shutdown-status >> $OUTPUT
$command show stripe-size-list >> $OUTPUT
$command show unique-identifier >> $OUTPUT
#actually command below includes all information above
$command show configuration >> $OUTPUT

fi


echo "###############################IPMPITOOl##################################" >> $OUTPUT
ipmitool lan print >> $OUTPUT
ipmitool chassis status >> $OUTPUT
ipmitool mc info >> $OUTPUT
ipmitool sdr >> $OUTPUT
ipmitool sensor >> $OUTPUT
ipmitool fru >> $OUTPUT
ipmitool sel >> $OUTPUT
ipmitool user list 1 >> $OUTPUT



scp $OUTPUT tbackup@machine:/path/storageinfo_$(hostname)_$(date +%Y%m%d)

Background Processes in Unix/Linux

The & is an important little character in UNIX; it means "run the command in the background"; i.e., detach it from the window it was started from, so it does not block the command line.

Should the program ever try to read from the terminal window, it will be suspended, until the user "brings it to the foreground"; i.e., brings it to the state it would have had without the & to begin with.

To bring a program to the foreground, use "fg" or "%". If you have more than one background job to choose from ("jobs" will show you), then use for example "%2" to choose the second one.
Important:

If you forget to give the & at the end of line, and the process blocks the command input to the terminal window, you can put the process in the background "after the fact", by using Ctrl-Z. The process is suspended, and you get the command prompt back. The first thing you should do then is probably to give the command "bg", that resumes the process, but now in the background.

taken from http://www.astro.ku.dk/comp-phys/tutorials/background.shtml