Python Script to Capture Information - Solaris |
|
Contents
Objective
This
Python Script will enable us to gather necessary information related to
Migration Activity and will also help us in identifying details requiring our
attention for further troubleshooting if need be.
General Information
Task/Process Name:
|
Python Script to Capture Information - Solaris
|
|
Category:
|
Informational
|
|
Author:
|
Sri Krishna
Chirumarri
|
|
Intended
Audience:
|
Infrastructure
Operations ( Solaris )
|
|
Skillset
Requirements:
|
Solaris System
Administrator
|
|
Linux
Flavor & Version:
|
Solaris 9 & 10
|
|
Required
Python Version:
|
2.7 & 2.6
|
|
Requested
By:
|
PM Team
|
Date:
01/02/18
|
Version control
Date
|
Version
|
Next Review
Date
|
Comments/Remarks
|
Owner
|
04/19/18
|
1.0
|
|
Initial
version
|
Sri Krishna Chirumarri
|
05/05/18
|
1.1
|
|
Revised
Draft
|
Sri Krishna Chirumarri
|
05/23/18
|
1.2
|
|
Revised
Draft
|
Sri Krishna Chirumarri
|
06/01/18
|
1.3
|
|
Revised
Draft
|
Sri Krishna Chirumarri
|
Script Execution details
The script will specifically work for Solaris machines with
Solaris OS 9 & 10. It is a menu based system providing us with 3 options
namely Pre-Checks, Post-Checks and Compare_Pre_Post. It will also provide tar
files for Pre and Post checks.
Both Pre-Checks and Post-Checks will generate files related
to the configurations within the server and place it into a folder that is
provided as per the script.
Pre-Checks option will be selected before the start of data
migration activity to capture configuration details of the Linux machine which
will be used at a later stage. Once the storage activity is completed, we will
run second option which is Post-checks.
The 3rd option (Compare_Pre_Post) will be used to
verify if there are any changes in the configurations or command outputs. This
will help us in identifying details requiring our attention for further
troubleshooting.
Script
#!/usr/bin/env python
# Purpose :
To Collect information from the server before and after migration
activity.
# To compare pre and post
migration information for any discrepancies.
# Author :
Sri Krishna Chirumarri
# Version :
1.1
# Details :
This is a menu based script that will ask you to enter your choice of
preference.
# Execution :
Interactive Menu to choose your option for the respective activity
import os
import sys
import platform
import commands
import re
import string
import filecmp
#import zipfile
#import shutil
#import tarfile
def menu():
print "++++++++++ Migration Menu
++++++++++\n"
print "Pre-Checks : 1"
print "Post-Checks : 2"
print "Comparision : 3"
print "Quit : 0"
print
"\n++++++++++++++++++++++++++++++++++\n"
menu()
change_number =
raw_input("Please enter the change number: ")
hostname=commands.getoutput('hostname')
if
os.path.isdir("/var/crash") is False:
os.mkdir("/var/crash")
os.mkdir("/var/crash/%s" %
change_number)
os.chdir("/var/crash/%s" %
change_number)
print "Current Working directory
is : /var/crash/%s" % change_number
elif
os.path.isdir("/var/crash") and
os.path.isdir("/var/crash/%s" % change_number):
os.chdir("/var/crash/%s" %
change_number)
print "\nCurrent Working
Directory: " + os.getcwd()
else:
os.mkdir("/var/crash/%s" %
change_number)
os.chdir("/var/crash/%s" %
change_number)
print "Current Working directory
is : /var/crash/%s" % change_number
def pre_checks():
print "Pre Migration
Verification"
commands.getoutput('echo | format >
echo_format.out.before')
commands.getoutput('powermt display
dev=all > powermt_display_dev_all.out.before')
commands.getoutput('cat /etc/vfstab
> vfstab.out.before')
commands.getoutput('cfgadm -al >
cfgadm-al.out.before')
commands.getoutput('swap -l >
swap-l.out.before')
commands.getoutput('fcinfo hba-port -l
> fcinfo_hba-port-l.out.before')
commands.getoutput('fcinfo lu -v >
fcinfo_lu-v.out.before')
commands.getoutput('cfgadm -al -o
show_scsi_lun > cfgadm-al-o-show_scsi_lun.out.before')
commands.getoutput('luxadm -e port >
luxadm-e-port.out.before')
# Dynamic Multipath Related Information
commands.getoutput('mpathadm list
lu > mpathadm_list_lu.out.before')
commands.getoutput('mpathadm show lu
/dev/rdsk/c*t*d* > mpathadm_show_lu.out.before')
commands.getoutput('mpathadm list
mpath-support > mpathadm_list_mpath-support.out.before')
commands.getoutput('mpathadm show
mpath-support libmpscsi_vhci.so >
mpathadm_show_mpath-support_libmpscsi_vhci.so.out.before')
#commands.getoutput('mpathadm show
mpath-support <library name> >
mpathadm_show_mpath-support.out.before')
commands.getoutput('df -k >
df-k.out.before')
commands.getoutput('prtvtoc
/dev/rdsk/c*t*d*s2 > prtvtoc.out.before')
commands.getoutput('date >
date.out.before')
commands.getoutput('hostid >
hostid.out.before')
commands.getoutput('hostname >
hostname.out.before')
commands.getoutput('ifconfig -a >
ifconfig-a.out.before')
commands.getoutput('isainfo -kv >
isainfo-kv.out.before')
commands.getoutput('modinfo >
modinfo.out.before')
commands.getoutput('mount >
mount.out.before')
commands.getoutput('mount -p >
mount-p.out.before')
commands.getoutput('pkginfo -l >
pkginfo-l.out.before')
commands.getoutput('psrinfo -p >
psrinfo-p.out.before')
commands.getoutput('mpathadm list
initiator-port > mpathadm_list_initiator-port.out.before')
commands.getoutput('prtconf -vp >
prtconf-vp.out.before')
commands.getoutput('prtdiag -v >
prtdiag-v.out.before')
commands.getoutput('prtpicl >
prtpicl.out.before')
commands.getoutput('prtpicl -v >
prtpicl-v.out.before')
commands.getoutput('prtpicl -v -c
scsi-fcp > prtpicl-v-c_scsi-fcp.out.before')
commands.getoutput('ulimit -a >
ulimit-a.out.before')
commands.getoutput('uname -a >
uname-a.out.before')
commands.getoutput('uptime > uptime.out.before')
commands.getoutput('arp -a >
arp-a.out.before')
commands.getoutput('crontab -l >
crontab-l.out.before')
commands.getoutput('dmesg >
dmesg.out.before')
commands.getoutput('env >
env.out.before')
commands.getoutput('iostat -En >
iostat-En.out.before')
commands.getoutput('ipcs -a >
ipcs-a.out.before')
commands.getoutput('ipcs -msa >
ipcs-msa.out.before')
commands.getoutput('ls -l /etc/rcS.d
> ls-l_etc_rcS.d.out.before')
commands.getoutput('ls -l
/kernel/drv > ls-l_kernel_drv.out.before')
commands.getoutput('ls -Ralsi /dev >
ls-Ralsi_dev.out.before')
commands.getoutput('ls -Ralsi /devices
> ls-Ralsi_devices.out.before')
commands.getoutput('ls -Ralsi /etc >
ls-Ralsi_etc.out.before')
commands.getoutput('netstat -a >
netstat-a.out.before')
commands.getoutput('netstat -r >
netstat-r.out.before')
commands.getoutput('netstat -nr >
netstat-nr.out.before')
commands.getoutput('prstat 2 5 >
prstat.out.before')
commands.getoutput('prtconf -v >
prtconf-v.out.before')
commands.getoutput('ps -efl >
ps-efl.out.before')
commands.getoutput('/usr/ucb/ps -aux
> ps-aux.out.before')
commands.getoutput('rpcinfo >
rpcinfo.out.before')
commands.getoutput('rpcinfo -p >
rpcinfo-p.out.before')
commands.getoutput('sysdef >
sysdef.out.before')
commands.getoutput('vmstat 2 5 >
vmstat.out.before')
commands.getoutput('who -b >
who-b.out.before')
commands.getoutput('fmadm faulty >
fmadm_faulty.out.before')
commands.getoutput('fmdump -V >
fmdump-V.out.before')
commands.getoutput('fmdump -eV >
fmdump-eV.out.before')
commands.getoutput('svcs -v >
svcs-v.out.before')
#commands.getoutput('svcs -xv '*' >
svcs-xv.out.before')
commands.getoutput('cat /etc/hosts >
etc-hosts.out.before')
commands.getoutput('cat /etc/mnttab
> mnttab.out.before')
commands.getoutput('cat
/etc/nsswitch.conf > nsswitch.conf.out.before')
commands.getoutput('cat
/etc/cfg/fp/fabric_WWN_map > fabric_WWN_map.out.before')
commands.getoutput('cat
/etc/driver_aliases > driver_aliases.out.before')
commands.getoutput('cat /etc/hba.conf
> hba.conf.out.before')
commands.getoutput('cat
/etc/name_to_major > name_to_major.out.before')
commands.getoutput('cat
/etc/path_to_inst > path_to_inst.out.before')
commands.getoutput('cat /etc/release
> release.out.before')
commands.getoutput('cat
/etc/resolv.conf > resolv.conf.out.before')
commands.getoutput('cat /etc/system
> etc_system.out.before')
# Configuration Files in /kernel/drv/
commands.getoutput('ls -l /kernel/drv/
> kernel_drv_conf_files.out.before')
kernel_drv_conf_list =
commands.getoutput("ls -l /kernel/drv/ | awk '{print
$NF}'").split('\n')
commands.getoutput('echo
"Configuration Files in /kernel/drv folder : " %s >>
/var/crash/%s/kernel_drv_conf_list.out.before' % (kernel_drv_conf_list,change_number))
commands.getoutput('echo "\n"
>> /var/crash/%s/kernel_drv_conf_list.out.before' % change_number)
for i in kernel_drv_conf_list:
commands.getoutput('echo
"\n" >> /var/crash/%s/kernel_drv_conf_list.out.before' %
change_number)
commands.getoutput('echo
"==============================" >>
/var/crash/%s/kernel_drv_conf_list.out.before' % change_number)
commands.getoutput('echo %s
>> /var/crash/%s/kernel_drv_conf_list.out.before' % (i,change_number))
commands.getoutput('echo
"==============================" >>
/var/crash/%s/kernel_drv_conf_list.out.before' % change_number)
commands.getoutput('cat
/kernel/drv/%s >> /var/crash/%s/kernel_drv_conf_list.out.before' %
(i,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/kernel_drv_conf_list.out.before' %
change_number)
commands.getoutput('cat
/etc/lvm/md.tab > md.tab.out.before')
# SVM Commands
metastat_package =
commands.getoutput('pkginfo -l SUNWmdu | grep -i "STATUS"')
if 'installed' in metastat_package:
commands.getoutput('metastat
> metastat.out.before')
commands.getoutput('metastat -p
> metastat-p.out.before')
commands.getoutput('metadb >
metadb.out.before')
commands.getoutput('metaset
> metaset.out.before')
# Zones Related Information
zoneadm_package =
commands.getoutput('pkginfo -l SUNWzoneu | grep -i "STATUS"')
if 'installed' in zoneadm_package:
commands.getoutput('zoneadm
list -v > zoneadm_list-v.out.before')
commands.getoutput('zoneadm
list > zoneadm_list.out.before')
commands.getoutput('zoneadm
list -civ > zoneadm_list-civ.out.before')
zpool_package =
commands.getoutput('pkgchk -l -p /usr/sbin/zpool | grep -i "status"')
if 'installed' in zpool_package:
commands.getoutput('zpool list
> zpool_list.out.before')
commands.getoutput('zpool
iostat > zpool_iostat.out.before')
commands.getoutput('zpool
iostat -v > zpool_iostat-v.out.before')
commands.getoutput('zpool
iostat -x > zpool_iostat-x.out.before')
commands.getoutput('zpool status -v
> zpool_status-v.out.before')
commands.getoutput('zfs get
compression > zfs_get_compression.out.before')
#localzones_list =
commands.getoutput("zoneadm list | grep -v global").split('\n')
#commands.getoutput('echo "Local
Zones Information : " %s >>
/var/crash/%s/localzones_info.out.before' % (localzones_list,change_number))
#commands.getoutput('echo
"\n" >> /var/crash/%s/localzones_info.out.before' %
change_number)
#for i in localzones_list:
#commands.getoutput('echo "\n" >>
/var/crash/%s/localzones_info.out.before' % change_number)
#commands.getoutput('echo
"==============================" >>
/var/crash/%s/localzones_info.out.before' % change_number)
#commands.getoutput('echo %s
>> /var/crash/%s/localzones_info.out.before' % (i,change_number))
#commands.getoutput('echo
"==============================" >>
/var/crash/%s/localzones_info.out.before' % change_number)
#commands.getoutput('zonecfg -z %s
info >> /var/crash/%s/localzones_info.out.before' % (i,change_number))
#commands.getoutput('echo
"\n" >> /var/crash/%s/localzones_info.out.before' %
change_number)
# Veritas Volume Manager Disk
Information
if
os.path.isdir("/opt/VRTS/bin") is True:
commands.getoutput('pkginfo -l
VRTSvxvm > pkginfo-l_VRTSvxvm.out.before')
# Veritas Disk Information
commands.getoutput('/opt/VRTS/bin/vxdisk
list > vxdisk_list.out.before')
commands.getoutput('/opt/VRTS/bin/vxdisk -s list >
vxdisk-s_list.out.before')
commands.getoutput('/opt/VRTS/bin/vxdisk -eo alldgs list >
vxdisk-eo-alldgs-list.out.before')
commands.getoutput('/opt/VRTS/bin/vxprint -ht >
vxprint-ht.out.before')
vxdisklist =
commands.getoutput("/opt/VRTS/bin/vxdisk list | grep -v DEVICE | awk
'{print $1}'").split('\n')
commands.getoutput('echo
"Veritas Disk Information : " %s >>
/var/crash/%s/vxdisk_info.out.before' % (vxdisklist,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/vxdisk_info.out.before' % change_number)
for i in vxdisklist:
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdisk_info.out.before' % change_number)
commands.getoutput('echo "=============================="
>> /var/crash/%s/vxdisk_info.out.before' % change_number)
commands.getoutput('echo
%s >> /var/crash/%s/vxdisk_info.out.before' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/vxdisk_info.out.before' % change_number)
commands.getoutput('/opt/VRTS/bin/vxdg
-g %s free >> /var/crash/%s/vxdisk_info.out.before' % (i,change_number))
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdisk_info.out.before' % change_number)
commands.getoutput('/opt/VRTS/bin/vxdisk
list %s >> /var/crash/%s/vxdisk_info.out.before')
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdisk_info.out.before' % change_number)
# Veritas DMP Information
commands.getoutput('vxdmpadm
listenclosure > vxdmpadm_listenclosure.out.before')
commands.getoutput('vxddladm
listsupport libname=libvxInvista.so >
vxddladm_listsupport_libname_libvxInvista.so.out.before')
commands.getoutput('vxddladm
listversion libname=libvxInvista.so >
vxddladm_listversion_libname_libvxInvista.so.out.before')
commands.getoutput('vxdmpadm
list dmpnode > vxdmpadm_list_dmpnode.out.before')
commands.getoutput('/opt/VRTS/bin/vxlist
> vxlist.out.before')
commands.getoutput('/opt/VRTS/bin/vxtask list >
vxtask_list.out.before')
commands.getoutput('pkginfo -l
VRTSvxfs > pkginfo-l_VRTSvxfs.out.before')
# Veritas Disk Group
Information
commands.getoutput('/opt/VRTS/bin/vxdg list > vxdg_list.out.before')
vxdglist =
commands.getoutput("/opt/VRTS/bin/vxdg list | grep -v NAME | awk '{print
$1}'").split('\n')
commands.getoutput('echo
"Veritas Disk Group Information : " %s >>
/var/crash/%s/vxdg_info.out.before' % (vxdglist,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/vxdg_info.out.before' % change_number)
for i in vxdglist:
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdg_info.out.before' % change_number)
commands.getoutput('echo "=============================="
>> /var/crash/%s/vxdg_info.out.before' % change_number)
commands.getoutput('echo %s >> /var/crash/%s/vxdg_info.out.before'
% (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/vxdg_info.out.before' % change_number)
commands.getoutput('/opt/VRTS/bin/vxdg -g %s free >>
/var/crash/%s/vxdg_info.out.before' % (i,change_number))
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdg_info.out.before' % change_number)
commands.getoutput('/opt/VRTS/bin/vxdg list %s >>
/var/crash/%s/vxdg_info.out.before')
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdg_info.out.before' % change_number)
# Veritas Cluster Server Information
if
os.path.isdir("/opt/VRTSvcs/bin") is True:
commands.getoutput('pkginfo -l
VRTSvcs > pkginfo-l_VRTSvcs.out.before')
commands.getoutput('cat
/etc/VRTSvcs/conf/config/main.cf > vcs_main.conf.out.before')
commands.getoutput('cat /etc/VRTSvcs/conf/config/types.cf >
vcs_types.conf.out.before')
commands.getoutput('cat
/var/VRTSvcs/log/engine_A.log > vcs_engine_A.log.out.before')
commands.getoutput('cat
/var/VRTSvcs/log/engine_B.log > vcs_engine_B.log.out.before')
commands.getoutput('cat
/var/VRTSvcs/log/engine_C.log > vcs_engine_C.log.out.before')
commands.getoutput('cat
/var/VRTSvcs/log/hashadow-err_A.log > vcs_hashadow-err_A.log.out.before')
commands.getoutput('cat
/etc/llttab > vcs_llttab.out.before')
commands.getoutput('cat
/etc/gabtab > vcs_gabtab.out.before')
commands.getoutput('cat
/etc/llthosts > vcs_llthosts.out.before')
commands.getoutput('cat /etc/vxfendg
> vcs_vxfendg.out.before')
commands.getoutput('cat
/etc/vxfentab > vcs_vxfentab.out.before')
commands.getoutput('cat
/etc/vxfenmode > vcs_vxfenmode.out.before')
commands.getoutput('/opt/VRTS/bin/vxfenadm
-d > vcs_vxfenadm-d.out.before')
commands.getoutput('/opt/VRTS/bin/gabconfig -a >
vcs_gabconfig-a.out.before')
commands.getoutput('/opt/VRTSvcs/bin/haclus -display >
vcs_haclus-display.out.before')
commands.getoutput('/opt/VRTSvcs/bin/haclus -display | grep -i
"readonly" > vcs_haclus-display_readonly_state.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hauser -display >
vcs_hauser-display.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hagrp -display >
vcs_hagrp-display.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hagrp -list >
vcs_hagrp-list.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hagrp -dep >
vcs_hagrp-dep.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hagrp -state >
vcs_hagrp-state.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hares -display >
vcs_hares-display.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hares
-state > vcs_hares-state.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hastatus -summary >
vcs_hastatus-sum.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hasys -list > vcs_hasys-list.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hasys -state >
vcs_hasys-state.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hasys -nodeid >
vcs_hasys-nodeid.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hatype
-display > vcs_hatype-display.out.before')
commands.getoutput('/opt/VRTSvcs/bin/hatype -list >
vcs_hatype-list.out.before')
commands.getoutput('/opt/VRTSvcs/bin/haagent -display >
vcs_haagent-display.out.before')
commands.getoutput('/opt/VRTSvcs/bin/haagent -display | grep Faults >
vcs_haagent-display_grep_faults.out.before')
commands.getoutput('/opt/VRTSvcs/bin/haagent -list >
vcs_haagent-list.out.before')
commands.getoutput('/opt/VRTS/bin/lltstat
-n > vcs_lltstat-n.out.before')
commands.getoutput('/opt/VRTS/bin/lltstat -nvv >
vcs_lltstat-nvv.out.before')
commands.getoutput('/opt/VRTS/bin/lltstat -p >
vcs_lltstat-p.out.before')
commands.getoutput('/opt/VRTS/bin/lltstat
-c > vcs_lltstat-c.out.before')
commands.getoutput('/opt/VRTS/bin/lltstat -l >
vcs_lltstat-l.out.before')
commands.getoutput('/opt/VRTS/bin/lltconfig -a list > vcs_lltconfig-a_list.out.before')
commands.getoutput('ps -ef |
grep had > vcs_ps_ef_grep_had.out.before')
commands.getoutput('/usr/sbin/vxdctl -c mode >
vcs_vxdctl_mode.out.before')
commands.getoutput('tar -cf %s-%s-pre.tar
-C /var/crash/%s/ *.before' % (change_number, hostname, change_number))
def post_checks():
print "Post Migration
Verification"
commands.getoutput('echo | format >
echo_format.out.after')
commands.getoutput('powermt display
dev=all > powermt_display_dev_all.out.after')
commands.getoutput('cat /etc/vfstab
> vfstab.out.after')
commands.getoutput('cfgadm -al >
cfgadm-al.out.after')
commands.getoutput('swap -l >
swap-l.out.after')
commands.getoutput('fcinfo hba-port -l
> fcinfo_hba-port-l.out.after')
commands.getoutput('fcinfo lu -v >
fcinfo_lu-v.out.after')
commands.getoutput('cfgadm -al -o
show_scsi_lun > cfgadm-al-o-show_scsi_lun.out.after')
commands.getoutput('luxadm -e port >
luxadm-e-port.out.after')
# Dynamic Multipath Related Information
commands.getoutput('mpathadm list
lu > mpathadm_list_lu.out.after')
commands.getoutput('mpathadm show lu
/dev/rdsk/c*t*d* > mpathadm_show_lu.out.after')
commands.getoutput('mpathadm list
mpath-support > mpathadm_list_mpath-support.out.after')
commands.getoutput('mpathadm show
mpath-support libmpscsi_vhci.so >
mpathadm_show_mpath-support_libmpscsi_vhci.so.out.after')
#commands.getoutput('mpathadm show
mpath-support <library name> > mpathadm_show_mpath-support.out.after')
commands.getoutput('df -k >
df-k.out.after')
commands.getoutput('prtvtoc
/dev/rdsk/c*t*d*s2 > prtvtoc.out.after')
commands.getoutput('date >
date.out.after')
commands.getoutput('hostid >
hostid.out.after')
commands.getoutput('hostname >
hostname.out.after')
commands.getoutput('ifconfig -a >
ifconfig-a.out.after')
commands.getoutput('isainfo -kv > isainfo-kv.out.after')
commands.getoutput('modinfo >
modinfo.out.after')
commands.getoutput('mount >
mount.out.after')
commands.getoutput('mount -p >
mount-p.out.after')
commands.getoutput('pkginfo -l >
pkginfo-l.out.after')
commands.getoutput('psrinfo -p >
psrinfo-p.out.after')
commands.getoutput('mpathadm list
initiator-port > mpathadm_list_initiator-port.out.after')
commands.getoutput('prtconf -vp >
prtconf-vp.out.after')
commands.getoutput('prtdiag -v >
prtdiag-v.out.after')
commands.getoutput('prtpicl >
prtpicl.out.after')
commands.getoutput('prtpicl -v >
prtpicl-v.out.after')
commands.getoutput('prtpicl -v -c
scsi-fcp > prtpicl-v-c_scsi-fcp.out.after')
commands.getoutput('ulimit -a >
ulimit-a.out.after')
commands.getoutput('uname -a >
uname-a.out.after')
commands.getoutput('uptime >
uptime.out.after')
commands.getoutput('arp -a >
arp-a.out.after')
commands.getoutput('crontab -l >
crontab-l.out.after')
commands.getoutput('dmesg >
dmesg.out.after')
commands.getoutput('env >
env.out.after')
commands.getoutput('iostat -En >
iostat-En.out.after')
commands.getoutput('ipcs -a >
ipcs-a.out.after')
commands.getoutput('ipcs -msa >
ipcs-msa.out.after')
commands.getoutput('ls -l /etc/rcS.d
> ls-l_etc_rcS.d.out.after')
commands.getoutput('ls -l /kernel/drv
> ls-l_kernel_drv.out.after')
commands.getoutput('ls -Ralsi /dev >
ls-Ralsi_dev.out.after')
commands.getoutput('ls -Ralsi /devices
> ls-Ralsi_devices.out.after')
commands.getoutput('ls -Ralsi /etc >
ls-Ralsi_etc.out.after')
commands.getoutput('netstat -a >
netstat-a.out.after')
commands.getoutput('netstat -r >
netstat-r.out.after')
commands.getoutput('netstat -nr >
netstat-nr.out.after')
commands.getoutput('prstat 2 5 >
prstat.out.after')
commands.getoutput('prtconf -v >
prtconf-v.out.after')
commands.getoutput('ps -efl >
ps-efl.out.after')
commands.getoutput('/usr/ucb/ps -aux
> ps-aux.out.after')
commands.getoutput('rpcinfo >
rpcinfo.out.after')
commands.getoutput('rpcinfo -p >
rpcinfo-p.out.after')
commands.getoutput('sysdef > sysdef.out.after')
commands.getoutput('vmstat 2 5 >
vmstat.out.after')
commands.getoutput('who -b >
who-b.out.after')
commands.getoutput('fmadm faulty >
fmadm_faulty.out.after')
commands.getoutput('fmdump -V >
fmdump-V.out.after')
commands.getoutput('fmdump -eV >
fmdump-eV.out.after')
commands.getoutput('svcs -v >
svcs-v.out.after')
#commands.getoutput('svcs -xv '*' >
svcs-xv.out.after')
commands.getoutput('cat /etc/hosts >
etc-hosts.out.after')
commands.getoutput('cat
/etc/mnttab > mnttab.out.after')
commands.getoutput('cat
/etc/nsswitch.conf > nsswitch.conf.out.after')
commands.getoutput('cat
/etc/cfg/fp/fabric_WWN_map > fabric_WWN_map.out.after')
commands.getoutput('cat
/etc/driver_aliases > driver_aliases.out.after')
commands.getoutput('cat /etc/hba.conf
> hba.conf.out.after')
commands.getoutput('cat
/etc/name_to_major > name_to_major.out.after')
commands.getoutput('cat
/etc/path_to_inst > path_to_inst.out.after')
commands.getoutput('cat /etc/release
> release.out.after')
commands.getoutput('cat
/etc/resolv.conf > resolv.conf.out.after')
commands.getoutput('cat /etc/system
> etc_system.out.after')
# Configuration Files in /kernel/drv/
commands.getoutput('ls -l /kernel/drv/
> kernel_drv_conf_files.out.after')
kernel_drv_conf_list =
commands.getoutput("ls -l /kernel/drv/ | awk '{print
$NF}'").split('\n')
commands.getoutput('echo "Configuration
Files in /kernel/drv folder : " %s >>
/var/crash/%s/kernel_drv_conf_list.out.after' %
(kernel_drv_conf_list,change_number))
commands.getoutput('echo "\n"
>> /var/crash/%s/kernel_drv_conf_list.out.after' % change_number)
for i in kernel_drv_conf_list:
commands.getoutput('echo
"\n" >> /var/crash/%s/kernel_drv_conf_list.out.after' %
change_number)
commands.getoutput('echo
"==============================" >>
/var/crash/%s/kernel_drv_conf_list.out.after' % change_number)
commands.getoutput('echo %s
>> /var/crash/%s/kernel_drv_conf_list.out.after' % (i,change_number))
commands.getoutput('echo
"==============================" >>
/var/crash/%s/kernel_drv_conf_list.out.after' % change_number)
commands.getoutput('cat
/kernel/drv/%s >> /var/crash/%s/kernel_drv_conf_list.out.after' %
(i,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/kernel_drv_conf_list.out.after' %
change_number)
commands.getoutput('cat
/etc/lvm/md.tab > md.tab.out.after')
# SVM Commands
metastat_package =
commands.getoutput('pkginfo -l SUNWmdu | grep -i "STATUS"')
if 'installed' in metastat_package:
commands.getoutput('metastat
> metastat.out.after')
commands.getoutput('metastat -p
> metastat-p.out.after')
commands.getoutput('metadb >
metadb.out.after')
commands.getoutput('metaset
> metaset.out.after')
# Zones Related Information
zoneadm_package =
commands.getoutput('pkginfo -l SUNWzoneu | grep -i "STATUS"')
if 'installed' in zoneadm_package:
commands.getoutput('zoneadm
list -v > zoneadm_list-v.out.after')
commands.getoutput('zoneadm
list > zoneadm_list.out.after')
commands.getoutput('zoneadm
list -civ > zoneadm_list-civ.out.after')
zpool_package =
commands.getoutput('pkgchk -l -p /usr/sbin/zpool | grep -i "status"')
if 'installed' in zpool_package:
commands.getoutput('zpool list
> zpool_list.out.after')
commands.getoutput('zpool
iostat > zpool_iostat.out.after')
commands.getoutput('zpool
iostat -v > zpool_iostat-v.out.after')
commands.getoutput('zpool
iostat -x > zpool_iostat-x.out.after')
commands.getoutput('zpool
status -v > zpool_status-v.out.after')
commands.getoutput('zfs get
compression > zfs_get_compression.out.after')
#localzones_list =
commands.getoutput("zoneadm list | grep -v global").split('\n')
#commands.getoutput('echo "Local
Zones Information : " %s >> /var/crash/%s/localzones_info.out.after'
% (localzones_list,change_number))
#commands.getoutput('echo
"\n" >> /var/crash/%s/localzones_info.out.after' %
change_number)
#for i in localzones_list:
#commands.getoutput('echo "\n" >>
/var/crash/%s/localzones_info.out.after' % change_number)
#commands.getoutput('echo
"==============================" >>
/var/crash/%s/localzones_info.out.after' % change_number)
#commands.getoutput('echo %s
>> /var/crash/%s/localzones_info.out.after' % (i,change_number))
#commands.getoutput('echo "=============================="
>> /var/crash/%s/localzones_info.out.after' % change_number)
#commands.getoutput('zonecfg -z %s
info >> /var/crash/%s/localzones_info.out.after' % (i,change_number))
#commands.getoutput('echo
"\n" >> /var/crash/%s/localzones_info.out.after' %
change_number)
# Veritas Volume Manager Disk
Information
if
os.path.isdir("/opt/VRTS/bin") is True:
commands.getoutput('pkginfo -l
VRTSvxvm > pkginfo-l_VRTSvxvm.out.after')
# Veritas Disk Information
commands.getoutput('/opt/VRTS/bin/vxdisk list >
vxdisk_list.out.after')
commands.getoutput('/opt/VRTS/bin/vxdisk -s list >
vxdisk-s_list.out.after')
commands.getoutput('/opt/VRTS/bin/vxdisk
-eo alldgs list > vxdisk-eo-alldgs-list.out.after')
commands.getoutput('/opt/VRTS/bin/vxprint -ht >
vxprint-ht.out.after')
vxdisklist =
commands.getoutput("/opt/VRTS/bin/vxdisk list | grep -v DEVICE | awk '{print
$1}'").split('\n')
commands.getoutput('echo
"Veritas Disk Information : " %s >>
/var/crash/%s/vxdisk_info.out.after' % (vxdisklist,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/vxdisk_info.out.after' % change_number)
for i in vxdisklist:
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdisk_info.out.after' % change_number)
commands.getoutput('echo "=============================="
>> /var/crash/%s/vxdisk_info.out.after' % change_number)
commands.getoutput('echo %s >>
/var/crash/%s/vxdisk_info.out.after' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/vxdisk_info.out.after' % change_number)
commands.getoutput('/opt/VRTS/bin/vxdg -g %s free >>
/var/crash/%s/vxdisk_info.out.after' % (i,change_number))
commands.getoutput('echo "\n" >> /var/crash/%s/vxdisk_info.out.after'
% change_number)
commands.getoutput('/opt/VRTS/bin/vxdisk list %s >>
/var/crash/%s/vxdisk_info.out.after')
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdisk_info.out.after' % change_number)
# Veritas DMP Information
commands.getoutput('vxdmpadm
listenclosure > vxdmpadm_listenclosure.out.after')
commands.getoutput('vxddladm
listsupport libname=libvxInvista.so > vxddladm_listsupport_libname_libvxInvista.so.out.after')
commands.getoutput('vxddladm
listversion libname=libvxInvista.so >
vxddladm_listversion_libname_libvxInvista.so.out.after')
commands.getoutput('vxdmpadm
list dmpnode > vxdmpadm_list_dmpnode.out.after')
commands.getoutput('/opt/VRTS/bin/vxlist > vxlist.out.after')
commands.getoutput('/opt/VRTS/bin/vxtask list >
vxtask_list.out.after')
commands.getoutput('pkginfo -l
VRTSvxfs > pkginfo-l_VRTSvxfs.out.after')
# Veritas Disk Group
Information
commands.getoutput('/opt/VRTS/bin/vxdg list > vxdg_list.out.after')
vxdglist =
commands.getoutput("/opt/VRTS/bin/vxdg list | grep -v NAME | awk '{print
$1}'").split('\n')
commands.getoutput('echo
"Veritas Disk Group Information : " %s >>
/var/crash/%s/vxdg_info.out.after' % (vxdglist,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/vxdg_info.out.after' % change_number)
for i in vxdglist:
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdg_info.out.after' % change_number)
commands.getoutput('echo "=============================="
>> /var/crash/%s/vxdg_info.out.after' % change_number)
commands.getoutput('echo %s >> /var/crash/%s/vxdg_info.out.after'
% (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/vxdg_info.out.after' % change_number)
commands.getoutput('/opt/VRTS/bin/vxdg -g %s free >>
/var/crash/%s/vxdg_info.out.after' % (i,change_number))
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdg_info.out.after' % change_number)
commands.getoutput('/opt/VRTS/bin/vxdg list %s >>
/var/crash/%s/vxdg_info.out.after')
commands.getoutput('echo "\n" >>
/var/crash/%s/vxdg_info.out.after' % change_number)
# Veritas Cluster Server Information
if
os.path.isdir("/opt/VRTSvcs/bin") is True:
commands.getoutput('pkginfo -l
VRTSvcs > pkginfo-l_VRTSvcs.out.after')
commands.getoutput('cat
/etc/VRTSvcs/conf/config/main.cf > vcs_main.conf.out.after')
commands.getoutput('cat
/etc/VRTSvcs/conf/config/types.cf > vcs_types.conf.out.after')
commands.getoutput('cat
/var/VRTSvcs/log/engine_A.log > vcs_engine_A.log.out.after')
commands.getoutput('cat
/var/VRTSvcs/log/engine_B.log > vcs_engine_B.log.out.after')
commands.getoutput('cat
/var/VRTSvcs/log/engine_C.log > vcs_engine_C.log.out.after')
commands.getoutput('cat
/var/VRTSvcs/log/hashadow-err_A.log > vcs_hashadow-err_A.log.out.after')
commands.getoutput('cat
/etc/llttab > vcs_llttab.out.after')
commands.getoutput('cat
/etc/gabtab > vcs_gabtab.out.after')
commands.getoutput('cat
/etc/llthosts > vcs_llthosts.out.after')
commands.getoutput('cat
/etc/vxfendg > vcs_vxfendg.out.after')
commands.getoutput('cat
/etc/vxfentab > vcs_vxfentab.out.after')
commands.getoutput('cat
/etc/vxfenmode > vcs_vxfenmode.out.after')
commands.getoutput('/opt/VRTS/bin/vxfenadm -d >
vcs_vxfenadm-d.out.after')
commands.getoutput('/opt/VRTS/bin/gabconfig -a >
vcs_gabconfig-a.out.after')
commands.getoutput('/opt/VRTSvcs/bin/haclus -display >
vcs_haclus-display.out.after')
commands.getoutput('/opt/VRTSvcs/bin/haclus -display | grep -i
"readonly" > vcs_haclus-display_readonly_state.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hauser -display > vcs_hauser-display.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hagrp -display >
vcs_hagrp-display.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hagrp -list >
vcs_hagrp-list.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hagrp
-dep > vcs_hagrp-dep.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hagrp -state >
vcs_hagrp-state.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hares -display >
vcs_hares-display.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hares
-state > vcs_hares-state.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hastatus -summary >
vcs_hastatus-sum.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hasys -list > vcs_hasys-list.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hasys -state >
vcs_hasys-state.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hasys -nodeid >
vcs_hasys-nodeid.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hatype
-display > vcs_hatype-display.out.after')
commands.getoutput('/opt/VRTSvcs/bin/hatype -list >
vcs_hatype-list.out.after')
commands.getoutput('/opt/VRTSvcs/bin/haagent -display >
vcs_haagent-display.out.after')
commands.getoutput('/opt/VRTSvcs/bin/haagent -display | grep Faults >
vcs_haagent-display_grep_faults.out.after')
commands.getoutput('/opt/VRTSvcs/bin/haagent -list >
vcs_haagent-list.out.after')
commands.getoutput('/opt/VRTS/bin/lltstat
-n > vcs_lltstat-n.out.after')
commands.getoutput('/opt/VRTS/bin/lltstat -nvv >
vcs_lltstat-nvv.out.after')
commands.getoutput('/opt/VRTS/bin/lltstat -p >
vcs_lltstat-p.out.after')
commands.getoutput('/opt/VRTS/bin/lltstat
-c > vcs_lltstat-c.out.after')
commands.getoutput('/opt/VRTS/bin/lltstat -l >
vcs_lltstat-l.out.after')
commands.getoutput('/opt/VRTS/bin/lltconfig -a list > vcs_lltconfig-a_list.out.after')
commands.getoutput('ps -ef |
grep had > vcs_ps_ef_grep_had.out.after')
commands.getoutput('/usr/sbin/vxdctl -c mode >
vcs_vxdctl_mode.out.after')
commands.getoutput('tar -cf
/var/crash/%s-%s-post.tar -C /var/crash/%s/ *.after' % (change_number,
hostname, change_number))
def compare_pre_post():
print "\n+++++ Comparing
Pre and Post Checks +++++\n"
os.chdir('/var/crash/%s' %
change_number)
cmd_list = ['vfstab',
'cfgadm-al', 'swap-l', 'df-k', 'prtvtoc', 'ifconfig-a', 'isainfo-kv',
'mount-p', 'pkginfo-l', 'psrinfo-p', 'prtconf-vp', 'prstat', 'prtdiag-v',
'prtpicl-v', 'ulimit-a', 'uname-a', 'arp-a', 'crontab-l', 'iostat-En',
'ipcs-a', 'ipcs-msa', 'netstat-a', 'netstat-r', 'netstat-nr', 'vmstat',
'prtconf-v', 'ps-efl', 'ps-aux', 'rpcinfo-p', 'who-b', 'fmadm_faulty',
'fmdump-V', 'fmdump-eV', 'svcs-v', 'etc-hosts', 'mnttab', 'nsswitch.conf',
'fabric_WWN_map', 'driver_aliases', 'hba.conf', 'name_to_major',
'path_to_inst', 'release', 'resolv.conf', 'etc_system', 'md.tab',
'kernel_drv_conf_list', 'metastat-p', 'zoneadm_list', 'zpool_list',
'zpool_iostat', 'vxdisk_list', 'vxdisk_info', 'vxprint-ht',
'vxdmpadm_listenclosure', 'vxtask_list', 'vxdg_list', 'vxdg_info',
'vcs_main.conf', 'vcs_types.conf', 'vcs_engine_A.log', 'vcs_engine_B.log',
'vcs_engine_C.log', 'vcs_hashadow-err_A.log', 'vcs_llttab', 'vcs_gabtab',
'vcs_llthosts', 'vcs_vxfendg', 'vcs_vxfenmode', 'vcs_vxfentab',
'vcs_vxfenadm-d', 'vcs_gabconfig-a', 'vcs_haclus-display',
'vcs_haclus-display_readonly_state', 'vcs_hauser-display', 'vcs_hagrp-display',
'vcs_hagrp-list', 'vcs_hagrp-dep', 'vcs_hagrp-state', 'vcs_hares-display',
'vcs_hares-state', 'vcs_hatype-display', 'vcs_hatype-list', 'vcs_hastatus-sum',
'vcs_hasys-list', 'vcs_hasys-state', 'vcs_hasys-nodeid', 'vcs_haagent-display',
'vcs_haagent-display_grep_faults', 'vcs_haagent-list', 'vcs_lltstat-n',
'vcs_lltstat-nvv', 'vcs_lltstat-p', 'vcs_lltstat-c', 'vcs_lltstat-l',
'vcs_lltconfig-a_list', 'vcs_ps_ef_grep_had', 'vcs_vxdctl_mode' ]
suffix_before = '.out.before'
suffix_after = '.out.after'
for i in cmd_list:
i=str(i)
output =
filecmp.cmp(i+"%s" % suffix_before, i+"%s" % suffix_after)
# print i, output
if output == False:
print
"Comparison failed for file " + i
print "\n No change in
rest of the Configurations. All OK \n"
user_input = input("Please
enter the choice: ")
while True:
if user_input == 1:
pre_checks()
elif user_input == 2:
post_checks()
elif user_input == 3:
compare_pre_post()
elif user_input == 0:
print "Thank You !!!
"
sys.exit(0)
user_input = input("Please enter
your next choice: ")
Comments
Post a Comment