#System Information collection for IBM AIX Platform Version=V0.1 INFO_TIME=`date +%Y%m%d-%H%M%S` CUR_TIME=`date +%Y-%m-%d' '%H:%M:%S' '%A' '%Z` HOSTNAME=`hostname` Model=`uname -M` Systemid=`uname -u` USER=`whoami` SN=`uname -u|cut -c 7-13` TMP=/tmp/System_info_collect_${HOSTNAME} LVM_TMP=${TMP}/lvm FILE_NAME=${HOSTNAME}_${SN}_${Version}_${INFO_TIME} ERR_RPT=${TMP}/Error_report.txt OUT_DIR=/home/system_info if [ $USER != 'root' ] then echo '** WARNING **' >&0 echo 'Please run this script as user root.\nExit' >&0 exit fi if test ! -d ${OUT_DIR} then mkdir -p ${OUT_DIR} echo 'The output dir ${OUT_DIR} has been created successfully!' fi if test ! -f ${OUT_DIR}/info_AIX.sh then cp $0 ${OUT_DIR}/info_AIX.sh echo 'This Script has been copied as ${OUT_DIR}/info_AIX.sh' fi echo 'useage: sh $0' ####################Start of Removing Temporary Files################# cleanup() { if test -d ${TMP} then cd /tmp echo 'Removing Temporary Files....' # rm -rf /tmp/System_info_collect_`hostname` > /dev/null 2>>${ERR_RPT} rm -rf ${TMP} > /dev/null 2>$0 if [ $? -ne 0 ] then echo '\nError : Unable to delete temp directory - ${i}\n' echo '\nPlease delete the contents of ${i} manually!\n' fi echo 'Remove Temporary Files Successfully!' cd ${OUT_DIR} fi } cleanup ####################End of Removing Temporary Files################# ######################Start of Function col_info#################### col_info(){ if [ '$#' -eq '0' ] then echo 'Hostname: ${HOSTNAME}' echo 'Username: ${USER}' echo 'Model: ${Model}' echo 'Systemid: ${Systemid}'>>${OUT} echo 'Current Time: ${CUR_TIME}' echo '############################################################' else if [ '$#' -eq '2' ] then CMD=$1 OUT=$2 CMD2=`echo ${CMD}|awk '{print $1}'` which ${CMD2} >/dev/null 2>&1 if [ $? -eq 0 ] then echo 'Hostname: ${HOSTNAME}' >>${OUT} echo 'Username: ${USER}'>>${OUT} echo 'Model: ${Model}'>>${OUT} echo 'Systemid: ${Systemid}'>>${OUT} echo 'Current Time: ${CUR_TIME}'>>${OUT} echo '###########################$1#################################' >>${OUT} echo '#${CMD}'>>${OUT} ${CMD} >>${OUT} 2>&1 echo '\n'>>${OUT} else echo 'The first parameter \'${CMD}\' is error,please check.' #check whether the first parameter is a AIX command #which ${CMD2} >&0 2>&1 fi else echo 'Error!\nThere is $# parameter!'>&0 echo 'The first parameter is $1' fi fi } ######################End of Function col_info#################### echo 'Information collecting,please wait....' >&0 ################ Start of System Info ####################### CMD_TMP=${TMP}/System_info mkdir -p ${CMD_TMP} col_info 'hostname' '${CMD_TMP}/System_info.txt' 2>>${ERR_RPT}& col_info 'lsrsrc IBM.ManagementServer' '${CMD_TMP}/HMC.txt' 2>>${ERR_RPT}& col_info 'bootlist -m normal -o' '${CMD_TMP}/bootlist_-m_normal_-o.txt' 2>>${ERR_RPT}& col_info 'bootinfo -k' '${CMD_TMP}/System_info.txt' 2>>${ERR_RPT}& col_info 'uptime' '${CMD_TMP}/uptime.txt' 2>>${ERR_RPT}& col_info 'oslevel' '${CMD_TMP}/oslevel.txt' 2>>${ERR_RPT}& col_info 'oslevel -r' '${CMD_TMP}/oslevel_-r.txt' 2>>${ERR_RPT}& col_info 'oslevel -s' '${CMD_TMP}/oslevel_-s.txt' 2>>${ERR_RPT}& col_info 'echo \$TZ' '${CMD_TMP}/echo_TZ.txt' 2>>${ERR_RPT}& col_info 'lssrc -s xntpd' '${CMD_TMP}/lssrc_-s_xntpd.txt' 2>>${ERR_RPT}& col_info 'ntpq -p' '${CMD_TMP}/ntpq_-p.txt' 2>>${ERR_RPT}& col_info 'lsattr -El sys0' '${CMD_TMP}/lsattr_-El_sys0.txt' 2>>${ERR_RPT}& col_info 'prtconf' '${CMD_TMP}/prtconf.txt' 2>>${ERR_RPT}& col_info 'lsmcode -A' '${CMD_TMP}/lsmcode_-A.txt' 2>>${ERR_RPT}& col_info 'instfix -a' '${CMD_TMP}/instfix_-a.txt' 2>>${ERR_RPT}& col_info 'instfix -i' '${CMD_TMP}/instfix_-i.txt' 2>>${ERR_RPT}& col_info 'lslpp -h' '${CMD_TMP}/lslpp_-h.txt' 2>>${ERR_RPT}& col_info 'lslpp -L' '${CMD_TMP}/lslpp_-L.txt' 2>>${ERR_RPT}& col_info 'lssrc -a' '${CMD_TMP}/lssrc_-a.txt' 2>>${ERR_RPT}& col_info 'no -a' '${CMD_TMP}/no_-a.txt' 2>>${ERR_RPT}& col_info 'alog -o -t boot' '${CMD_TMP}/alog_-o_-t_boot.txt' 2>>${ERR_RPT}& col_info 'crontab -l' '${CMD_TMP}/crontab_-l.txt' 2>>${ERR_RPT}& col_info 'errpt' '${CMD_TMP}/errpt.txt' 2>>${ERR_RPT}& col_info 'errpt -d H' '${CMD_TMP}/errpt_-d_H.txt' 2>>${ERR_RPT}& col_info 'ipcs -a' '${CMD_TMP}/ipcs_-a.txt' 2>>${ERR_RPT}& col_info 'ipcs -msa' '${CMD_TMP}/ipcs_-msa.txt' 2>>${ERR_RPT}& col_info 'ps aux' '${CMD_TMP}/ps_aux.txt' 2>>${ERR_RPT}& col_info 'ps -ef' '${CMD_TMP}/ps_-ef.txt' 2>>${ERR_RPT}& col_info 'df -g' '${CMD_TMP}/df_-g.txt' 2>>${ERR_RPT}& col_info 'df -k' '${CMD_TMP}/df_-k.txt' 2>>${ERR_RPT}& col_info 'mount' '${CMD_TMP}/mount.txt' 2>>${ERR_RPT}& col_info 'lsfs' '${CMD_TMP}/lsfs.txt' 2>>${ERR_RPT}& col_info >>${CMD_TMP}/etc_hosts.txt cat /etc/hosts >>${CMD_TMP}/etc_hosts.txt col_info >>${CMD_TMP}/etc_filesystems.txt cat /etc/filesystems >>${CMD_TMP}/etc_filesystems.txt col_info >>${CMD_TMP}/${USER}_.profile.txt cat ~/.profile >>${CMD_TMP}/${USER}_.profile.txt col_info >>${CMD_TMP}/etc_inittab.txt cat /etc/inittab >>${CMD_TMP}/etc_inittab.txt col_info >>${CMD_TMP}/etc_limits.txt cat /etc/security/limits >>${CMD_TMP}/etc_limits.txt CMD_TMP=${TMP}/System_info/USER mkdir -p ${CMD_TMP} col_info >>${CMD_TMP}/etc_passwd.txt cat /etc/passwd >>${CMD_TMP}/etc_passwd.txt col_info 'lsgroup ALL' '${CMD_TMP}/lsgroup_ALL.txt' 2>>${ERR_RPT}& col_info >>'${CMD_TMP}/id_user.txt' USER2=`cut -d: -f1 /etc/passwd` for i in ${USER2}; do col_info 'lsuser ${i}' '${CMD_TMP}/lsuser_${i}.txt' 2>>${ERR_RPT}& echo '#id ${i}' >>'${CMD_TMP}/id_user.txt' id ${i} >>'${CMD_TMP}/id_user.txt' 2>>${ERR_RPT} echo '\n'>>'${CMD_TMP}/id_user.txt' done ################ End of System Info ####################### ################ Start of Device ####################### CMD_TMP=${TMP}/Device mkdir -p ${CMD_TMP} col_info 'prtconf -c' '${CMD_TMP}/prtconf_-c.txt' 2>>${ERR_RPT} col_info 'lsdev -Cc processor' '${CMD_TMP}/lsdev_Cc_processor.txt' col_info 'lsattr -El proc0' '${CMD_TMP}/lsattr_El_proc0.txt' col_info 'lsattr -El mem0' '${CMD_TMP}/Memory.txt' col_info 'lscfg -vp |grep -p Memory' '${CMD_TMP}/lscfg_-vp_grep_-p_Memory.txt' col_info 'lsslot -c pci' '${CMD_TMP}/lsslot_-c_pci.txt' col_info 'lscfg -vp' '${CMD_TMP}/lscfg_-vp.txt' col_info 'lscfg -v' '${CMD_TMP}/lscfg_-v.txt' col_info 'lsdev -C' '${CMD_TMP}/lsdev_-C.txt' col_info 'lsdev -Cc driver' '${CMD_TMP}/lsdev_-Cc_driver.txt' #############################Start of Network##################################### CMD_TMP=${TMP}/Device/Network mkdir -p ${CMD_TMP} col_info 'ifconfig -a' '${CMD_TMP}/ifconfig_-a.txt' col_info 'netstat -in' '${CMD_TMP}/netstat_-in.txt' col_info 'netstat -rn' '${CMD_TMP}/netstat_-rn.txt' col_info >>'${CMD_TMP}/lsdev_-Cc_adapter_grep_ent.txt' echo '#lsdev -Cc adapter|grep ent' >>'${CMD_TMP}/lsdev_-Cc_adapter_grep_ent.txt' lsdev -Cc adapter|grep ent >>'${CMD_TMP}/lsdev_-Cc_adapter_grep_ent.txt' ENT=`lsdev -Cc adapter|awk '{print $1}' |grep ent` for i in ${ENT}; do col_info 'lsattr -El ${i}' '${CMD_TMP}/lsattr_-El_${i}.txt' 2>>${ERR_RPT}& col_info 'lscfg -vpl ${i}' '${CMD_TMP}/lscfg_-vpl_${i}.txt' 2>>${ERR_RPT}& done col_info 'ifconfig -l' '${CMD_TMP}/ifconfig_-l.txt' col_info >> '${CMD_TMP}/en_Speed.txt' ENT2=`ifconfig -l` for i in ${ENT2}; do if [ $i != 'lo0' ] then col_info 'lsattr -El ${i}' '${CMD_TMP}/lsattr_-El_${i}.txt' 2>>${ERR_RPT}& col_info 'netstat -v $i' '${CMD_TMP}/netstat_-v_$i.txt' 2>>${ERR_RPT}& echo '#netstat -v $i |grep -i Speed' >> '${CMD_TMP}/en_Speed.txt' 2>>${ERR_RPT} netstat -v $i |grep -i Speed >> '${CMD_TMP}/en_Speed.txt' 2>>${ERR_RPT} echo '\n'>> '${CMD_TMP}/en_Speed.txt' 2>>${ERR_RPT} fi done #############################End of Network##################################### #############################Start of HBA##################################### CMD_TMP=${TMP}/Device/fcs mkdir -p ${CMD_TMP} col_info >>'${CMD_TMP}/lsdev_-Cc_adapter_grep_fcs.txt' echo '#lsdev -Cc adapter|grep fcs' >>'${CMD_TMP}/lsdev_-Cc_adapter_grep_fcs.txt' lsdev -Cc adapter|grep fcs >>'${CMD_TMP}/lsdev_-Cc_adapter_grep_fcs.txt' FCS=`lsdev -Cc adapter|grep fcs|awk '{print $1}'` for i in ${FCS}; do col_info 'lsattr -El ${i}' '${CMD_TMP}/lsattr_-El_${i}.txt' 2>>${ERR_RPT}& col_info 'lscfg -vpl ${i}' '${CMD_TMP}/lscfg_-vpl_${i}.txt' 2>>${ERR_RPT}& col_info 'fcstat $i' '${CMD_TMP}/fcstat_$i.txt' 2>>${ERR_RPT}& done #############################End of HBA##################################### #############################Start of Tape##################################### CMD_TMP=${TMP}/Device/tape mkdir -p ${CMD_TMP} col_info 'lsdev -Cc tape' '${CMD_TMP}/lsdev_-Cc_tape.txt' ENT=`lsdev -Cc tape|awk '{print $1}'` for i in ${ENT}; do col_info 'lsattr -El ${i}' '${CMD_TMP}/lsattr_-El_${i}.txt' 2>>${ERR_RPT}& col_info 'lscfg -vpl ${i}' '${CMD_TMP}/lscfg_-vpl_${i}.txt' 2>>${ERR_RPT}& done #############################End of Tape##################################### ################ Start of Disk Info ####################### CMD_TMP=${TMP}/Device/Disk mkdir -p ${CMD_TMP} mkdir -p ${CMD_TMP}/lsattr_-El mkdir -p ${CMD_TMP}/lscfg_-vpl col_info 'lsdev -Cc disk' '${CMD_TMP}/lsdev_-Cc_disk.txt' col_info 'lspath' '${CMD_TMP}/lspath.txt' col_info >>'${CMD_TMP}/disk_size.txt' 2>>${ERR_RPT} DISK=`lsdev -Cc disk|awk '{print $1}'` for i in ${DISK} do col_info 'lsattr -El ${i}' '${CMD_TMP}/lsattr_-El/lsattr_-El_${i}.txt' 2>>${ERR_RPT}& col_info 'lscfg -vpl ${i}' '${CMD_TMP}/lscfg_-vpl/lscfg_-vpl_${i}.txt' 2>>${ERR_RPT}& echo '\n#bootinfo -s' $i >>'${CMD_TMP}/disk_size.txt' 2>>${ERR_RPT} bootinfo -s $i >>'${CMD_TMP}/disk_size.txt' 2>>${ERR_RPT} echo '\n' >>'${CMD_TMP}/disk_size.txt' 2>>${ERR_RPT} done ################ End of Disk Info ####################### ################ End of Device ####################### ###################### Start of VG PV LV ####################### mkdir -p ${LVM_TMP} col_info 'lsvg' '${LVM_TMP}/lsvg.txt' col_info 'lsvg -o' '${LVM_TMP}/lsvg_-o.txt' col_info 'lspv' '${LVM_TMP}/lspv.txt' col_info 'lsps -a' '${LVM_TMP}/lsps_-a.txt' 2>>${ERR_RPT} col_info 'lsps -s' '${LVM_TMP}/lsps_-s.txt' 2>>${ERR_RPT} col_info 'swap -l' '${LVM_TMP}/swap_-l.txt' 2>>${ERR_RPT} col_info 'sysdumpdev -l' '${LVM_TMP}/sysdumpdev_-l.txt' 2>>${ERR_RPT} col_info 'sysdumpdev -L' '${LVM_TMP}/sysdumpdev_-L2.txt' 2>>${ERR_RPT} VG=`lsvg` for i in ${VG} do CMD_TMP=${LVM_TMP}/${i} mkdir -p ${CMD_TMP} col_info 'lsvg ${i}' '${CMD_TMP}/lsvg_${i}.txt' 2>>${ERR_RPT} col_info 'lsvg -M ${i}' '${CMD_TMP}/lsvg_-M_${i}.txt' 2>>${ERR_RPT} for j in -p -l do col_info 'lsvg ${j} ${i}' '${CMD_TMP}/lsvg_${j}_${i}.txt' 2>>${ERR_RPT} done LV=`lsvg -l ${i} 2>>${ERR_RPT} | awk 'NR>2 { print $1 }'` mkdir -p ${CMD_TMP}/lslv mkdir -p ${CMD_TMP}/lslv_-m mkdir -p ${CMD_TMP}/getlvcb_-m for j in ${LV} do col_info 'lslv ${j}' '${CMD_TMP}/lslv/lslv_${j}.txt' 2>>${ERR_RPT} col_info 'lslv -m ${j}' '${CMD_TMP}/lslv_-m/lslv_-m_${j}.txt' 2>>${ERR_RPT} col_info 'getlvcb -AT ${j}' '${CMD_TMP}/getlvcb_-m/getlvcb_-AT_${j}.txt' 2>>${ERR_RPT} done PV=`lsvg -p $i 2>>${ERR_RPT} | awk 'NR>2 { print $1 }'` for j in ${PV} do col_info 'lspv -l ${j}' '${CMD_TMP}/lspv_-l_${j}.txt' 2>>${ERR_RPT} done done ###################### End of VG PV LV ####################### ###################### Start Of HACMP ########################## clconfig=/usr/sbin/cluster/diag/clconfig HACMP_CHECK() { CMD_TMP=${TMP}/HACMP mkdir -p ${CMD_TMP} col_info 'lssrc -g cluster' '${CMD_TMP}/lssrc_-g_cluster.txt' 2>>${ERR_RPT} col_info 'clstat' '${CMD_TMP}/clstat.txt' 2>>${ERR_RPT} col_info 'clconfig -v '-tr'' >> '${CMD_TMP}/clconfig_-v_-tr.txt' 2>>${ERR_RPT} } lslpp -l | grep cluster.es.clvm >/dev/null if [ $? -eq 0 ] then HACMP_CHECK 2>>${ERR_RPT}& else echo 'This machine is not install HACMP,Skip HACMP Checking!' >&1|tee -a ${ERR_RPT} fi ###################### End Of HACMP ########################## which gzip >/dev/null 2>&0 if [ $? -eq 0 ] then tar cf - ${TMP}|gzip >${OUT_DIR}/System_info_${FILE_NAME}.tar.gz echo 'Information collecting complete successfully!' >&0 echo 'Information output: ${OUT_DIR}/System_info_${FILE_NAME}.tar.gz' >&0 else tar cf - ${TMP}|compress >${OUT_DIR}/System_info_${FILE_NAME}.tar.Z echo 'Information collecting complete successfully!' >&0 echo 'Information output: ${OUT_DIR}/System_info_${FILE_NAME}.tar.Z' >&0 fi |
|