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 $parentir/debconfsel.txt
57 getconf debconfgetselections `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`$VSERVER $vserver exec which $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 ?
129 if [ ! -x "$VROOTDIR/$vserver`$VSERVER $vserver exec which $debconfgetselections`" ]; then
130 warning "can't find $debconfgetselections in vserver $vserver, skipping package selection states."
132 debug "$VSERVER $vserver exec $debconfgetselections > $VROOTDIR/$vserver$selectionsfile"
133 $VSERVER $vserver exec $debconfgetselections > $VROOTDIR/$vserver$selectionsfile || fatal "can not save $debconfgetselections info to $selectionsfile"
138 # We want to perform this on the host as well
139 if [ -z "$packagemgr" -o ! -x "$packagemgr" ]; then
140 warning "can't find ${packagemgr}, skipping installed packages report."
142 # don't expand * since it can be used in $packagemgroptions
144 debug "$packagemgr $packagemgroptions > $packagesfile"
145 $packagemgr $packagemgroptions > $packagesfile || fatal "can not save $packagemgr info to $packagesfile"
148 if [ -z "$debconfgetselections" ]; then
149 warning "can't find ${debconfgetselections}, skilling package selection states."
151 debug "$debconfgetselections > $selectionsfile"
152 $debconfgetselections > $selectionsfile || fatal "can not save $debconfgetselections info to $selectionsfile"
156 ## System report ##############################
159 # here we grab a bunch of system stuff for a report
164 HASHES="#################################################################"
165 DASHES="-----------------------------------------------------------------"
167 cat /dev/null > $sysreportfile || fatal "can not write to $sysreportfile"
171 echo $HASHES >> $sysreportfile
172 echo "# $STATUS" >> $sysreportfile
173 echo $HASHES >> $sysreportfile
175 echo "file: $1" >> $sysreportfile
176 echo $DASHES >> $sysreportfile
177 cat $1 >> $sysreportfile 2>&1 || info "reading of $1 failed"
180 echo "directory: $1" >> $sysreportfile
181 echo $DASHES >> $sysreportfile
182 for file in `find $1 -maxdepth 3 -noleaf -type f`
187 echo $DASHES >> $sysreportfile
191 echo $HASHES >> $sysreportfile
192 echo "# $STATUS" >> $sysreportfile
193 echo $HASHES >> $sysreportfile
194 $1 >> $sysreportfile 2>&1 || info "executing of $1 failed"
198 STATUS="Determining $os version:"
201 STATUS="Determinding your current hostname: "
202 catifexec "/bin/hostname"
204 STATUS="Getting the date:"
205 catifexec "/bin/date"
207 STATUS="Checking your systems current uptime and load average:"
208 catifexec "/usr/bin/uptime"
210 STATUS="Checking available memory:"
211 catifexec "/usr/bin/free"
213 STATUS="Checking free disk space:"
214 catifexec "/bin/df" "-al"
216 STATUS="Collecting what services run at what run level:"
217 if [ $os = "redhat" ]; then
218 catifexec "/sbin/chkconfig --list"
219 STATUS="Collecting information about /etc/rc.d:"
220 catiffile "/bin/ls /etc/rc.d/rc*.d/"
222 elif [ $os = "debian" ]; then
223 for level in 0 1 2 3 4 5 6 S; do
224 echo "Level: $level" >> $sysreportfile
225 for f in /etc/rc${level}.d/*; do
226 # Remove /etc/Knn or Snn from beginning
227 ff=$(echo $f | @SED@ 's_/etc/rc..d/[KS][0-9][0-9]__')
228 if [ $f != $ff ]; then
229 echo $ff >> $sysreportfile
232 echo "" >> $sysreportfile
236 STATUS="Getting bootloader information:"
237 catifexec "/bin/ls -alR /boot"
239 # This covers sparc, alpha, and intel (respectively)
240 # updated for grub -mpg
241 if [ -f /etc/silo.conf ]; then
242 STATUS="Collecting information about the boot process (silo):"
243 catiffile "/etc/silo.conf"
245 if [ -f /etc/milo.conf ]; then
246 STATUS="Collecting information about the boot process (milo):"
247 catiffile "/etc/milo.conf"
249 if [ -f /etc/lilo.conf ]; then
250 STATUS="Collecting information about the boot process (lilo):"
251 catiffile "/etc/lilo.conf"
252 catifexec "/sbin/lilo -q"
254 if [ -d /boot/grub -a -f /boot/grub/grub.conf -a -f /boot/grub/device.map ]; then
255 STATUS="Collecting information about the boot process (grub.conf):"
256 catiffile "/boot/grub/grub.conf"
257 STATUS="Collecting information about the boot process (grub.map):"
258 catiffile "/boot/grub/device.map"
260 if [ -f /etc/cluster.conf -o -f /etc/cluster.xml ] ; then
261 STATUS="Gathering information on cluster setup"
263 if [ -f /etc/cluster.conf ] ; then
264 catiffile "/etc/cluster.conf"
267 if [ -f /etc/cluster.xml ] ; then
268 catiffile "/etc/cluster.xml"
272 STATUS="Gathering sysctl information (sysctl -a):"
273 catiffile "sysctl -a 2>/dev/null"
274 STATUS="Gathering sysctl information (/etc/sysctl.conf):"
275 catiffile "/etc/sysctl.conf"
277 STATUS="Gathering IP information (/sbin/ifconfig):"
278 catifexec "/sbin/ifconfig -a"
280 STATUS="Gathering additional IP information (/bin/ip addr list):"
281 catifexec "/bin/ip addr list"
283 STATUS="Checking network routes:"
284 catifexec "/sbin/route -n"
286 STATUS="Collecting Name Service Switch config information:"
287 catiffile "/etc/nsswitch.conf"
289 STATUS="Collecting information about system authentication (pam):"
290 catiffile "/etc/pam.conf"
291 catiffile "/etc/pam.d"
294 echo "Getting information about the kernel."
296 STATUS="Getting kernel version:"
297 catifexec "/bin/uname" "-a"
298 STATUS="Checking module information:"
299 catifexec "/sbin/lsmod"
300 for x in $(/sbin/lsmod | /bin/cut -f1 -d" " 2>/dev/null | /bin/grep -v Module 2>/dev/null
302 STATUS="Checking module information $x:"
303 catifexec "/sbin/modinfo $x"
306 STATUS="Gathering information about your filesystems:"
307 catiffile "/proc/filesystems"
309 STATUS="Gathering information about your system stat:"
310 catiffile "/proc/stat"
312 STATUS="Gathering information about your partitions:"
313 catiffile "/proc/partitions"
315 STATUS="Gathering information about your ksyms:"
316 catiffile "/proc/kallsyms"
318 STATUS="Gathering information about slabinfo:"
319 catiffile "/proc/slabinfo"
321 # Added support to cover for the new modules.conf layout in Red Hat 7
322 STATUS="Collecting information regarding kernel modules"
324 catiffile "/lib/modules/$VER/modules.dep"
325 if [ -f /etc/conf.modules ]; then
326 STATUS="Collecting information regarding kernel modules (conf.modules)"
327 catiffile "/etc/conf.modules"
329 if [ -f /etc/modules.conf ]; then
330 STATUS="Collecting information regarding kernel modules (modules.conf)"
331 catiffile "/etc/modules.conf"
333 if [ -f /etc/modprobe.conf ]; then
334 STATUS="Collecting information regarding kernel modules (modeprobe.conf)"
335 catiffile "/etc/modprobe.conf"
339 if [ -x /usr/sbin/dkms ] ; then
340 STATUS="Gathering current status of modules, versions and kernels (dkms):"
341 catifexec "/usr/sbin/dkms" "status"
344 if [ -f /etc/sysconfig/isdncard ] ; then
345 STATUS="Gathering information about ISDN:"
346 catiffile "/etc/sysconfig/isdncard"
349 STATUS="Collecting information from the proc directory:"
350 catiffile "/proc/pci"
352 STATUS="Getting kernel command line"
353 catiffile "/proc/cmdline"
355 STATUS="Gathering information about your CPU:"
356 catiffile "/proc/cpuinfo"
358 STATUS="Gathering information about your Ram:"
359 catiffile "/proc/meminfo"
361 STATUS="Gathering information about your ioports:"
362 catiffile "/proc/ioports"
364 STATUS="Gathering information about your interrupts:"
365 catiffile "/proc/interrupts"
367 STATUS="Gathering information about your scsi devices:"
368 catiffile "/proc/scsi"
370 STATUS="Gathering information about your dma:"
371 catiffile "/proc/dma"
373 STATUS="Gathering information about your devices (/proc/devices):"
374 catiffile "/proc/devices"
376 STATUS="Gathering information about your rtc:"
377 catiffile "/proc/rtc"
379 STATUS="Gathering information about your ide drivers:"
380 catiffile "/proc/ide"
382 STATUS="Gathering information about your bus:"
384 catiffile "/proc/bus"
387 echo "Getting disk and filesystem information."
390 STATUS="Collecting information from /etc/fstab:"
391 catiffile "/etc/fstab"
393 STATUS="Collecting disk partition information:"
396 STATUS="Checking mounted file systems (mount) "
397 catifexec "/bin/mount"
399 STATUS="Checking mounted file systems (/proc/mounts)"
400 catiffile "/proc/mounts"
402 STATUS="Collecting Software RAID information (/proc/mdstat)"
403 catiffile "/proc/mdstat"
405 STATUS="Collecting Software RAID information (/etc/raidtab)"
406 catiffile "/etc/raidtab"
408 STATUS="Collecting Software RAID information (/etc/mdadm.conf)"
409 catiffile "/etc/mdadm.conf"
411 STATUS="Collecting Automount information (auto.master)"
412 catiffile "/etc/auto.master"
414 STATUS="Collecting Automount information (auto.misc)"
415 catiffile "/etc/auto.misc"
417 STATUS="Collecting Automount information (auto.net)"
418 catiffile "/etc/auto.net"
420 STATUS="Collecting LVM information:"
421 if [ $os = "redhat" ]; then
422 catifexec "/usr/sbin/vgdisplay" "-vv"
423 elif [ $os = "debian" ]; then
424 catifexec "/sbin/vgdisplay" "-vv"
427 STATUS="Collecting SCSI Tape information (/etc/stinit.def)"
428 catiffile "/etc/stinit.def"
430 if [ -x /sbin/lsusb ] ; then
431 STATUS="Collecting USB devices list (lsusb):"
432 catifexec "/sbin/lsusb"
435 if [ -x /usr/bin/lshal ] ; then
436 STATUS="Collecting global devices list (lshal):"
437 catifexec "/usr/bin/lshal"
441 STATUS="Gathering information on SELinux setup"
442 catifexec "/usr/bin/selinuxconfig"
443 catifexec "/usr/sbin/sestatus"
444 if [ $os = "redhat" ]; then
445 catifexec "rpm" "-q -V selinux-policy-targeted"
446 catifexec "rpm" "-q -V selinux-policy-strict"
449 if [ $usevserver = yes ]; then
450 STATUS="Gathering vserver information"
451 catiffile "/proc/virtual"
454 if [ "$partitions" == "yes" ]; then
455 if [ "$dosfdisk" == "yes" ]; then
456 if [ ! -x "$SFDISK" ]; then
457 warning "can't find sfdisk, skipping sfdisk report."
461 if [ "$dohwinfo" == "yes" ]; then
462 if [ ! -x "$HWINFO" ]; then
463 warning "can't find hwinfo, skipping partition report."
469 if [ "$hardware" == "yes" ]; then
470 if [ ! -x "$HWINFO" ]; then
471 warning "can't find hwinfo, skipping hardware report."
476 ## HARDWARE #############################
479 # here we use hwinfo to dump a table listing all the
480 # information we can find on the hardware of this machine
483 if [ "$hardware" == "yes" ]; then
484 if [ "dohwinfo" == "yes" ]; then
485 if [ -f $hardwarefile ]; then
489 echo -e "\n\n====================== summary ======================\n" >> $hardwarefile
490 debug "$HWINFO --short --cpu --network --disk --pci >> $hardwarefile"
491 $HWINFO --short --cpu --network --disk --pci >> $hardwarefile
492 for flag in cpu network bios pci; do
493 echo -e "\n\n====================== $flag ======================\n" >> $hardwarefile
494 $HWINFO --$flag >> $hardwarefile
500 ## PARTITIONS #############################
502 # here we use sfdisk to dump a listing of all the partitions.
503 # these files can be used to directly partition a disk of the same size.
505 if [ "$partitions" == "yes" ]; then
506 if [ "$dosfdisk" == "yes" ]; then
507 devices=`LC_ALL=C $SFDISK -l 2>/dev/null | grep "^Disk /dev" | @AWK@ '{print $2}' | cut -d: -f1`
508 if [ "$devices" == "" ]; then
509 warning "No harddisks found"
511 for dev in $devices; do
512 debug "$SFDISK will try to backup partition tables for device $dev"
513 [ -b $dev ] || continue
516 outputfile=${partitionsfile//__star__/$label}
517 debug "$SFDISK $sfdisk_options -d $dev > $outputfile 2>/dev/null"
518 $SFDISK $sfdisk_options -d $dev > $outputfile 2>/dev/null
519 if [ $? -ne 0 ]; then
520 warning "The partition table for $dev could not be saved."
524 if [ "$dohwinfo" == "yes" ]; then
525 debug "Using $HWINFO to get all available disk information"
526 echo -e "\n\n====================== $disk ======================\n" >> $hardwarefile
527 $HWINFO --disk >> $hardwarefile