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 - Linux |
|
Category:
|
Informational
|
|
Author:
|
Sri Krishna
Chirumarri
|
|
Intended
Audience:
|
Infrastructure
Operations ( Linux )
|
|
Skillset
Requirements:
|
Linux System
Administrator
|
|
Linux
Flavor & Version:
|
Red Hat Linux 5 & 6
|
|
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
|
01/02/18
|
1.0
|
|
Initial
version
|
Sri Krishna Chirumarri
|
02/27/18
|
1.1
|
|
Revised
Version
|
Sri
Krishna Chirumarri
|
03/07/18
|
1.2
|
|
Revised
Version
|
Sri
Krishna Chirumarri
|
04/09/18
|
1.3
|
|
Revised
Version
|
Sri
Krishna Chirumarri
|
05/23/18
|
1.4
|
|
Revised
Version
|
Sri
Krishna Chirumarri
|
06/14/18
|
1.5
|
|
Revised
Version
|
Sri
Krishna Chirumarri
|
06/21/18
|
1.6
|
|
Revised
Version
|
Sri Krishna
Chirumarri
|
Script Execution details
The script will specifically work for Linux Standalone
server. It is a menu based system providing us with 3
options namely Pre-Checks, Post-Checks and Compare_Pre_Post.
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.6
# 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
#f =
open("pre-checks.txt", "w+")
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('uname -r
> uname-r.out.before')
commands.getoutput('df -hTP
> df-hTP.out.before')
commands.getoutput('df -k >
df-k.out.before')
commands.getoutput('lsblk >
lsblk.out.before')
commands.getoutput('blkid >
blkid.out.before')
commands.getoutput('cat
/etc/fstab > fstab.out.before')
commands.getoutput('fdisk -l >
fdisk.out.before')
commands.getoutput('pvs >
pvs.out.before')
commands.getoutput('vgs >
vgs.out.before')
commands.getoutput('lvs >
lvs.out.before')
commands.getoutput('cat
/etc/lvm/lvm.conf > lvm.conf.out.before')
commands.getoutput('cat
/etc/exports > exports.out.before')
commands.getoutput('cat
/etc/mtab > mtab.out.before')
commands.getoutput('mount >
mount.out.before')
commands.getoutput('mdadm
--detail > mdadm--detail.out.before')
commands.getoutput('dmesg |
grep "[hs]d[a-z]" > dmesg.out.before')
commands.getoutput('rpm -qa |
grep -i "multipath" > rpm-multipath.out.before')
#commands.getoutput("multipath -ll | awk '{$1="";
$2=""; $3="" print}'; > multipath.out.before")
commands.getoutput("multipath -ll >
multipath-ll.out.before")
commands.getoutput('mpathconf
> mpathconf.out.before')
commands.getoutput('cat
/etc/multipath/bindings > multipath-bindings.out.before')
commands.getoutput('cat
/etc/multipath/wwids > multipath-wwids.out.before')
commands.getoutput('cat
/etc/multipath.conf > multipath.conf.out.before')
commands.getoutput('free -m |
grep -v "-" > free.out.before')
commands.getoutput('cat
/etc/grub.conf > grub.conf.out.before')
commands.getoutput('cat /etc/sysconfig/network
> sysconfig-network.out.before')
commands.getoutput('cat
/etc/hosts > hosts.out.before')
commands.getoutput('ifconfig -a
| egrep -v "RX|TX|collisions" > ifconfig-a.out.before')
commands.getoutput('netstat -r
> netstat-r.out.before')
commands.getoutput('iptables -L
> iptables-l.out.before')
commands.getoutput('ip a s >
ip-a-s.out.before')
commands.getoutput('ip a > ip-a.out.before')
commands.getoutput('fcoeadm -i >
fcoeadm-i.out.before')
commands.getoutput('ip a s |
grep -i fcoe > ip-a-s-fcoe.out.before')
commands.getoutput('fipvlan -a
> fipvlan-fcoe.out.before')
commands.getoutput('fcoeadm -l
> fcoeadm-l.out.before')
commands.getoutput('fcoeadm -t
> fcoeadm-t.out.before')
commands.getoutput('nmcli dev
status > nmcli-dev-status.out.before')
commands.getoutput('nmcli con
show > nmcli-con-show.out.before')
commands.getoutput('nmcli con
show -a > nmcli-con-show-a.out.before')
commands.getoutput('chkconfig
--list > chkconfig--list.out.before')
commands.getoutput('cp -p
/etc/udev/rules.d/*asm*.reles asm-rules.out.before')
commands.getoutput('systool -c
fc_host -v > fc_host.out.before')
commands.getoutput('systool -c
scsi_host -v > scsi_host.out.before')
commands.getoutput('rpm -qa
> rpm-qa.out.before')
commands.getoutput('yum list
> yum-list.out.before')
commands.getoutput('cat
/etc/sysconfig/network > sysconfig-network.out.before')
commands.getoutput('lspci |
grep -i fibre > fc-adapter.out.before')
commands.getoutput('lspci >
lspci.out.before')
commands.getoutput('ls -l /boot
> ls-boot.out.before')
commands.getoutput('ls -l
/boot/grub > ls-boot-grub.out.before')
commands.getoutput('cat /boot/grub/device.map
> device.map.out.before')
commands.getoutput('cat
/boot/grub/menu.lst > menu.lst.out.before')
commands.getoutput('pvscan >
pvscan.out.before')
commands.getoutput('pcs status
> pcs-status.out.before')
commands.getoutput('pcs cluster
status > pcs-cluster-status.out.before')
commands.getoutput('pcs cluster
cib > pcs-cluster-cib-xml.out.before')
commands.getoutput('pcs
resource standards > pcs-resources-strds.out.before')
commands.getoutput('pcs
resource agents ocf > pcs-resource-agents-ocf.out.before')
commands.getoutput('pcs
resource agents lsb > pcs-resource-agents-lsb.out.before')
commands.getoutput('pcs
resource agents service > pcs-resource-agents-service.out.before')
commands.getoutput('pcs
resource agents stonith > pcs-resource-agents-stonith.out.before')
commands.getoutput('pcs
resource agents > pcs-resource-agents.out.before')
commands.getoutput('pcs
resource describe RA > pcs-resource-describe-RA.out.before')
commands.getoutput('pcs
resource show > pcs-resource-show.out.before')
commands.getoutput('pcs stonith
show > pcs-stonith-show.out.before')
commands.getoutput('pcs
resource rsc default > pcs-resource-rsc-default.out.before')
commands.getoutput('pcs
resource op defaults > pcs-resource-op-defaults.out.before')
commands.getoutput('pcs resource
failcount show RA > pcs-resource-failcount-show-RA.out.before')
commands.getoutput('pcs stonith
list > pcs-stonith-list.out.before')
commands.getoutput('pcs stonith
show > pcs-stonith-show.out.before')
commands.getoutput('cat
/var/log/messages > var-log-messages.out.before')
commands.getoutput('dmesg >
dmesg.out.before')
commands.getoutput('cman_tool
-V > cluster-version.out.before')
commands.getoutput('clustat >
clustat.out.before')
commands.getoutput('clustat -l
> clustat-l.out.before')
commands.getoutput('cman_tool
nodes > cman_tool-nodes.out.before')
commands.getoutput('cman_tool
status > cman_tool-status.out.before')
commands.getoutput('ccs_tool
lsnode > ccs_tool-lsnode.out.before')
commands.getoutput('ccs_tool
lsfence > ccs_tool-lsfence.out.before')
commands.getoutput('group_tool
> group_tool.out.before')
commands.getoutput('group_tool
ls > group_tool-ls.out.before')
commands.getoutput('ls -l
/dev/disk/by-id > dev-disk-by-id.out.before')
commands.getoutput('ls -l /dev/disk/by-uuid
> dev-disk-by-uuid.out.before')
commands.getoutput('ls -l
/dev/disk/by-path > dev-disk-by-path.out.before')
commands.getoutput('sosreport
--batch --name=%s --case-id=%s-pre --tmp-dir=/var/crash/%s' % (hostname,change_number,change_number))
mpaths =
commands.getoutput("multipath -ll | grep -i mpath | awk '{print
$1}'").split('\n')
commands.getoutput('echo
"Multipath Devices: " %s >>
/var/crash/%s/mpathlistattr.out.before' % (mpaths,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/mpathlistattr.out.before' %
change_number)
for i in mpaths:
commands.getoutput('echo "\n" >>
/var/crash/%s/mpathlistattr.out.before' % change_number)
commands.getoutput('echo "=============================="
>> /var/crash/%s/mpathlistattr.out.before' % change_number)
commands.getoutput('echo %s >>
/var/crash/%s/mpathlistattr.out.before' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/mpathlistattr.out.before' % change_number)
commands.getoutput('hdparm -I /dev/mapper/%s >>
/var/crash/%s/mpathlistattr.out.before' % (i,change_number))
commands.getoutput('echo "\n" >>
/var/crash/%s/mpathlistattr.out.before' % change_number)
ethlist =
commands.getoutput("ifconfig -a | grep -i Ethernet | awk '{print
$1}'").split('\n')
commands.getoutput('echo
"Ethernet Devices: " + %s >> /var/crash/%s/ethtool.out.before'
% (ethlist,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/ethtool.out.before' % change_number)
commands.getoutput('echo
"Ethernet Devices: " + %s >> /var/crash/%s/miitool.out.before'
% (ethlist,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/miitool.out.before' % change_number)
for i in ethlist:
commands.getoutput('echo
"==============================" >>
/var/crash/%s/ethtool.out.before' % change_number)
commands.getoutput('echo %s >> /var/crash/%s/ethtool.out.before' %
(i,change_number))
commands.getoutput('echo
"==============================" >>
/var/crash/%s/ethtool.out.before' % change_number)
commands.getoutput('ethtool %s >>
/var/crash/%s/ethtool.out.before' % (i,change_number))
commands.getoutput('echo
"==============================" >>
/var/crash/%s/miitool.out.before' % change_number)
commands.getoutput('echo %s >> /var/crash/%s/miitool.out.before' %
(i,change_number))
commands.getoutput('echo
"==============================" >>
/var/crash/%s/miitool.out.before' % change_number)
commands.getoutput('mii-tool %s >>
/var/crash/%s/miitool.out.before' % (i,change_number))
bond_list = commands.getoutput("ls
/proc/net/bonding").split('\n')
for i in bond_list:
commands.getoutput('echo "=============================="
>> /var/crash/%s/bond_info.out.before' % change_number)
commands.getoutput('echo
%s >> /var/crash/%s/bond_info.out.before' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/bond_info.out.before' % change_number)
commands.getoutput('cat
/proc/net/bonding/%s >> /var/crash/%s/bond_info.out.before' % (i,
change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/bond_info.out.before' % change_number)
fchost_list =
commands.getoutput("ls /sys/class/fc_host").split("\n")
for i in fchost_list:
commands.getoutput('echo "=============================="
>> /var/crash/%s/fchost_info.out.before' % change_number)
commands.getoutput('echo %s >>
/var/crash/%s/fchost_info.out.before' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fchost_info.out.before' % change_number)
commands.getoutput('cat /sys/class/fc_host/%s/port_name >>
/var/crash/%s/fchost_info.out.before' % (i, change_number))
commands.getoutput('cat /sys/class/fc_host/%s/port_state >>
/var/crash/%s/fchost_info.out.before' % (i, change_number))
commands.getoutput('cat /sys/class/fc_host/%s/symbolic_name >>
/var/crash/%s/fchost_info.out.before' % (i, change_number))
commands.getoutput('echo
"==============================" >>
/var/crash/%s/fchost_info.out.before' % change_number)
fctarget_list =
commands.getoutput("ls /sys/class/fc_transport").split('\n')
for i in fctarget_list:
commands.getoutput('echo "=============================="
>> /var/crash/%s/fctarget_info.out.before' % change_number)
commands.getoutput('echo %s >>
/var/crash/%s/fctarget_info.out.before' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fctarget_info.out.before' % change_number)
commands.getoutput('cat /sys/class/fc_transport/%s/port_name >>
/var/crash/%s/fctarget_info.out.before' % (i, change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fctarget_info.out.before' % change_number)
#ifcfg Information
ifcfg_list =
commands.getoutput("ls /etc/sysconfig/network-scripts | grep -i
ifcfg").split('\n')
for i in ifcfg_list:
commands.getoutput('echo "=============================="
>> /var/crash/%s/ifcfg_info.out.before' % change_number)
commands.getoutput('echo %s >>
/var/crash/%s/ifcfg_info.out.before' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/ifcfg_info.out.before' % change_number)
commands.getoutput('cat /etc/sysconfig/network-scripts/%s >>
/var/crash/%s/ifcfg_info.out.before' % (i, change_number))
commands.getoutput('echo
"==============================" >>
/var/crash/%s/ifcfg_info.out.before' % change_number)
#fcoe
if
os.path.isdir("/etc/fcoe") is True:
fcoe_list =
commands.getoutput("ls /etc/fcoe").split('\n')
for i in fcoe_list:
commands.getoutput('echo "=============================="
>> /var/crash/%s/fcoeinfo.out.before' % change_number)
commands.getoutput('echo
%s >> /var/crash/%s/fcoeinfo.out.before' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fcoeinfo.out.before' % change_number)
commands.getoutput('cat
/etc/fcoe/%s >> /var/crash/%s/fcoeinfo.out.before' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fcoeinfo.out.before' % change_number)
#os.chdir("/var/crash/")
initramfs_list =
commands.getoutput('ls -l /boot | grep -i initramfs* | awk -F" "
\'{print $NF}\'').split('\n')
for i in initramfs_list:
commands.getoutput('cp
-p /boot/%s /var/crash/%s/%s.out.before' % (i, change_number, i))
commands.getoutput('tar -cf
/var/crash/%s-%s-pre.tar -C /var/crash/%s/*.before' % (change_number, hostname,
change_number))
#commands.getoutput('sosreport
--batch --name=hostname --case-id=%s --tmp-dir=/var/crash/%s
#commands.getoutput('')
#commands.getoutput('')
def post_checks():
print "Post Migration
Verifications"
commands.getoutput('uname -r
> uname-r.out.after')
commands.getoutput('df -hTP
> df-hTP.out.after')
commands.getoutput('df -k >
df-k.out.after')
commands.getoutput('lsblk >
lsblk.out.after')
commands.getoutput('blkid >
blkid.out.after')
commands.getoutput('cat
/etc/fstab > fstab.out.after')
commands.getoutput('fdisk -l
> fdisk.out.after')
commands.getoutput('pvs >
pvs.out.after')
commands.getoutput('vgs >
vgs.out.after')
commands.getoutput('lvs >
lvs.out.after')
commands.getoutput('cat
/etc/lvm/lvm.conf > lvm.conf.out.after')
commands.getoutput('cat
/etc/exports > exports.out.after')
commands.getoutput('cat /etc/mtab
> mtab.out.after')
commands.getoutput('mount >
mount.out.after')
commands.getoutput('mdadm
--detail > mdadm--detail.out.after')
commands.getoutput('dmesg |
grep "[hs]d[a-z]" > dmesg.out.after')
commands.getoutput('rpm -qa | grep -i
"multipath" > rpm-multipath.out.after')
#commands.getoutput("multipath -ll | awk '{$1="";
$2=""; $3="" print}'; > multipath.out.after")
commands.getoutput('multipath
-ll > multipath-ll.out.after')
commands.getoutput('mpathconf
> mpathconf.out.after')
commands.getoutput('cat
/etc/multipath/bindings > multipath-bindings.out.after')
commands.getoutput('cat
/etc/multipath/wwids > multipath-wwids.out.after')
commands.getoutput('cat
/etc/multipath.conf > multipath.conf.out.after')
commands.getoutput('free -m |
grep -v "-" > free.out.after')
commands.getoutput('cat
/etc/grub.conf > grub.conf.out.after')
commands.getoutput('cat
/etc/sysconfig/network > sysconfig-network.out.after')
commands.getoutput('cat
/etc/hosts > hosts.out.after')
commands.getoutput('ifconfig -a
| egrep -v "RX|TX|collisions" > ifconfig-a.out.after')
commands.getoutput('netstat -r
> netstat-r.out.after')
commands.getoutput('iptables -L
> iptables-l.out.after')
commands.getoutput('ip a s >
ip-a-s.out.after')
commands.getoutput('ip a > ip-a.out.after')
commands.getoutput('fcoeadm -i
> fcoeadm-i.out.after')
commands.getoutput('ip a s |
grep -i fcoe > ip-a-s-fcoe.out.after')
commands.getoutput('fipvlan -a
> fipvlan-fcoe.out.after')
commands.getoutput('fcoeadm -l
> fcoeadm-l.out.after')
commands.getoutput('fcoeadm -t
> fcoeadm-t.out.after')
commands.getoutput('nmcli con
show > nmcli-con-show.out.after')
commands.getoutput('nmcli con
show -a > nmcli-con-show-a.out.after')
commands.getoutput('nmcli dev
status > nmcli-dev-status.out.after')
commands.getoutput('chkconfig
--list > chkconfig--list.out.after')
commands.getoutput('cp -p
/etc/udev/rules.d/*asm*.reles asm-rules.out.after')
commands.getoutput('systool -c
fc_host -v > fc_host.out.after')
commands.getoutput('systool -c
scsi_host -v > scsi_host.out.after')
commands.getoutput('rpm -qa
> rpm-qa.out.after')
commands.getoutput('yum list
> yum-list.out.after')
commands.getoutput('cat
/etc/sysconfig/network > sysconfig-network.out.after')
commands.getoutput('lspci | grep
-i fibre > fc-adapter.out.after')
commands.getoutput('lspci >
lspci.out.after')
commands.getoutput('ls -l /boot
> ls-boot.out.after')
commands.getoutput('ls -l
/boot/grub > ls-boot-grub.out.after')
commands.getoutput('cat
/boot/grub/device.map > device.map.out.after')
commands.getoutput('cat
/boot/grub/menu.lst > menu.lst.out.after')
commands.getoutput('pvscan >
pvscan.out.after')
commands.getoutput('pcs status
> pcs-status.out.after')
commands.getoutput('pcs cluster
status > pcs-cluster-status.out.after')
commands.getoutput('pcs cluster
cib > pcs-cluster-cib-xml.out.after')
commands.getoutput('pcs
resource standards > pcs-resources-strds.out.after')
commands.getoutput('pcs
resource agents ocf > pcs-resource-agents-ocf.out.after')
commands.getoutput('pcs
resource agents lsb > pcs-resource-agents-lsb.out.after')
commands.getoutput('pcs resource
agents service > pcs-resource-agents-service.out.after')
commands.getoutput('pcs
resource agents stonith > pcs-resource-agents-stonith.out.after')
commands.getoutput('pcs
resource agents > pcs-resource-agents.out.after')
commands.getoutput('pcs
resource describe RA > pcs-resource-describe-RA.out.after')
commands.getoutput('pcs
resource show > pcs-resource-show.out.after')
commands.getoutput('pcs stonith
show > pcs-stonith-show.out.after')
commands.getoutput('pcs
resource rsc default > pcs-resource-rsc-default.out.after')
commands.getoutput('pcs
resource op defaults > pcs-resource-op-defaults.out.after')
commands.getoutput('pcs
resource failcount show RA > pcs-resource-failcount-show-RA.out.after')
commands.getoutput('pcs stonith
list > pcs-stonith-list.out.after')
commands.getoutput('pcs stonith
show > pcs-stonith-show.out.after')
commands.getoutput('cat
/var/log/messages > var-log-messages.out.after')
commands.getoutput('dmesg >
dmesg.out.after')
commands.getoutput('cman_tool
-V > cluster-version.out.after')
commands.getoutput('clustat
> clustat.out.after')
commands.getoutput('clustat -l
> clustat-l.out.after')
commands.getoutput('cman_tool
nodes > cman_tool-nodes.out.after')
commands.getoutput('cman_tool
status > cman_tool-status.out.after')
commands.getoutput('ccs_tool
lsnode > ccs_tool-lsnode.out.after')
commands.getoutput('ccs_tool
lsfence > ccs_tool-lsfence.out.after')
commands.getoutput('group_tool
> group_tool.out.after')
commands.getoutput('group_tool
ls > group_tool-ls.out.after')
commands.getoutput('ls -l
/dev/disk/by-id > dev-disk-by-id.out.after')
commands.getoutput('ls -l
/dev/disk/by-uuid > dev-disk-by-uuid.out.after')
commands.getoutput('ls -l
/dev/disk/by-path > dev-disk-by-path.out.after')
commands.getoutput('sosreport
--batch --name=%s --case-id=%s-post --tmp-dir=/var/crash/%s' %
(hostname,change_number,change_number))
mpaths =
commands.getoutput("multipath -ll | grep -i mpath | awk '{print
$1}'").split('\n')
commands.getoutput('echo
"Multipath Devices: " %s >>
/var/crash/%s/mpathlistattr.out.after' % (mpaths,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/mpathlistattr.out.after' % change_number)
for i in mpaths:
commands.getoutput('echo "\n" >>
/var/crash/%s/mpathlistattr.out.after' % change_number)
commands.getoutput('echo "=============================="
>> /var/crash/%s/mpathlistattr.out.after' % change_number)
commands.getoutput('echo %s >>
/var/crash/%s/mpathlistattr.out.after' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/mpathlistattr.out.after' % change_number)
commands.getoutput('hdparm -I /dev/mapper/%s >>
/var/crash/%s/mpathlistattr.out.after' % (i,change_number))
commands.getoutput('echo "\n" >>
/var/crash/%s/mpathlistattr.out.after' % change_number)
ethlist =
commands.getoutput("ifconfig -a | grep -i Ethernet | awk '{print
$1}'").split('\n')
commands.getoutput('echo "Ethernet
Devices: " + %s >> /var/crash/%s/ethtool.out.after' %
(ethlist,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/ethtool.out.after' % change_number)
commands.getoutput('echo
"Ethernet Devices: " + %s >> /var/crash/%s/miitool.out.after' %
(ethlist,change_number))
commands.getoutput('echo
"\n" >> /var/crash/%s/miitool.out.after' % change_number)
for i in ethlist:
commands.getoutput('echo
"==============================" >>
/var/crash/%s/ethtool.out.after' % change_number)
commands.getoutput('echo %s >> /var/crash/%s/ethtool.out.after' %
(i,change_number))
commands.getoutput('echo
"==============================" >>
/var/crash/%s/ethtool.out.after' % change_number)
commands.getoutput('ethtool %s >> /var/crash/%s/ethtool.out.after'
% (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/miitool.out.after' % change_number)
commands.getoutput('echo %s >> /var/crash/%s/miitool.out.after' %
(i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/miitool.out.after' % change_number)
commands.getoutput('mii-tool %s >>
/var/crash/%s/miitool.out.after' % (i,change_number))
bond_list =
commands.getoutput("ls /proc/net/bonding").split('\n')
for i in bond_list:
commands.getoutput('echo "=============================="
>> /var/crash/%s/bond_info.out.after' % change_number)
commands.getoutput('echo %s >> /var/crash/%s/bond_info.out.after'
% (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/bond_info.out.after' % change_number)
commands.getoutput('cat
/proc/net/bonding/%s >> /var/crash/%s/bond_info.out.after' % (i,
change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/bond_info.out.after' % change_number)
fchost_list =
commands.getoutput("ls /sys/class/fc_host").split("\n")
for i in fchost_list:
commands.getoutput('echo "=============================="
>> /var/crash/%s/fchost_info.out.after' % change_number)
commands.getoutput('echo %s >> /var/crash/%s/fchost_info.out.after'
% (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fchost_info.out.after' % change_number)
commands.getoutput('cat
/sys/class/fc_host/%s/port_name >> /var/crash/%s/fchost_info.out.after' %
(i, change_number))
commands.getoutput('cat
/sys/class/fc_host/%s/port_state >> /var/crash/%s/fchost_info.out.after'
% (i, change_number))
commands.getoutput('cat
/sys/class/fc_host/%s/symbolic_name >>
/var/crash/%s/fchost_info.out.after' % (i, change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fchost_info.out.after' % change_number)
fctarget_list =
commands.getoutput("ls /sys/class/fc_transport").split('\n')
for i in fctarget_list:
commands.getoutput('echo "=============================="
>> /var/crash/%s/fctarget_info.out.after' % change_number)
commands.getoutput('echo %s >>
/var/crash/%s/fctarget_info.out.after' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fctarget_info.out.after' % change_number)
commands.getoutput('cat
/sys/class/fc_transport/%s/port_name >>
/var/crash/%s/fctarget_info.out.after' % (i, change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fctarget_info.out.after' % change_number)
#ifcfg Information
ifcfg_list =
commands.getoutput("ls /etc/sysconfig/network-scripts | grep -i
ifcfg").split('\n')
for i in ifcfg_list:
commands.getoutput('echo
"==============================" >>
/var/crash/%s/ifcfg_info.out.after' % change_number)
commands.getoutput('echo %s >> /var/crash/%s/ifcfg_info.out.after'
% (i,change_number))
commands.getoutput('echo
"==============================" >>
/var/crash/%s/ifcfg_info.out.after' % change_number)
commands.getoutput('cat
/etc/sysconfig/network-scripts/%s >> /var/crash/%s/ifcfg_info.out.after'
% (i, change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/ifcfg_info.out.after' % change_number)
#fcoe
if
os.path.isdir("/etc/fcoe") is True:
fcoe_list =
commands.getoutput("ls /etc/fcoe").split('\n')
for i in fcoe_list:
commands.getoutput('echo "=============================="
>> /var/crash/%s/fcoeinfo.out.after' % change_number)
commands.getoutput('echo %s
>> /var/crash/%s/fcoeinfo.out.after' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fcoeinfo.out.after' % change_number)
commands.getoutput('cat
/etc/fcoe/%s >> /var/crash/%s/fcoeinfo.out.after' % (i,change_number))
commands.getoutput('echo "=============================="
>> /var/crash/%s/fcoeinfo.out.after' % change_number)
initramfs_list =
commands.getoutput('ls -l /boot | grep -i initramfs* | awk -F" "
\'{print $NF}\'').split('\n')
for i in initramfs_list:
commands.getoutput('cp
-p /boot/%s /var/crash/%s/%s.out.after' % (i, change_number, i))
commands.getoutput('tar -cf
/var/crash/%s-%s-post.tar -C /var/crash/%s/*.after' % (change_number, hostname,
change_number))
#commands.getoutput('.out.after')
#commands.getoutput('')
#commands.getoutput('')
def compare_pre_post():
print "\n+++++ Comparing
Pre and Post Checks +++++\n"
os.chdir('/var/crash/%s' %
change_number)
cmd_list = ['uname-r',
'df-k','df-hTP','lsblk','blkid','fstab','fdisk','pvs','vgs','lvs','lvm.conf','exports','mtab','mount','mdadm--detail','dmesg',
'dmesg','rpm-multipath','multipath-ll','mpathconf','multipath.conf','multipath-bindings','multipath-wwids','free','grub.conf','sysconfig-network','hosts',
'ifconfig-a','netstat-r','iptables-l','chkconfig--list','fc_host','scsi_host','rpm-qa','yum-list','sysconfig-network','fc-adapter','lspci','ls-boot','ls-boot-grub','device.map','menu.lst','pvscan',
'pcs-status','pcs-cluster-status','pcs-cluster-cib-xml','pcs-resources-strds','pcs-resource-agents-ocf','pcs-resource-agents-lsb','pcs-resource-agents-service',
'pcs-resource-agents-stonith','pcs-resource-agents','pcs-resource-describe-RA','pcs-resource-show','pcs-stonith-show','pcs-resource-rsc-default','pcs-resource-op-defaults',
'pcs-resource-failcount-show-RA','pcs-stonith-list','pcs-stonith-show','var-log-messages','dmesg','cluster-version','clustat','clustat-l','cman_tool-nodes','cman_tool-status',
'ccs_tool-lsnode','ccs_tool-lsfence','group_tool','group_tool-ls','dev-disk-by-id','dev-disk-by-uuid','dev-disk-by-path','mpathlistattr','ethtool','miitool','bond_info','fchost_info','fctarget_info','ifcfg_info','ip-a-s','ip-a',
'ip-a-s-fcoe','fipvlan-fcoe','fcoeadm-i','fcoeadm-l','fcoeadm-t','nmcli-con-show','nmcli-con-show-a','nmcli-dev-status','fcoeinfo'
]
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