1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
3 # this handler will save various reports of vital system information.
4 # by default, all the reports are enabled and are saved in /var/backups.
6 # (1) a capture of the debconf package selection states. This file
7 # can be used to restore the answers to debconf questions for
8 # packages that you will be installing through (2) below. To
9 # do this, run: "debconf-set-selections < debconfsel.txt"
11 # (2) a list of all the packages installed and removed.
12 # this file can be used to restore the state of installed packages
13 # by running "dpkg --set-selections < dpkg-selections.txt and
14 # then run "apt-get -u dselect-upgrade". If you have the
15 # debconf-set-selections file from (1), you should restore those first.
17 # (3) the partition table of all disks.
18 # this partition table can be used to format another disk of
19 # the same size. this can be handy if using software raid and
20 # you have a disk go bad. just replace the disk and partition it
21 # by running "sfdisk /dev/sdb < partitions.sdb.txt"
22 # (MAKE SURE YOU PARTITION THE CORRECT DISK!!!)
24 # (4) hardware information.
25 # write to a text file the important things which hwinfo can gleen.
28 if [ -f /etc/debian_version ]
31 debug "Debian detected"
32 osversion="/etc/debian_version"
33 elif [ -f /etc/redhat-release ]
36 debug "Redhat detected"
37 osversion="/etc/redhat-release"
39 warning "Unknown OS detected!"
42 getconf parentdir /var/backups
47 if [ ! -d $parentdir ]; then
53 getconf packagesfile $parentdir/dpkg-selections.txt
54 getconf packagemgr `which dpkg`
55 getconf packagemgroptions ' --get-selections *'
56 getconf selectionsfile $parentdir/debconfsel.txt
57 getconf debconfgetselections `which debconf-get-selections`
58 elif [ $os = "redhat" ]
60 getconf packagesfile $parentdir/rpmpackages.txt
61 getconf packagemgr `which rpm`
62 getconf packagemgroptions ' -qa '
64 getconf SYSREPORT `which sysreport`
65 getconf sysreport_options ' -norpm '
67 getconf packagesfile $parentdir/unknownOS.txt
69 packagemgroptions="${packagemgroptions//__star__/*}"
71 getconf partitions yes
72 getconf partitionsfile $parentdir/partitions.__star__.txt
75 getconf hardwarefile $parentdir/hardware.txt
78 getconf sysreportfile $parentdir/sysreport.txt
80 getconf SFDISK `which sfdisk`
81 getconf HWINFO `which hwinfo`
82 getconf sfdisk_options ""
83 getconf hwinfo_options ""
87 # If vservers are configured, check that the ones listed in $vsnames are running.
89 if [ $vservers_are_available = yes ]; then
90 if [ "$vsnames" = all ]; then
91 vsnames="$found_vservers"
93 if ! vservers_running "$vsnames" ; then
94 fatal "At least one of the vservers listed in vsnames ($vsnames) is not running."
96 info "Using vservers '$vsnames'"
100 ## PACKAGES ##############################
103 # here we grab a list of the packages installed and removed.
106 if [ "$packages" == "yes" ]; then
108 if [ $usevserver = yes ]; then
109 info "vserver root directory set to: $VROOTDIR"
110 for vserver in $vsnames; do
111 info "examining vserver: $vserver"
113 vservers_running $vserver
114 if [ $? -ne 0 ]; then
115 warning "The vserver $vserver is not running."
118 # is $packagemgr available inside $vserver ?
119 if [ ! -x "${VROOTDIR}/${vserver}${packagemgr}" ]; then
120 warning "can't find $packagemgr in vserver $vserver, skipping installed packages report."
122 # don't expand * since it can be used in $packagemgroptions
124 debug "$VSERVER $vserver exec $packagemgr $packagemgroptions > $VROOTDIR/$vserver$packagesfile"
125 $VSERVER $vserver exec $packagemgr $packagemgroptions > $VROOTDIR/$vserver$packagesfile || fatal "can not save $packagemgr info to $packagesfile"
128 # is $debconfgetselections available inside $vserver ?
130 # case #1: it is available on the host, is it available inside $vserver ?
131 if [ -n "$debconfgetselections" ]; then
132 [ -x "${VROOTDIR}/${vserver}${debconfgetselections}" ] && found=yes
133 # case #2: it is not available on the host, is it available inside $vserver ?
135 [ -n "`$VSERVER $vserver exec which debconf-get-selections`" ] && found=yes
137 if [ "$found" != yes ]; then
138 warning "can't find debconf-get-selections in vserver $vserver, skipping package selection states. You may want to install the debconf-utils package."
140 debug "$VSERVER $vserver exec $debconfgetselections > $VROOTDIR/$vserver$selectionsfile"
141 $VSERVER $vserver exec $debconfgetselections > $VROOTDIR/$vserver$selectionsfile || fatal "can not save debconf-get-selections info to $selectionsfile"
147 # We want to perform this on the host as well
148 if [ -z "$packagemgr" -o ! -x "$packagemgr" ]; then
149 warning "can't find ${packagemgr}, skipping installed packages report."
151 # don't expand * since it can be used in $packagemgroptions
153 debug "$packagemgr $packagemgroptions > $packagesfile"
154 $packagemgr $packagemgroptions > $packagesfile || fatal "can not save $packagemgr info to $packagesfile"
157 if [ -z "$debconfgetselections" ]; then
158 warning "can't find debconf-get-selections, skipping package selection states. You might want to install the debconf-utils package."
160 debug "$debconfgetselections > $selectionsfile"
161 $debconfgetselections > $selectionsfile || fatal "can not save $debconfgetselections info to $selectionsfile"
165 ## System report ##############################
168 # here we grab a bunch of system stuff for a report
173 HASHES="#################################################################"
174 DASHES="-----------------------------------------------------------------"
176 cat /dev/null > $sysreportfile || fatal "can not write to $sysreportfile"
180 echo $HASHES >> $sysreportfile
181 echo "# $STATUS" >> $sysreportfile
182 echo $HASHES >> $sysreportfile
184 echo "file: $1" >> $sysreportfile
185 echo $DASHES >> $sysreportfile
186 cat $1 >> $sysreportfile 2>&1 || info "reading of $1 failed"
189 echo "directory: $1" >> $sysreportfile
190 echo $DASHES >> $sysreportfile
191 for file in `find $1 -maxdepth 3 -noleaf -type f`
196 echo $DASHES >> $sysreportfile
201 echo $HASHES >> $sysreportfile
202 echo "# $STATUS" >> $sysreportfile
203 echo $HASHES >> $sysreportfile
204 $* >> $sysreportfile 2>&1 || info "executing of $1 failed"
209 STATUS="Determining $os version:"
212 STATUS="Determinding your current hostname: "
213 catifexec "/bin/hostname"
215 STATUS="Getting the date:"
216 catifexec "/bin/date"
218 STATUS="Checking your systems current uptime and load average:"
219 catifexec "/usr/bin/uptime"
221 STATUS="Checking available memory:"
222 catifexec "/usr/bin/free"
224 STATUS="Checking free disk space:"
225 catifexec "/bin/df" "-al"
227 STATUS="Collecting what services run at what run level:"
228 if [ $os = "redhat" ]; then
229 catifexec "/sbin/chkconfig" "--list"
230 STATUS="Collecting information about /etc/rc.d:"
231 catiffile "/bin/ls /etc/rc.d/rc*.d/"
233 elif [ $os = "debian" ]; then
234 for level in 0 1 2 3 4 5 6 S; do
235 echo "Level: $level" >> $sysreportfile
236 for f in /etc/rc${level}.d/*; do
237 # Remove /etc/Knn or Snn from beginning
238 ff=$(echo $f | @SED@ 's_/etc/rc..d/[KS][0-9][0-9]__')
239 if [ $f != $ff ]; then
240 echo $ff >> $sysreportfile
243 echo "" >> $sysreportfile
247 STATUS="Getting bootloader information:"
248 catifexec "/bin/ls" "-alR /boot"
250 # This covers sparc, alpha, and intel (respectively)
251 # updated for grub -mpg
252 if [ -f /etc/silo.conf ]; then
253 STATUS="Collecting information about the boot process (silo):"
254 catiffile "/etc/silo.conf"
256 if [ -f /etc/milo.conf ]; then
257 STATUS="Collecting information about the boot process (milo):"
258 catiffile "/etc/milo.conf"
260 if [ -f /etc/lilo.conf ]; then
261 STATUS="Collecting information about the boot process (lilo):"
262 catiffile "/etc/lilo.conf"
263 catifexec "/sbin/lilo" "-q"
265 if [ -d /boot/grub -a -f /boot/grub/grub.conf -a -f /boot/grub/device.map ]; then
266 STATUS="Collecting information about the boot process (grub.conf):"
267 catiffile "/boot/grub/grub.conf"
268 STATUS="Collecting information about the boot process (grub.map):"
269 catiffile "/boot/grub/device.map"
271 if [ -f /etc/cluster.conf -o -f /etc/cluster.xml ] ; then
272 STATUS="Gathering information on cluster setup"
274 if [ -f /etc/cluster.conf ] ; then
275 catiffile "/etc/cluster.conf"
278 if [ -f /etc/cluster.xml ] ; then
279 catiffile "/etc/cluster.xml"
283 STATUS="Gathering sysctl information (sysctl -a):"
284 catiffile "sysctl -a 2>/dev/null"
285 STATUS="Gathering sysctl information (/etc/sysctl.conf):"
286 catiffile "/etc/sysctl.conf"
288 STATUS="Gathering IP information (/sbin/ifconfig):"
289 catifexec "/sbin/ifconfig" "-a"
291 STATUS="Gathering additional IP information (/bin/ip addr list):"
292 catifexec "/bin/ip" "addr list"
294 STATUS="Checking network routes:"
295 catifexec "/sbin/route" "-n"
297 STATUS="Collecting Name Service Switch config information:"
298 catiffile "/etc/nsswitch.conf"
300 STATUS="Collecting information about system authentication (pam):"
301 catiffile "/etc/pam.conf"
302 catiffile "/etc/pam.d"
305 echo "Getting information about the kernel."
307 STATUS="Getting kernel version:"
308 catifexec "/bin/uname" "-a"
309 STATUS="Checking module information:"
310 catifexec "/sbin/lsmod"
311 for x in $(/sbin/lsmod | /bin/cut -f1 -d" " 2>/dev/null | /bin/grep -v Module 2>/dev/null
313 STATUS="Checking module information $x:"
314 catifexec "/sbin/modinfo" "$x"
317 STATUS="Gathering information about your filesystems:"
318 catiffile "/proc/filesystems"
320 STATUS="Gathering information about your system stat:"
321 catiffile "/proc/stat"
323 STATUS="Gathering information about your partitions:"
324 catiffile "/proc/partitions"
326 STATUS="Gathering information about your ksyms:"
327 catiffile "/proc/kallsyms"
329 STATUS="Gathering information about slabinfo:"
330 catiffile "/proc/slabinfo"
332 # Added support to cover for the new modules.conf layout in Red Hat 7
333 STATUS="Collecting information regarding kernel modules"
335 catiffile "/lib/modules/$VER/modules.dep"
336 if [ -f /etc/conf.modules ]; then
337 STATUS="Collecting information regarding kernel modules (conf.modules)"
338 catiffile "/etc/conf.modules"
340 if [ -f /etc/modules.conf ]; then
341 STATUS="Collecting information regarding kernel modules (modules.conf)"
342 catiffile "/etc/modules.conf"
344 if [ -f /etc/modprobe.conf ]; then
345 STATUS="Collecting information regarding kernel modules (modeprobe.conf)"
346 catiffile "/etc/modprobe.conf"
350 if [ -x /usr/sbin/dkms ] ; then
351 STATUS="Gathering current status of modules, versions and kernels (dkms):"
352 catifexec "/usr/sbin/dkms" "status"
355 if [ -f /etc/sysconfig/isdncard ] ; then
356 STATUS="Gathering information about ISDN:"
357 catiffile "/etc/sysconfig/isdncard"
360 STATUS="Collecting information from the proc directory:"
361 catiffile "/proc/pci"
363 STATUS="Getting kernel command line"
364 catiffile "/proc/cmdline"
366 STATUS="Gathering information about your CPU:"
367 catiffile "/proc/cpuinfo"
369 STATUS="Gathering information about your Ram:"
370 catiffile "/proc/meminfo"
372 STATUS="Gathering information about your ioports:"
373 catiffile "/proc/ioports"
375 STATUS="Gathering information about your interrupts:"
376 catiffile "/proc/interrupts"
378 STATUS="Gathering information about your scsi devices:"
379 catiffile "/proc/scsi"
381 STATUS="Gathering information about your dma:"
382 catiffile "/proc/dma"
384 STATUS="Gathering information about your devices (/proc/devices):"
385 catiffile "/proc/devices"
387 STATUS="Gathering information about your rtc:"
388 catiffile "/proc/rtc"
390 STATUS="Gathering information about your ide drivers:"
391 catiffile "/proc/ide"
393 STATUS="Gathering information about your bus:"
394 catifexec "/usr/bin/lspci"
395 catiffile "/proc/bus"
398 echo "Getting disk and filesystem information."
401 STATUS="Collecting information from /etc/fstab:"
402 catiffile "/etc/fstab"
404 STATUS="Collecting disk partition information:"
405 catifexec "/sbin/fdisk" "-l"
407 STATUS="Checking mounted file systems (mount) "
408 catifexec "/bin/mount"
410 STATUS="Checking mounted file systems (/proc/mounts)"
411 catiffile "/proc/mounts"
413 STATUS="Collecting Software RAID information (/proc/mdstat)"
414 catiffile "/proc/mdstat"
416 STATUS="Collecting Software RAID information (/etc/raidtab)"
417 catiffile "/etc/raidtab"
419 STATUS="Collecting Software RAID information (/etc/mdadm.conf)"
420 catiffile "/etc/mdadm.conf"
422 STATUS="Collecting Software RAID information (/sbin/mdadm -Q)"
423 catifexec "/sbin/mdadm" "-Q" "--detail" '/dev/md?*'
425 STATUS="Collecting Automount information (auto.master)"
426 catiffile "/etc/auto.master"
428 STATUS="Collecting Automount information (auto.misc)"
429 catiffile "/etc/auto.misc"
431 STATUS="Collecting Automount information (auto.net)"
432 catiffile "/etc/auto.net"
434 STATUS="Collecting LVM information:"
435 if [ $os = "redhat" ]; then
436 catifexec "/usr/sbin/vgdisplay" "-vv"
437 elif [ $os = "debian" ]; then
438 catifexec "/sbin/vgdisplay" "-vv"
441 STATUS="Collecting SCSI Tape information (/etc/stinit.def)"
442 catiffile "/etc/stinit.def"
444 if [ -x /sbin/lsusb ] ; then
445 STATUS="Collecting USB devices list (lsusb):"
446 catifexec "/sbin/lsusb"
449 if [ -x /usr/bin/lshal ] ; then
450 STATUS="Collecting global devices list (lshal):"
451 catifexec "/usr/bin/lshal"
455 STATUS="Gathering information on SELinux setup"
456 catifexec "/usr/bin/selinuxconfig"
457 catifexec "/usr/sbin/sestatus"
458 if [ $os = "redhat" ]; then
459 catifexec "rpm" "-q -V selinux-policy-targeted"
460 catifexec "rpm" "-q -V selinux-policy-strict"
463 if [ $usevserver = yes ]; then
464 STATUS="Gathering vserver information"
465 catiffile "/proc/virtual"
468 if [ "$partitions" == "yes" ]; then
469 if [ "$dosfdisk" == "yes" ]; then
470 if [ ! -x "$SFDISK" ]; then
471 warning "can't find sfdisk, skipping sfdisk report."
475 if [ "$dohwinfo" == "yes" ]; then
476 if [ ! -x "$HWINFO" ]; then
477 warning "can't find hwinfo, skipping partition report."
483 if [ "$hardware" == "yes" ]; then
484 if [ ! -x "$HWINFO" ]; then
485 warning "can't find hwinfo, skipping hardware report."
490 ## HARDWARE #############################
493 # here we use hwinfo to dump a table listing all the
494 # information we can find on the hardware of this machine
497 if [ "$hardware" == "yes" ]; then
498 if [ "dohwinfo" == "yes" ]; then
499 if [ -f $hardwarefile ]; then
503 echo -e "\n\n====================== summary ======================\n" >> $hardwarefile
504 debug "$HWINFO --short --cpu --network --disk --pci >> $hardwarefile"
505 $HWINFO --short --cpu --network --disk --pci >> $hardwarefile
506 for flag in cpu network bios pci; do
507 echo -e "\n\n====================== $flag ======================\n" >> $hardwarefile
508 $HWINFO --$flag >> $hardwarefile
514 ## PARTITIONS #############################
516 # here we use sfdisk to dump a listing of all the partitions.
517 # these files can be used to directly partition a disk of the same size.
519 if [ "$partitions" == "yes" ]; then
520 if [ "$dosfdisk" == "yes" ]; then
521 devices=`LC_ALL=C $SFDISK -l 2>/dev/null | grep "^Disk /dev" | @AWK@ '{print $2}' | cut -d: -f1`
522 if [ "$devices" == "" ]; then
523 warning "No harddisks found"
525 for dev in $devices; do
526 debug "$SFDISK will try to backup partition tables for device $dev"
527 [ -b $dev ] || continue
530 outputfile=${partitionsfile//__star__/$label}
531 debug "$SFDISK $sfdisk_options -d $dev > $outputfile 2>/dev/null"
532 $SFDISK $sfdisk_options -d $dev > $outputfile 2>/dev/null
533 if [ $? -ne 0 ]; then
534 warning "The partition table for $dev could not be saved."
538 if [ "$dohwinfo" == "yes" ]; then
539 debug "Using $HWINFO to get all available disk information"
540 echo -e "\n\n====================== $disk ======================\n" >> $hardwarefile
541 $HWINFO --disk >> $hardwarefile