#!/bin/bash ############################################################################ # # snapshot - A system information gathering tool. # # Copyright (C) 2004 Hewlett-Packard Development Company, L.P. # # Author: Eddie Quinteros # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################ #Make sure root runs this script PATH=/bin:/sbin:/usr/bin:/usr/sbin if [ `whoami` != "root" ] then echo You must be logged in as root to run snapshot exit fi VERSION="3.4.0.2" Working_Dir=`hostname` #_`eval date "+%Y-%m-%d"` #make a directory to place files rm -rf $Working_Dir mkdir $Working_Dir Report_Html_File=$Working_Dir/index.html #Get a temp file to write the text_file text_file=$Working_Dir/text_file$$ touch $text_file #Start the html writting - divide head and info Frames echo "$Working_Dir: Snapshot report " >> $Report_Html_File Report_Html_File=$Working_Dir/heading.html #write the head frame echo " Report Generated for HP Support" >> $Report_Html_File echo "" >> $Report_Html_File echo "
Report for `hostname` on `date "+%m-%d-%Y %H:%M:%S"`
" >> $Report_Html_File echo "
Produced by snapshot Version $VERSION
" >> $Report_Html_File echo "
Summary Kernel Hardware Software File Systems Network Services Stats Log-Files Misc-files Graphics
" >> $Report_Html_File #write the info frames #write the main sections start_main() { echo Processing $1 information Report_Html_File=$Working_Dir/$1.html #touch $Working_Dir echo "$1 Report" >> $Report_Html_File Top_Menu=$1_menu echo "

$1

" >> $Report_Html_File echo "" >> $Report_Html_File #Join the two files into one .html file cat $text_file >> $Report_Html_File echo "" >> $Report_Html_File echo "" > $text_file } #Write Subections start_submain() { echo "
  • $1" >> $Report_Html_File echo "" >> $Report_Html_File } #write the text in
     format to the text file
    to_text() {
    echo "
    " >> $text_file
    eval $1 >> $text_file
    echo "
    " >> $text_file } #cat_file for catting file #usage: #cat_file "full_path_of_file" "tag_name" cat_file() { if [ -e $1 ] then echo "
  • $1 " >> $Report_Html_File #Do the text file Data echo "

    $1

    " >> $text_file to_text "cat $1" fi } #parse_command for parsing commands #usage: #parse_command "full_path_of_command" "args" "tag_name" parse_command() { if [ -x $1 ] then #Do the html menu echo "
  • $3 " >> $Report_Html_File #Do the text file Menu echo "

    $3

    " >> $text_file if [ $1 == "/usr/bin/dpkg" ] then to_text "COLUMNS=220 /usr/bin/dpkg $2" else to_text "$1 $2" fi fi } #Reporting Sumary info start_main Summary #dmidecode crashes cell systems Find a way to distinguish cell systems PLATFORM=`uname -m` if [ "$PLATFORM" = "ia64" ] ; then #check if this is a cellbased system if [ -x /sbin/hpbmc ] ; then SYSTYPE=`/sbin/hpbmc | grep "Product Name" | grep -e "rx[123456][246][02467]0"` # all not cellbased systemtypes parse_command "/sbin/hpbmc" "|grep server" "System-Type" fi fi if [ ! "$PLATFORM"="ia64" -o -n "$SYSTYPE" ] ; then parse_command "/usr/sbin/dmidecode" "|grep Product|head -1" "System-Type" fi cat_file "/etc/redhat-release" cat_file "/etc/UnitedLinux-release" parse_command "/bin/uname" "-r" "Kernel-version" cat_file "/proc/version" parse_command "/sbin/runlevel" " " "runlevel" cat_file "/etc/lsb-release" cat_file "/etc/issue" parse_command "/bin/hostname" " " "/bin/hostname" parse_command "/bin/date" " " "/bin/date" end_main #Reporting Kernel Info start_main Kernel parse_command "/bin/uname" "-a" "/bin/uname -a" cat_file "/proc/version" cat_file "/proc/sys/kernel/tainted" cat_file "/boot/efi/efi/redhat/elilo.conf" cat_file "/boot/efi/efi/SuSE/elilo.conf" cat_file "/etc/lilo.conf" cat_file "/etc/elilo.conf" cat_file "/boot/grub/device.map" cat_file "/boot/grub/grub.conf" cat_file "/etc/grub.conf" cat_file "/proc/cmdline" parse_command "/lib/modules/`uname -r`/modules.dep" "modules.dep" "cat" parse_command "/bin/rpm" "-qa|grep kernel" "Kernels installed" cat_file "/etc/modules.conf" cat_file "/etc/modprobe.conf" cat_file "/etc/modprobe.d/arch/ia64" cat_file "/etc/sysctl.conf" parse_command "/sbin/sysctl" "-a 2>&1 /dev/null" "Configured-Kernel-Params" parse_command "/bin/ls" " -ltRL /boot" "ls -ltRL /boot" cat_file "/proc/ksyms" cat_file "/proc/kallsyms" cat_file "/boot/System.map" cat_file "/boot/System.map-`eval uname -r`" start_submain Dumputils-LKCD cat_file "/proc/sys/kernel/sysrq" cat_file "/proc/sys/kernel/kdb" cat_file "/proc/diskdump" cat_file "/etc/sysconfig/dump" cat_file "/etc/sysconfig/netdump" cat_file "/etc/sysconfig/netdump_id_dsa" cat_file "/etc/sysconfig/netdump_id_dsa.pub" cat_file "/etc/sysconfig/diskdump" cat_file "/etc/dumputils.conf" cat_file "/etc/dump" if [ -d /var/crash ] then parse_command "/bin/ls" "-ltRL /var/crash" "/ls -ltRL /var/crash" fi if [ -d /proc/sys/dump ] then for f in `find /proc/sys/dump/ -type f` do cat_file "$f" done fi if [ -e /dev/vmdump ] then parse_command "/bin/ls" "-l /dev/vmdump" "Dump device information" fi if [ -d /var/log/dump ] then parse_command "/bin/ls" "-ltRL /var/log/dump" "ls -ltRL /var/log/dump" fi if [ -d /var/log/hpde-support-dumpdata ] then parse_command "/bin/ls" "-ltRL /var/log/hpde-support-dumpdata" "hpde-support-dumpdata" fi end_submain parse_command "/sbin/lsmod" " " "Loaded Modules" start_submain "Modinfo" for i in `/sbin/lsmod|grep -v Module|awk '{print $1}'|grep -v bond` do parse_command "/sbin/modinfo" "$i" "$i" done if [ `eval /sbin/lsmod|grep bond|awk '{print $1}'|grep bonding` ] then parse_command "/sbin/modinfo" "bonding" "bonding" fi end_submain end_main #Reporting Hardware start_main Hardware parse_command "/sbin/hwclock" " " "/sbin/hwclock" cat_file "/proc/cpuinfo" cat_file "/proc/meminfo" cat_file "/proc/iomem" "/proc/iomem" #lspci not available on IA64 if [ -e /sbin/lspci ] then parse_command "/sbin/lspci" "-v" "PCI-Devices" else cat_file "/proc/pci" fi cat_file "/proc/ioports" cat_file "/proc/interrupts" cat_file "/proc/dma" parse_command "/sbin/lsusb" " " "lsusb" cat_file "/proc/scsi/device_info" cat_file "/proc/scsi/scsi" cat_file "/proc/devices" start_submain "IDE-Devices" if [ -d /proc/ide ] then for i in `ls /proc/ide | grep hd` do cat_file "/proc/ide/$i/model" done fi end_submain #dmidecode crashes cell systems Find a way to distinguish cell systems if [ ! "$PLATFORM"="ia64" -o -n "$SYSTYPE" ] ; then parse_command "/usr/sbin/dmidecode" " " "Dmidecode" fi parse_command "/sbin/hpbmc" " " "hpbmc" parse_command "/usr/bin/lshal" "2>&1 /dev/null" "lshal" end_main #Reporting Log Files start_main Log-Files cat_file "/var/log/messages" cat_file "/var/log/messages.0" cat_file "/var/log/messages.1" cat_file "/var/log/dmesg" parse_command "/bin/dmesg" " " "Dmesg" cat_file "/etc/syslog.conf" cat_file "/var/log/syslog" cat_file "/var/log/syslog.0" cat_file "/var/log/debug" cat_file "/var/log/debug.0" cat_file "/var/log/boot.log" cat_file "/var/log/boot.log.1" cat_file "/var/log/boot.msg" cat_file "/var/log/booto.msg" cat_file "/var/log/kern.log" cat_file "/var/log/kern.log.0" cat_file "/var/log/user.log" cat_file "/var/log/user.log.0" cat_file "/var/log/daemon.log" cat_file "/var/log/secure" end_main #Reporting Processes & software Installed start_main Software parse_command "/bin/ps" "-efl" "Running-Processes" parse_command "/bin/ps" "-eo pid,pcpu,nwchan,wchan=WIDE-WCHAN-COLUMN -o args" "Yet-Another-ps" #Red Hat parse_command "/usr/sbin/lsof" " " "Lsof" #Suse parse_command "/usr/bin/lsof" " " "Lsof" parse_command "/bin/rpm" "-qa --queryformat '%{installtime} %{installtime:date} %{name}-%{version}-%{release}-%{arch} \n'| sort -k9" "Installed Software" cat_file "/etc/apt/sources.list" parse_command "/usr/bin/dpkg" "-l" "Installed-Software" parse_command "/usr/bin/apt-show-versions" "apt-show-versions" end_main #Reporting FileSystems info start_main File-Systems cat_file "/proc/partitions" parse_command "fdisk" "-l" "fdisk -l" cat_file "/etc/fstab" parse_command "/bin/mount" " " "/bin/mount" parse_command "/sbin/swapon" "-s" "Swap-Information" parse_command "/bin/df" "-hTal" "Disk-Free" cat_file "/etc/exports" cat_file "/proc/lvm/global/" parse_command "/usr/sbin/pvdisplay" "-v 2>&1" "pvdisplay" parse_command "/sbin/pvdisplay" "-v 2>&1" "pvdisplay" parse_command "/usr/sbin/vgdisplay" "-v 2>&1" "vgdisplay" parse_command "/sbin/vgdisplay" "-v 2>&1" "vgdisplay" parse_command "/usr/sbin/lvdisplay" "-v 2>&1" "lvdisplay" parse_command "/sbin/lvdisplay" "-v 2>&1" "lvdisplay" cat_file "/proc/mdstat" cat_file "/etc/raidtab" end_main #Reporting Network Info start_main Network cat_file "/etc/host.conf" cat_file "/etc/hosts" cat_file "/etc/hosts.allow" cat_file "/etc/hosts.deny" cat_file "/etc/hosts.equiv" start_submain Interfaces #Red Hat if [ -d /etc/sysconfig/networking/devices ] then for z in `ls /etc/sysconfig/networking/devices` do cat_file "/etc/sysconfig/networking/devices/$z" done fi #Suse if [ -d /etc/sysconfig/network ] then for y in `ls /etc/sysconfig/network/ifcfg-eth*` do cat_file "$y" done fi #HPTE cat_file "/etc/network/interfaces" end_submain parse_command "/sbin/ifconfig" "-a" "Ifconfig" start_submain "NIC-Settings" for NIC in `ifconfig |grep eth|awk '{print $1}'` do parse_command "/usr/sbin/ethtool" "$NIC" "$NIC" done end_submain cat_file "/etc/nsswitch.conf" cat_file "/etc/resolv.conf" parse_command "/sbin/route" " " "Route-Table" parse_command "/bin/netstat" "-a" "Netstat" parse_command "/sbin/iptables" " -t filter -nvL" "IPtable" end_main #Reporting Services start_main Services parse_command "/usr/sbin/sestatus" " " "SeLinux status" parse_command "/sbin/chkconfig" " --list" "chkconfig" start_submain "Inetd-Services-Enabled" cat_file "/etc/xinetd.conf" #Eval this maybe ckconfig is enough if [ -d /etc/xinetd.d ] then for i in `ls /etc/xinetd.d/*` do if [ `eval grep disable $i|grep no|awk '{print $3}'` ] then cat_file "$i" "`basename $i`" if [ "$i" = "/etc/xinetd.d/wu-ftpd" ] then start_submain "Ftp-configuration-files" for x in `ls /etc/ftp*` do cat_file "$x" done end_submain else cat_file "/etc/pam.d/`basename $i`" fi fi done fi #End of Eval cat_file "/etc/inetd.conf" end_submain start_submain "Cron Information" for x in `/bin/ls -d /etc/cron*` do for f in `find $x -type f` do cat_file "$f" done done end_submain end_main #Reporting System Stats start_main "Stats" parse_command "/usr/bin/uptime" " " "Uptime" parse_command "/usr/bin/iostat" " " "Iostat" parse_command "/usr/bin/vmstat" " " "Vmstat" parse_command "/usr/bin/w" " " "w" parse_command "/usr/bin/last" "-ax" "/usr/bin/last -ax" parse_command "/usr/bin/free" " " "Mem/Swap free" cat_file "/proc/stat" cat_file "/proc/slabinfo" TERM=dumb parse_command "/usr/bin/top" "n1" "top" if [ -e /var/log/sa ] then start_submain "sar" for i in `ls /var/log/sa/*|grep -v sar|grep -v \.bz2` do parse_command "/usr/bin/sar" "-A -f $i" "$i" done end_submain fi end_main #Reporting Misc info & conf files start_main "Misc-Files" cat_file "/etc/inittab" cat_file "/etc/security/limits.conf" cat_file "/etc/pam.d/system-auth" cat_file "/etc/smb.conf" cat_file "/etc/pam_smb.conf" cat_file "/etc/yp.conf" cat_file "/etc/ypserv.conf" cat_file "/etc/ld.so.conf" if [ -e /etc/quagga ] then start_submain "quagga-configuration" for i in `ls /etc/quagga/*conf` do cat_file $i done end_submain fi if [ -d /var/log/quagga ] then start_submain "quagga-logs" for i in `find /var/log/quagga -name \*.log` do cat_file $i done end_submain fi end_main #Reporting Graphics Info start_main "Graphics" if [ -e /etc/X11/xorg.conf ] then for file in `ls /etc/X11/xorg*` do cat_file "$file" done fi if [ -e /var/log/Xorg.0.log ] then for file in `ls /var/log/Xorg*` do cat_file "$file" done fi if [ -e /etc/X11/XF86Config ] then for file in `ls /etc/X11/XF86Config*` do cat_file "$file" done fi if [ -e /var/log/XFree86.0.log ] then for file in `ls /var/log/XFree86*` do cat_file "$file" done fi if [ -e /var/log/gdm.log ] then for file in `ls /var/log/gdm*` do cat_file "$file" done fi if [ -e /var/log/kdm.log ] then for file in `ls /var/log/kdm*` do cat_file "$file" done fi cat_file "/etc/X11/predm" cat_file "/etc/X11/fs/config" cat_file "/etc/X11/xdm/xdm-config" if [ -d /etc/X11/xdm ] then for file in `ls /etc/X11/xdm/X*` do cat_file "$file" done fi if [ -d /etc/X11/gdm ] then for file in `ls /etc/X11/gdm/*gdm.conf` do cat_file "$file" done fi cat_file "/etc/X11/gdm/gnomerc" if [ -d /etc/X11/gdm/Sessions ] then for file in `ls /etc/X11/gdm/Sessions/*` do cat_file "$file" done fi if [ -e /etc/X11/gdm/Presession ] then for file in `ls /etc/X11/gdm/Presession/*` do cat_file "$file" done fi if [ -d /etc/X11/gdm/PostSession ] then for i in `ls /etc/X11/gdm/PostSession/*` do cat_file "$file" done fi if [ -d /etc/X11/gdm/PostLogin ] then for file in `ls /etc/X11/gdm/PostLogin/*` do cat_file "$file" done fi cat_file "/usr/X11R6/lib/X11/Options" if [ -d /etc/kde ] then parse_command "/bin/ls" "-ltciqFR /etc/kde/" "/etc/kde" fi if [ -d /etc/X11 ] then parse_command "/bin/ls" "-ltciqFR /etc/X11/" "/etc/X11" fi if [ -d /usr/X11R6/lib/X11/ ] then parse_command "/bin/ls" "-ltciqFR /usr/X11R6/lib/X11/" "/usr/X11R6/lib/X11/" fi if [ $DISPLAY ] then parse_command "/usr/X11R6/bin/xdpyinfo" "-queryExtensions -display $DISPLAY" "xdpyinfo -queryExtensions" parse_command "/usr/X11R6/bin/xrdb" "-q -display $DISPLAY" "xrdb -q" parse_command "/usr/X11R6/bin/xset" "-q -display $DISPLAY" "xset -q" parse_command "/usr/X11R6/bin/xmodmap" "-pm -display $DISPLAY" "xmodmap -pm" parse_command "/usr/X11R6/bin/xmodmap" "-pke -display $DISPLAY" "xmodmap -pke" parse_command "/usr/X11R6/bin/glxinfo" "-v -l -display $DISPLAY" "glxinfo -v -l" parse_command "/usr/X11R6/bin/xlsclients" "-al -display $DISPLAY" "xlsclients -al" fi if [ -x /usr/X11R6/bin/xfsinfo ] then XFS=`ps -ef|grep xfs|grep -v grep|awk '{print $8}'` parse_command "/usr/X11R6/bin/xfsinfo" "-server :7100" "xfsinfo -server :7100" fi end_main if [ -e /opt/OC/bin/collectInfo ] then "/opt/OC/bin/collectInfo" fi #delete the text file rm $text_file tar zcvf $Working_Dir.tar.gz $Working_Dir > /dev/null rm -rf $Working_Dir echo The file $Working_Dir.tar.gz contains the report produced by snapshot exit