#!/bin/bash -u # Script %name: DMMPsupport ############################################################################# #Description: This script file collects information useful for Linux Device Mapper #Multipath support purpose. Only a root user can run this script. The information collected # will be saved in a compressed tar file under the /tmp/directory. # ############################################################################# ############################################################################# # set up the global variables # ############################################################################## initialize_fn() { TMP_DIR=/tmp/DMMPSupport_$$ TOP_DIR=${TMP_DIR}/$(hostname) HARDWARE_INFO_DIR=${TOP_DIR}/hardware_info KERNEL_INFO_DIR=${TOP_DIR}/kernel_info KERNEL_CONFIG_INFO_DIR=${TOP_DIR}/kernel_config_info COMPILER_INFO_DIR=${TOP_DIR}/compiler_info BOOT_CONFIG_INFO_DIR=${TOP_DIR}/boot_config_info SCSI_HBA_INFO_DIR=${TOP_DIR}/scsi_hba_info DMMP_INFO_DIR=${TOP_DIR}/linuxDMMP_info FINAL_TAR=/tmp/DMMPSupportdata_$(hostname)_$(date +%m%d%y%H%M%S).tar.gz DM_MODULES_DIR=${DMMP_INFO_DIR}/modules } ############################################################################# # Collect hardware information of the target system. # ############################################################################## hardware_info_fn() { /bin/mkdir -p ${HARDWARE_INFO_DIR} /bin/cat /proc/cpuinfo >${HARDWARE_INFO_DIR}/cpuinfo.txt /bin/cat /proc/interrupts >${HARDWARE_INFO_DIR}/interrupts.txt /bin/cat /proc/partitions >${HARDWARE_INFO_DIR}/partitions.txt /bin/cat /proc/ioports >${HARDWARE_INFO_DIR}/ioports.txt /bin/cat /proc/meminfo -v >${HARDWARE_INFO_DIR}/meminfo.txt ( echo "Output of the lspci -vv " echo "##############################################" /sbin/lspci -vv echo "##############################################" echo "Output of the lspci -x " echo "##############################################" /sbin/lspci -x ) >${HARDWARE_INFO_DIR}/pciinfo.txt } ############################################################################# # Collect kernel information of the target system. # ############################################################################## kernel_info_fn() { /bin/mkdir -p ${KERNEL_INFO_DIR} ( echo "Current Running Kernel Version" /bin/uname -a /bin/cat /etc/*release ) >${KERNEL_INFO_DIR}/kernel_version.txt /sbin/lsmod >${KERNEL_INFO_DIR}/modules.txt ( echo "printk log levels from \"cat /proc/sys/kernel/printk\" " /bin/cat /proc/sys/kernel/printk ) >${KERNEL_INFO_DIR}/printk.txt ( echo "Process status list" /bin/ps -leaf ) > ${KERNEL_INFO_DIR}/ps.txt ( if [ -f /usr/bin/pstree ] then /usr/bin/pstree else echo "binary /usr/bin/pstree not installed." fi ) > ${KERNEL_INFO_DIR}/pstree.txt ( if [ -f /proc/kallsyms ] then cat /proc/kallsyms else echo "kallsyms not found in proc." fi ) > ${KERNEL_INFO_DIR}/kallsyms.txt ( if [ -f /bin/rpm ] then echo "Rpm packages installed in the system ( rpm -qa command output ) " /bin/rpm -qa else echo "rpm not installed in the system." fi ) > ${KERNEL_INFO_DIR}/rpm_packages.txt ( if [ -f /usr/bin/uptime ] then /usr/bin/uptime else echo "binary /usr/bin/uptime not installed." fi )> ${KERNEL_INFO_DIR}/uptime.txt ( if [ -f /usr/bin/sar ] then echo "System Activity Report " /usr/bin/sar -A else echo "sar package not installed in the system." fi ) > ${KERNEL_INFO_DIR}/sar.txt ( if [ -f /bin/df ] then echo "output of df -al" df -al else echo "df binary package not installed in the system" fi ) > ${KERNEL_INFO_DIR}/df.txt /bin/cat /proc/slabinfo > ${KERNEL_INFO_DIR}/slabinfo.txt ( if [ -f /usr/bin/free ] then /usr/bin/free else echo "/usr/bin/free binary not installed." fi ) > ${KERNEL_INFO_DIR}/free.txt } ############################################################################# # Collect Kernel configuration information # ############################################################################## kernel_config_info_fn() { /bin/mkdir -p ${KERNEL_CONFIG_INFO_DIR} AUTOCONF_H=/lib/modules/$(uname -r)/build/include/linux/autoconf.h if [ -f ${AUTOCONF_H} ] then /bin/cp ${AUTOCONF_H} ${KERNEL_CONFIG_INFO_DIR}/autoconf.h else echo "${AUTOCONF_H} doesn't exist" > ${KERNEL_CONFIG_INFO_DIR}/autoconf.h fi LINUX_VERSION_H=/lib/modules/$(uname -r)/build/include/linux/version.h if [ -f ${LINUX_VERSION_H} ] then /bin/cp ${LINUX_VERSION_H} ${KERNEL_CONFIG_INFO_DIR}/UTS_version.h else echo "${LINUX_VERSION_H} doesn't exist" > ${KERNEL_CONFIG_INFO_DIR}/UTS_version.h fi ############################################# #the system map file and config file of the kernel ############################################# SYSTEM_MAP_FILE=System.map-$(uname -r) /bin/cp /boot/${SYSTEM_MAP_FILE} ${KERNEL_CONFIG_INFO_DIR}/${SYSTEM_MAP_FILE}.txt CONFIGURE_FILE=config-$(uname -r) /bin/cp /boot/${CONFIGURE_FILE} ${KERNEL_CONFIG_INFO_DIR}/${CONFIGURE_FILE}.txt /bin/ls -l /usr/src > ${KERNEL_CONFIG_INFO_DIR}/kernel_src_dir_list.txt } ############################################################################# #Collect compiler and related environment information # ############################################################################## compiler_info_fn() { /bin/mkdir -p ${COMPILER_INFO_DIR} COMPILER_INFO_FILE=${COMPILER_INFO_DIR}/compiler_info.txt ( echo "gcc version ----" gcc --version echo "make version ---" make --version echo "ld version ---" ld --version echo " libc version --" /bin/ls -l `ldd /bin/sh | /bin/awk '/libc/{print $3}'` | sed \ -e 's/\.so$//' | /bin/awk -F'[.-]' '{print "Linux C Library " \ $(NF-2)"."$(NF-1)"."$NF}' echo " bash version---" /bin/bash --version )>${COMPILER_INFO_FILE} } ############################################################################# #Collect boot loader information # ############################################################################## boot_config_info_fn() { /bin/mkdir -p ${BOOT_CONFIG_INFO_DIR} ( echo "Output of /bin/ls -lR /boot" echo "###########################################" /bin/ls -lR /boot ) > ${BOOT_CONFIG_INFO_DIR}/boot_files.txt if [ `uname -m` == "ia64" ]; then LILO_CONFIG="/boot/efi/efi/redhat/elilo.conf" else LILO_CONFIG="/etc/lilo.conf" fi YABOOT_CONFIG="/etc/yaboot.conf" GRUB_CONFIG="/boot/grub/menu.lst" if [ -f ${LILO_CONFIG} ] then /bin/cp ${LILO_CONFIG} ${BOOT_CONFIG_INFO_DIR}/$(basename ${LILO_CONFIG}) fi if [ -f ${YABOOT_CONFIG} ] then /bin/cp ${YABOOT_CONFIG} ${BOOT_CONFIG_INFO_DIR}/$(basename ${YABOOT_CONFIG}) fi if [ -f ${GRUB_CONFIG} ] then /bin/cp ${GRUB_CONFIG} ${BOOT_CONFIG_INFO_DIR}/$(basename ${GRUB_CONFIG} ) if [ -f /boot/grub/device.map ] then /bin/cp /boot/grub/device.map ${BOOT_CONFIG_INFO_DIR}/device.map fi fi ( echo "kernel boot command line options" /bin/cat /proc/cmdline ) >${BOOT_CONFIG_INFO_DIR}/cmdline.txt } ############################################################################# #Collect HBA driver info # ############################################################################## scsi_hba_info_fn() { /bin/mkdir -p ${SCSI_HBA_INFO_DIR} ( if [ -f /proc/scsi/scsi ] then /bin/cat /proc/scsi/scsi else echo "Linux Scsi module sd_mod is not loaded" fi ) >${SCSI_HBA_INFO_DIR}/scsi_device.txt ( if [ -d /proc/scsi ] then echo "Output of ls -R /proc/scsi" >${SCSI_HBA_INFO_DIR}/scsi_hosts.txt /bin/ls -R /proc/scsi else echo "Linux Scsi module sd_mod is not loaded " fi ) >${SCSI_HBA_INFO_DIR}/scsi_hosts.txt for hba in $(/bin/ls /proc/scsi/) do if [ -d /proc/scsi/$hba ] then if [ $hba != "sg" ] then for host in $(/bin/ls /proc/scsi/${hba}) do if [ $host -ge 0 ] && [ $host -le 100 ] then /bin/cat /proc/scsi/$hba/$host > ${SCSI_HBA_INFO_DIR}/${hba}_$host.txt fi done fi fi done #if it is lsi driver if [ -d /proc/mpt ] then /usr/bin/find /proc/mpt -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/lsi_mpt_proc_info.txt fi ################### #module info ################### if [ -d /proc/scsi/qla2xxx ] then /sbin/modinfo qla2xxx >${SCSI_HBA_INFO_DIR}/qla2xxx_modinfo.txt fi if [ -d /proc/scsi/lpfc ] then /sbin/modinfo lpfc >${SCSI_HBA_INFO_DIR}/lpfc_modinfo.txt fi ( if [ -d /proc/scsi/mptscsih ] then /sbin/modinfo mptbase /sbin/modinfo mptscsih fi ) >${SCSI_HBA_INFO_DIR}/mpt_modinfo.txt if [ -d /proc/scsi/mptsas ] then /sbin/modinfo mptsas >> ${SCSI_HBA_INFO_DIR}/mpt_modinfo.txt fi if [ -d /proc/scsi/srp ] then # cisco and mellanox have the same /proc directory cisco_ib_modinfo=`/sbin/modinfo ts_srp_host ` if [ "XX${cisco_ib_modinfo}" = "XX" ] then # this is mellanox HCA driver /sbin/modinfo ib_srp >${SCSI_HBA_INFO_DIR}/ib_srp_modinfo.txt /usr/bin/vstat >${SCSI_HBA_INFO_DIR}/mellanox_vstat.txt else # this is cisco HCA driver /sbin/modinfo ts_srp_host >${SCSI_HBA_INFO_DIR}/ts_srp_host_modinfo.txt if [ -f /usr/local/topspin/bin/vstat ] then /usr/local/topspin/bin/vstat >${SCSI_HBA_INFO_DIR}/cisco_vstat.txt fi fi fi #silverstorm debug capture if [ -d /proc/driver/ics_srp ] then /sbin/modinfo ics_srp >${SCSI_HBA_INFO_DIR}/ics_srp_modinfo.txt fi if [ -f /sbin/p1info ] then /sbin/p1info >${SCSI_HBA_INFO_DIR}/ics_p1info.txt fi if [ -f /sbin/p2info ] then /sbin/p2info >${SCSI_HBA_INFO_DIR}/ics_p2info.txt fi #ofed debug capture if [ -f /usr/local/ofed/bin/ibhosts ] then /usr/local/ofed/bin/ibhosts >${SCSI_HBA_INFO_DIR}/ofed_ibhosts.txt fi if [ -f /usr/local/ofed/bin/ibstat ] then /usr/local/ofed/bin/ibstat >${SCSI_HBA_INFO_DIR}/ofed_ibstat.txt fi if [ -f /usr/local/ofed/bin/ibstatus ] then /usr/local/ofed/bin/ibstatus >${SCSI_HBA_INFO_DIR}/ofed_ibstatus.txt fi if [ -f /usr/local/ofed/bin/ibv_devices ] then /usr/local/ofed/bin/ibv_devices >${SCSI_HBA_INFO_DIR}/ofed_ibv_devices.txt fi if [ -f /usr/local/ofed/bin/ibv_devinfo ] then /usr/local/ofed/bin/ibv_devinfo >${SCSI_HBA_INFO_DIR}/ofed_ibv_devinfo.txt fi if [ -f /usr/local/ofed/bin/ibswitches ] then /usr/local/ofed/bin/ibswitches >${SCSI_HBA_INFO_DIR}/ofed_ibswitches.txt fi if [ -f /usr/local/ofed/bin/ofed_info ] then /usr/local/ofed/bin/ofed_info >${SCSI_HBA_INFO_DIR}/ofed_info.txt fi if [ -f /usr/local/ofed/bin/perfquery ] then /usr/local/ofed/bin/perfquery >${SCSI_HBA_INFO_DIR}/ofed_perfquery.txt fi if [ -f /usr/local/ofed/bin/saquery ] then /usr/local/ofed/bin/saquery >${SCSI_HBA_INFO_DIR}/ofed_saquery.txt fi if [ -f /usr/local/ofed/bin/sminfo ] then /usr/local/ofed/bin/sminfo >${SCSI_HBA_INFO_DIR}/ofed_sminfo.txt fi ################## #sysfs output ################### /bin/ls -lR /sys/class/scsi_device >${SCSI_HBA_INFO_DIR}/sys_scsi_devices.txt /bin/ls -lR /sys/class/scsi_host >${SCSI_HBA_INFO_DIR}/sys_scsi_host.txt ################## #fc_transport output ################### ( if [ -d /sys/class/fc_transport ] then echo "List of Physical Scsi Devices and their fc_transport information" echo "ls -l /sys/class/fc_transport/" /bin/ls -l /sys/class/fc_transport echo "" echo "" echo "#################################################" echo "PortName, PortId and NodeName of each Scsi device" echo "#################################################" for entry in $(/bin/ls /sys/class/fc_transport) do echo "/sys/class/fc_transport/"$entry PORT_NAME=$(/bin/cat /sys/class/fc_transport/${entry}/port_name) echo "port_name: ${PORT_NAME}" PORT_ID=$(/bin/cat /sys/class/fc_transport/${entry}/port_id) echo "port_id: ${PORT_ID}" NODE_NAME=$(/bin/cat /sys/class/fc_transport/${entry}/node_name) echo "node_name: ${NODE_NAME}" echo "" done fi ) > ${SCSI_HBA_INFO_DIR}/sys_fc_transport.txt if [ -d /sys/class/fc_host ] then /usr/bin/find /sys/class/fc_host -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/sys_fc_host.txt fi if [ -d /sys/class/fc_remote_ports ] then /usr/bin/find /sys/class/fc_remote_ports -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/sys_fc_remote_ports.txt fi ###################################################### #Capture scsi_host information from /sys file system ###################################################### if [ -d /sys/class/scsi_host ] then /usr/bin/find /sys/class/scsi_host -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/sys_class_scsihost_info.txt fi ################## #Mellanox infiniband output ################### if [ -d /proc/infiniband ] then /usr/bin/find /proc/infiniband -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/mellanox_proc_info.txt fi ################## #SilverStorm infiniband output ################### if [ -d /proc/driver/ics_dsc ] then /usr/bin/find /proc/driver/ics_dsc -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/silverstorm_proc_info.txt fi if [ -d /proc/driver/ics_srp ] then /usr/bin/find /proc/driver/ics_srp -type f -print -exec /bin/cat {} \; \ >>${SCSI_HBA_INFO_DIR}/silverstorm_proc_info.txt fi if [ -f /etc/sysconfig/ics_srp.cfg ] then /usr/bin/find /etc/sysconfig/ics_srp.cfg -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/silverstorm_ics_srp_cfg.txt fi ################## #iscsi ################### if [ -d /sys/class/iscsi_connection ] then /usr/bin/find /sys/class/iscsi_connection -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/sys_iscsi_connection.txt fi if [ -d /sys/class/iscsi_session ] then /usr/bin/find /sys/class/iscsi_session -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/sys_iscsi_session.txt fi if [ -d /sys/class/iscsi_transport ] then /usr/bin/find /sys/class/iscsi_transport -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/sys_iscsi_transport.txt fi if [ -d /sys/class/iscsi_host ] then /usr/bin/find /sys/class/iscsi_host -type f -print -exec /bin/cat {} \; \ >${SCSI_HBA_INFO_DIR}/sys_iscsi_host.txt fi if [ -f /sbin/iscsiadm ] then ( echo "Output of iscsiadm -m session" /sbin/iscsiadm -m session echo "#######################################" echo "Output of iscsiadm -m session -i" /sbin/iscsiadm -m session -i ) >${SCSI_HBA_INFO_DIR}/iscsiadm_output.txt fi if [ -f /etc/iscsi/initiatorname.iscsi ] then /bin/cp /etc/iscsi/initiatorname.iscsi ${SCSI_HBA_INFO_DIR}/initiatorname.iscsi fi if [ -f /etc/iscsi/iscsid.conf ] then /bin/cp /etc/iscsi/iscsid.conf ${SCSI_HBA_INFO_DIR}/iscsid.conf fi } ############################################################################ # Collect DM and related kernel modules # ############################################################################ linux_DMINFO_fn() { /bin/mkdir -p ${DM_MODULES_DIR} if [ -d /lib/modules/`uname -r`/kernel/drivers/md ] then scp -r /lib/modules/`uname -r`/kernel/drivers/md ${DM_MODULES_DIR}/ fi if [ /lib/modules/`uname -r`/kernel/drivers/scsi/device_handler ] then scp -r /lib/modules/`uname -r`/kernel/drivers/scsi/device_handler ${DM_MODULES_DIR}/ fi ( if [ -f /var/lib/multipath/bindings ] then /bin/cat /var/lib/multipath/bindings else echo "Did not find /var/lib/multipath/bindings file..." fi )>${DMMP_INFO_DIR}/binding.conf if [ /sbin/dmsetup ] then /sbin/dmsetup info >${DMMP_INFO_DIR}/dmsetup_info.txt /sbin/dmsetup table >${DMMP_INFO_DIR}/dmsetup_table.txt /sbin/dmsetup status >${DMMP_INFO_DIR}/dmsetup_status.txt fi if [ /sbin/multipath ] then /sbin/multipath -ll >${DMMP_INFO_DIR}/multipath_ll.txt /sbin/multipath -t >${DMMP_INFO_DIR}/multipath_t.txt if [ $DMMP_DD -eq 1 ] then ## this will refresh the multipath map /sbin/multipath -v5 >${DMMP_INFO_DIR}/multipath_v5.txt fi fi ( if [ -f /etc/multipath.conf ] then /bin/cat /etc/multipath.conf else echo "Did not find /etc/multipath.conf file..." fi ) >${DMMP_INFO_DIR}/multipath.conf ( if [ -f /sbin/multipath ] then echo "DM kernel module version" modinfo dm-mod modinfo dm-multipath echo "multipath-tool version" /sbin/multipath -h else echo "Linux DMMP is not installed on the system " fi ) >${DMMP_INFO_DIR}/DMMP_versions.txt if [ `uname -m` == "ia64" ]; then INITRD_IMAGE=/boot/efi/efi/redhat/initrd-`uname -r` else INITRD_IMAGE=/boot/initrd-`uname -r` INITRD_KDUMP_IMAGE=/boot/initrd-`uname -r`-kdump fi if [ -f $INITRD_IMAGE ] then /bin/cp $INITRD_IMAGE* ${DMMP_INFO_DIR}/. else echo "Did not find $INITRD_IMAGE file.." \ >${INITRD_INFO_DIR}/INITRD_IMAGE.txt fi if [ -f $INITRD_KDUMP_IMAGE ] then /bin/cp $INITRD_KDUMP_IMAGE* ${DMMP_INFO_DIR}/ else echo "Did not find $INITRD_KDUMP_IMAGE file.." \ >${DMMP_INFO_DIR}/INITRD_KDUMP_IMAGE.txt fi ( if [ -f /etc/syslog.conf ] then /bin/cat /etc/syslog.conf else echo "Did not find /etc/syslog.conf file..." fi )>${DMMP_INFO_DIR}/syslog.conf if [ -f /var/log/messages ] then /bin/cp /var/log/messages ${DMMP_INFO_DIR} else echo "Did not find syslog file..." >${DMMP_INFO_DIR}/messages fi ( if [ -f /etc/modprobe.conf ] then /bin/cat /etc/modprobe.conf else echo "Did not find /etc/modprobe.conf file..." fi )>${DMMP_INFO_DIR}/modprobe.conf ( if [ -f /etc/modprobe.conf.local ] then /bin/cat /etc/modprobe.conf.local else echo "Did not find /etc/modprobe.conf.local file..." fi ) >${DMMP_INFO_DIR}/modprobe.conf.local if [ -f /etc/modprobe-openib.conf ] then /bin/cp /etc/modprobe-openib.conf ${DMMP_INFO_DIR}/modprobe-openib.conf fi ( if [ -f /usr/bin/lsscsi ] then echo " " echo " Output of lsscsi -Hl" echo "*********************** " /usr/bin/lsscsi -Hl echo " " echo " Output of lsscsi -ldg" echo "*********************** " /usr/bin/lsscsi -ldg else echo "Did not find /usr/bin/lsscsi file..." fi ) >${DMMP_INFO_DIR}/lsscsi.txt } ############################################################################# # create summary file # ############################################################################## summary_fn() { ( /bin/cat <>${TOP_DIR}/summary.txt } ############################################################################# # create tar ball # ############################################################################## tar_compress_fn() { cd ${TMP_DIR} /bin/tar -zcf ${FINAL_TAR} * /bin/rm -rf ${TMP_DIR} } ############################################################################ # dmmpSupport Usage # ############################################################################## dmmpSupport_usage() { echo "Usage: $0 [-a][-h][-s]" exit 2; } ############################################################################# # Do all things we need # ############################################################################## work_horse() { ( hardware_info_fn kernel_info_fn kernel_config_info_fn compiler_info_fn boot_config_info_fn scsi_hba_info_fn linux_DMINFO_fn summary_fn tar_compress_fn ) 2>/dev/null echo "The collected support data is saved in ${FINAL_TAR}." } ######################### # script entry ############################ DMMP_DOIO=0 DMMP_DD=0 if [ $# -gt 1 ] then dmmpSupport_usage elif [ $# -eq 1 ] then while getopts ahs op 2>/dev/null do case "$op" in a) DMMP_DOIO=1;; s) DMMP_DD=1;; h) dmmpSupport_usage;; \?) dmmpSupport_usage;; esac done ##### #the option must be -a or -s or -h ###### if [ $DMMP_DOIO -eq 0 ] && [ $DMMP_DD -eq 0 ] then dmmpSupport_usage fi fi initialize_fn work_horse