File: //usr/lib/Acronis/BackupAndRecovery/systeminfo
#!/bin/sh
# This is Acronis Linux Report Utility. It's absolutely harmless for your
# system and security. Please run this utility under privileged user and
# send us resulted sysinfo archive from /var/lib/Acronis/sysinfo directory.
# Copyright (C) Acronis, 2010
# Initially written by Fadeeva Marina
# (marian.fadeeva@acronis.com)
rpm_dist=/bin/rpm
non_rpm=/usr/bin/dpkg
libdir=/usr/lib/Acronis
dkms_dir=/var/lib/dkms
var_dir=/var/lib/Acronis
var_log_dir=/var/log/Acronis
aties=$libdir/Agent/agent
abr=$libdir/BackupAndRecoveryAgent
atiesecho=$libdir/Agent/acronisagent
abrams=$libdir/AMS/ManagementServer
online_backup_dir=$var_dir/BackupAndRecovery/OnlineBackup
# collect full contents from
specific_dirs="/var/lib/alsdb $var_dir/CurlCaCertificates $var_dir/BackupAndRecovery/MMS/Activity
$var_dir/BackupAndRecovery/MMS/AccessVault $var_dir/AMS/AccessVault
$var_dir/Scheduler/tasks /ConfigurationFiles"
specific_dirs_media="/ConfigurationFiles"
# collect all the Acronis databases (-shm and -wal files will be colleceted as well)
db3_ext_templates="sqlite sqlite3 db db3"
db3_dirs="$var_dir $libdir"
# collect logs from
logs_files_exts="log log.gz output trace stat"
logs_dirs="$var_log_dir $var_dir"
# collect conf files from
conf_files_exts="config meta ini sh csv xml sql"
conf_dirs="/etc/Acronis $var_dir"
procfiles="version cmdline interrupts modules bus/pci/devices bus/usb/devices partitions scsi/scsi
mounts cpuinfo meminfo mdstat devices bus/input/devices swaps fb slabinfo"
slabfiles="objects object_size objs_per_slab order slabs slab_size"
df_options="-hT"
ver=""
ver2=""
export LANG=C
# Parse options
script_name="$0"
silent_mode="0"
is_dir_mode="0"
ensure_root="1"
default_tgtdir="/var/lib/Acronis/sysinfo"
default_filename=sysinfo-$(date +%Y.%m.%d-%H.%M.%S).tar.bz2
filename=$default_filename
umask 0077
while [ "$#" -gt 0 ]; do
case "$1" in
-h|--help)
echo "Acronis Report Utility"
echo ""
echo "EXAMPLES"
echo " Save sysinfo into $default_tgtdir/$default_filename:"
echo " $script_name"
echo ""
echo " Save sysinfo into specified directory:"
echo " $script_name --target_dir path/to/report/dir"
echo ""
echo " Save compressed sysinfo into specified file:"
echo " $script_name --target_file path/to/report/archive.tar.bz2"
echo " (path can be absolute or relative to $default_tgtdir)"
echo ""
echo " Print this help and exit:"
echo " $script_name --help"
echo ""
exit 0
;;
--silent)
silent_mode="1"
shift
;;
--skip_root_check)
ensure_root="0"
shift
;;
--target_file)
is_dir_mode="0"
if [ "$#" -lt 2 ]; then
>&2 echo "ERROR: value of $1 option is not specified"
>&2 echo ""
exit 1
fi
filename=$2
shift 2
;;
--target_dir)
is_dir_mode="1"
if [ "$#" -lt 2 ]; then
>&2 echo "ERROR: value of $1 option is not specified"
>&2 echo ""
exit 1
fi
filename=$2
shift 2
;;
*)
>&2 echo "Unexpected argument $1"
>&2 echo "Run $0 --help to get usage examples"
exit 1
;;
esac
done
case $filename in
/*) result_abs_path="$filename" ;;
*) result_abs_path="$default_tgtdir/$filename" ;;
esac
# location of intermediary data
if [ "$is_dir_mode" -eq "1" ]; then
work_dir="$result_abs_path"
else
work_dir=$default_tgtdir/logs
fi
# make sure script is run by root
if [ -x /bin/asamba ]; then
# this is media version. No need to check if run by root
df_options="-h"
specific_dirs="$specific_dirs $specific_dirs_media"
else
if [ "$ensure_root" -eq "1" ]; then
is_root="0"
test -x /usr/bin/id && is_root="$(/usr/bin/id -u)"
if [ "$is_root" -ne "0" ] ; then
>&2 echo You must be root to run this script!
exit 1
fi
fi
fi
# switch into working directory and start collecting sysinfo
if [ "$silent_mode" -eq "0" ]; then
echo Please wait for a while ...
fi
mkdir -p $work_dir
cd $work_dir
if [ -x /bin/uname ]; then
ver=/lib/modules/`/bin/uname -r`/kernel/drivers/block/snapapi*
ver2=/lib/modules/`/bin/uname -r`/kernel/drivers/extra/snapapi*
fi
# Start from checking kernel version and setting
# proprer snapapi module name
if [ -x /bin/uname ]; then
/bin/uname -r | grep "2.4" > /dev/null
if [ "$?" -eq "0" ]; then
snapapi_ver=snapapi # it's 2.4 kernel
else
snapapi_ver=snapapi26 # it's 2.6 or upper kernel
fi
fi
# get the logs of last attempt to compile snapapi module.
if [ -d "$dkms_dir/$snapapi_ver" ]; then
cp -u `find $dkms_dir/$snapapi_ver -name make.log | xargs ls -t | head -1` \
snapapi_make.log 2>&1
fi
if [ -r /etc/ProductVersion.conf ]; then
cp /etc/ProductVersion.conf ProductVersion.conf 2>&1
fi
if [ -r /etc/config ]; then
cp /etc/config etc_config 2>&1
fi
if [ -r /usr/lib/Acronis/BackupAndRecovery_version.txt ]; then
cp /usr/lib/Acronis/BackupAndRecovery_version.txt ProductVersion.conf 2>&1
else
if [ -r /var/lib/Acronis/BackupAndRecovery_version.txt ]; then
cp /var/lib/Acronis/BackupAndRecovery_version.txt ProductVersion.conf 2>&1
fi
fi
# Common for all versions
if [ -x /usr/sbin/acrocmd ]; then
#Live Linux
/usr/sbin/acrocmd list disks > acrocmd.txt 2>&1
elif [ -x /bin/acrocmd ]; then
/bin/acrocmd list disks > acrocmd.txt 2>&1
elif [ -x /usr/sbin/trueimagecmd ]; then
#Live Linux
/usr/sbin/trueimagecmd --list > trueimagecmd.txt 2>&1
elif [ -x /bin/trueimagecmd ]; then
/bin/trueimagecmd --list > trueimagecmd.txt 2>&1
fi
# Gather information about dsk_supp state
# should be done before $logs_dirs are gathered because it writes additional debug logs
if [ -x /usr/lib/Acronis/BackupAndRecovery/dsk_supp_test ]; then
DSK_DSK__LOG=1 /usr/lib/Acronis/BackupAndRecovery/dsk_supp_test > dsk_supp_test.txt 2>&1
elif [ -x /bin/dsk_supp_test ]; then
DSK_DSK__LOG=1 /bin/dsk_supp_test > dsk_supp_test.txt 2>&1
fi
# save /tmp/asamba.log if exist
if [ -r /tmp/asamba.log ]; then
cp /tmp/asamba.log . 2>&1
fi
# Schedmgr report
if [ -x $libdir/Schedule/schedmgr-bin ]; then
$libdir/Schedule/schedmgr-bin get report > schedmgr_report.txt 2>&1
fi
# Now check X-Server logs:
# Do we have xorg?
if [ -r /etc/X11/xorg.conf ]; then
cp /var/log/Xorg* . 2>&1
# or is it XFree86?
elif [ -r /etc/X11/XF86Config ]; then
cp /var/log/XFree86* . 2>&1
fi
# Common for all agents
if [ -x "$aties" ] || [ -x "$atiesecho" ]; then
/sbin/iptables -L > iptables.txt 2>&1
/bin/netstat -nap | grep agent > netstat.txt 2>&1
/sbin/lsmod | grep snapapi* > /dev/null
if [ "$?" -eq 0 ]; then
/sbin/rmmod $snapapi_ver > rmmod.txt 2>&1
fi
if [ -e "$ver" ] || [ -e "$ver2" ]; then
/sbin/modprobe $snapapi_ver
fi
fi # agents common
# For ATIES Linux agent 9.1
if [ -x "$aties" ]; then
/etc/init.d/acronis_trueimage_agent status > agent.txt 2>&1
fi
# For ATIES ECHO Linux agent
if [ -x "$atiesecho" ]; then
/etc/init.d/acronis_agent status > agent.txt 2>&1
fi
# For ABR Agent
if [ -x "$abr" ]; then
/etc/init.d/acronis_agent status > agent.txt 2>&1
/etc/init.d/acronis_mms status > mms.txt 2>&1
cp /etc/Acronis/BackupAndRecovery.config BackupAndRecovery.config 2>&1
fi
# For ABR AMS
if [ -x "$abrams" ]; then
/etc/init.d/acronis_ams status > ams.txt 2>&1
cp /etc/Acronis/AMS.config AMS.config 2>&1
#dump PostgreSQL database
# disabled as most installations use sqlite database and it is collected.
#
# pg_dump acronis_cms -Fc | gzip > acronis_cms.gz
fi
if [ -f "/tmp/AcronisAMS.log" ]; then
mkdir -p tmp 2>&1
cp /tmp/AcronisAMS.log tmp 2>&1
fi
if [ -f "/tmp/AcronisMMS.log" ]; then
mkdir -p tmp 2>&1
cp /tmp/AcronisMMS.log tmp 2>&1
fi
# Then gather system information
# Some systems have kernel config in /proc/. Let's save it
if [ -r /proc/config.gz ]; then
gunzip /proc/config.gz . 2>&1
mv config proc_config 2>&1
fi
if [ -x /usr/bin/vmstat ]; then
/usr/bin/vmstat 10 6 > vmstat.txt 2>&1
elif [ -x /bin/vmstat ]; then
/bin/vmstat 10 6 > vmstat.txt 2>&1
fi
/sbin/fdisk -l > fdisk.txt 2>&1
if [ -r /etc/issue ]; then
cp /etc/issue issue.txt 2>&1
fi
if [ -x /usr/sbin/gdisk ] || [ -x /bin/gdisk ]; then
for i in `cat /proc/partitions | awk '{print $4}' | grep -v [0-9]`; do
if [ -e "/dev/$i" ]; then
# Use echo to avoid gdisk questions. Details in ABR-152465
echo 1 | gdisk -l /dev/$i >> gdisk.txt 2>&1
fi
done
fi
if [ -r /etc/resolv.conf ]; then
cp /etc/resolv.conf resolv.txt 2>&1
fi
if [ -x /bin/uname ]; then
/bin/uname -a > uname.txt 2>&1
fi
#just in case we're on GPT system
if [ -x /sbin/parted ]; then
parted -sl > parted.txt 2>&1
fi
if [ -x /bin/lsblk ]; then
/bin/lsblk > lsblk.txt 2>&1
fi
#Creating summary.txt file with general system information
echo `date` >> summary.txt 2>&1
for i in $procfiles
do
if [ -r /proc/$i ]; then
echo "$ cat /proc/$i" >> summary.txt
cat /proc/"$i" >> summary.txt 2>&1
fi
done
echo "$ blockdev --report" >> summary.txt
blockdev --report >> summary.txt 2>&1
for sdir in `find /sys/kernel/slab -name snapapi_blk_*` ;
do
echo $sdir >> snapapi_slabs.txt 2>&1
for sfile in $slabfiles
do
if [ -r "$sdir/$sfile" ]; then
echo "$ cat $sdir/$sfile" >> snapapi_slabs.txt
cat "$sdir/$sfile" >> snapapi_slabs.txt 2>&1
fi
done
echo >> snapapi_slabs.txt 2>&1
done
if [ -x /bin/dmesg ]; then
/bin/dmesg > dmesg.txt 2>&1
fi
# copy dmesg saved right after system startup
if [ -r /var/log/dmesg ]; then
cp /var/log/dmesg . 2>&1
fi
# configuration of software RAID
dmraid_cmd=`which dmraid 2>/dev/null`
if [ -n "$dmraid_cmd" ]; then
$dmraid_cmd -rD > /dev/null 2>&1
$dmraid_cmd -n > dmraid_n.txt 2>&1
$dmraid_cmd -r > dmraid.txt 2>&1
fi
if [ -x /usr/sbin/dkms ]; then
/usr/sbin/dkms status > dkms.txt 2>&1
fi
if [ -r /var/log/trueimage-setup.log ]; then
cp /var/log/trueimage-setup.log . 2>&1
fi
if [ -r /etc/fstab ]; then
cp /etc/fstab . 2>&1
fi
if [ -r /var/log/messages ]; then
cp /var/log/messages* . 2>&1
fi
if [ -r /var/log/syslog ]; then
cp /var/log/syslog* . 2>&1
fi
# for systemd-based systems collect journal logs for the last month
if which journalctl >/dev/null 2>&1; then
journalctl --no-pager -a --since=-1month > journalctl.txt 2>&1
fi
# Ubuntu saves kernel log to kern.log unstead of messages
if [ -r /var/log/kern.log ]; then
cp /var/log/kern.log . 2>&1
fi
if [ -x /bin/getmeta ]; then
# let's call it first
/bin/getmeta
cp /tmp/*.hex .
cp /tmp/*.dd .
fi
# save logs from /tmp when on media
if [ -x /bin/acronis ]; then
cp /tmp/*.log .
cp /tmp/*.log.?.gz .
fi
if [ -x /sbin/lspci ]; then
/sbin/lspci -m -vvv > lspci.txt 2>&1
elif [ -x /bin/lspci ]; then
/bin/lspci -m -vvv > lspci.txt 2>&1
fi
if [ -d /boot ]; then
cp /boot/config* . 2>&1
ls -lR /boot > boot.txt 2>&1
fi
if [ -x /sbin/ifconfig ]; then
/sbin/ifconfig -a > ifconfig.txt 2>&1
elif [ -x /bin/ifconfig ]; then
/bin/ifconfig -a > ifconfig.txt 2>&1
fi
if [ -x /usr/bin/gcc ]; then
/usr/bin/gcc -v > gcc.txt 2>&1
fi
ps auxfww > ps.txt 2>&1
if [ "X$?" = "X1" ]; then
#ps in Bootable Media supports only "w" mode
ps w > ps.txt 2>&1
fi
if [ -x /usr/bin/crontab ]; then
/usr/bin/crontab -l > crontab.txt 2>&1
fi
if [ -x /usr/sbin/dmidecode ]; then
/usr/sbin/dmidecode > dmidecode.txt 2>&1
elif [ -x /bin/dmidecode ]; then
/bin/dmidecode > dmidecode.txt 2>&1
fi
df $df_options > df.txt 2>&1
df >> df.txt 2>&1
# Gather full contents of specified directoris
for abs_src_dir in $specific_dirs
do
if [ -d "$abs_src_dir" ]; then
tgt_dir=".$abs_src_dir"
mkdir -p "$tgt_dir"
for k in `ls -1 "$abs_src_dir"`; do cp -r "$abs_src_dir/$k" "$tgt_dir" ;done
fi
done
#Gather MMS and AMS databases
db3_files_exts=""
for ext in $db3_ext_templates
do
db3_files_exts="$db3_files_exts $ext $ext-shm $ext-wal"
done
for ext in $db3_files_exts
do
for abs_src_dir in `find $db3_dirs -name "*.$ext" -exec dirname {} \; | uniq`
do
case $abs_src_dir/ in
${work_dir}*)
# do not copy files already located in work_dir
;;
*)
mkdir -p ."$abs_src_dir"
for j in `ls -1 "$abs_src_dir" | grep "\.$ext$"`
do
cp -r "$abs_src_dir/$j" ."$abs_src_dir/$j"
done
;;
esac
done
done
#Gather Acronis logs
for ext in $logs_files_exts
do
for abs_src_dir in `find $logs_dirs -name "*.$ext" -exec dirname {} \; | uniq`
do
case $abs_src_dir/ in
${work_dir}*)
# do not copy files already located in work_dir
;;
*)
mkdir -p ."$abs_src_dir"
for j in `ls -1 "$abs_src_dir" | grep "\.$ext$"`
do
cp -r "$abs_src_dir/$j" ."$abs_src_dir/$j"
done
;;
esac
done
done
#Gather Acronis conf files
for ext in $conf_files_exts
do
for abs_src_dir in `find $conf_dirs -name "*.$ext" -exec dirname {} \; | uniq`
do
case $abs_src_dir/ in
${work_dir}*)
# do not copy files already located in work_dir
;;
*)
mkdir -p ."$abs_src_dir"
for j in `ls -1 "$abs_src_dir" | grep "\.$ext$"`
do
cp -r "$abs_src_dir/$j" ."$abs_src_dir/$j"
done
;;
esac
done
done
#Gather Virtual Appliance databse. It's not in Acronis dir, but has fixed name
virtapp_db="/var/lib/F4CEEE47-042C-4828-95A0-DE44EC267A28.db3"
if [ -r $virtapp_db ]; then
cp $virtapp_db ./var/lib/ 2>&1
fi
if [ -d $online_backup_dir ]; then
ls -lR $online_backup_dir > online_backup.txt
OPENSSL=/usr/bin/openssl
if [ -x $OPENSSL ]; then
for crt in `find $online_backup_dir -name '*.crt'`; do
echo "[$crt]" >> online_backup.txt
$OPENSSL x509 -in $crt -text -noout >> online_backup.txt 2>&1
done
fi
fi
# SELINUX information
if [ -r /etc/selinux/config ]; then
/usr/sbin/sestatus > sestatus.txt 2>&1
fi
# LVM information
if [ -c /dev/mapper/control ]; then
dmsetup table > dmsetup_table.txt 2>&1
lvm pvdisplay -v > pvdisplay.txt 2>&1
lvm vgdisplay -v > vgdisplay.txt 2>&1
lvm lvdisplay -v > lvdisplay.txt 2>&1
fi
# multipath
if [ -r /dev/mpath ]; then
multipath -v 3 -ll > multipath.txt 2>&1
fi
# Then will gather information about installed pakages.
# Currently only for rpm and dpkg - based.
if [ -x "$rpm_dist" ]; then
/bin/rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" \
> rpm_packages.txt 2>&1
elif [ -x "$non_rpm" ]; then
dpkg-query -W -f='${Package} ${Version} ${Architecture}\n' \
> dpkg_packages.txt 2>&1
fi
# Try to find loader's config file:
# Start from grub.conf
if [ -r /boot/grub/grub.conf ]; then
cp /boot/grub/grub.conf . 2>&1
fi
# Then menu.lst
if [ -r /boot/grub/menu.lst ]; then
cp /boot/grub/menu.lst . 2>&1
fi
# Then GRUB2 config
if [ -r /boot/grub2/grub.cfg ]; then
cp /boot/grub2/grub.cfg . 2>&1
fi
if [ -r /boot/grub2/i386-pc/grub.cfg ]; then
cp /boot/grub2/i386-pc/grub.cfg i386-pc_grub.cfg 2>&1
fi
# And GRUB2 environment
if [ -r /boot/grub2/grubenv ]; then
cp /boot/grub2/grubenv . 2>&1
fi
if [ -r /boot/grub2/i386-pc/grubenv ]; then
cp /boot/grub2/i386-pc/grubenv i386-pc_grubenv 2>&1
fi
# and for lilo.conf
if [ -r /etc/lilo.conf ]; then
cp /etc/lilo.conf . 2>&1
fi
# And GRUB's device map
if [ -r /boot/grub/device.map ]; then
cp /boot/grub/device.map grub1_device.map 2>&1
fi
if [ -r /boot/grub2/device.map ]; then
cp /boot/grub2/device.map grub2_device.map 2>&1
fi
# gather some files for VZ
if [ -r /etc/vz/vz.conf ]; then
cp /etc/vz/vz.conf . 2>&1
fi
if [ -r /etc/parallels-release ]; then
cp /etc/parallels-release . 2>&1
fi
if [ -r /var/log/parallels.log ]; then
cp /var/log/parallels.log . 2>&1
fi
# Gather information about tape devices
if [ -x /usr/lib/Acronis/ARSM/tapes_info ]; then
/usr/lib/Acronis/ARSM/tapes_info tapes_info.txt
elif [ -x /bin/tapes_info ]; then
/bin/tapes_info tapes_info.txt
fi
#Get dumps from root folder by pattern
for f in /*.dmp; do
[ -r "$f" ] && tar -czf "$(basename $f).tar.gz" "$f";
done
python_executable="/usr/sbin/acropsh"
sysinfo_py="/usr/lib/Acronis/BackupAndRecovery/sysinfo.py"
if [ ! \( -x "$python_executable" -a -f "$sysinfo_py" \) ]; then
# if scripts not found in standard locations try Virtual Appliance locations
python_executable="/bin/acropsh"
sysinfo_py="/bin/sysinfo.py"
fi
if [ -x "$python_executable" -a -f "$sysinfo_py" ]; then
# Continue sysinfo collection using python report utility
$python_executable $sysinfo_py
fi
cd ../
if [ "$is_dir_mode" -eq "1" ]; then
if [ "$silent_mode" -eq "0" ]; then
echo Sysinfo collected into $work_dir
fi
exit 0
fi
tar -cjf "$result_abs_path" ./logs
rm -rf ./logs
if [ -f "$result_abs_path" ]; then
if [ "$silent_mode" -eq "0" ]; then
echo Report file $result_abs_path has been created.
fi
exit 0
fi
exit 1