Skip to content

Commit

Permalink
Add first cut of a script that collects runtime information.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Jan 31, 2014
1 parent 6f4dc6d commit 3feb4c3
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 0 deletions.
1 change: 1 addition & 0 deletions autoconf/configure.in
Expand Up @@ -3757,6 +3757,7 @@ debian/bareos-director.preinst \
debian/bareos-storage.preinst \
scripts/bareos-config \
scripts/bareos-config-lib.sh \
scripts/bareos-explorer \
scripts/btraceback \
scripts/bconsole \
scripts/bareos \
Expand Down
1 change: 1 addition & 0 deletions debian/bareos-common.install
@@ -1,5 +1,6 @@
/usr/lib/bareos/scripts/bareos-config
/usr/lib/bareos/scripts/bareos-config-lib.sh
/usr/lib/bareos/scripts/bareos-explorer
/usr/lib/bareos/scripts/btraceback.gdb
/usr/lib/libbareos.so
/usr/lib/libbareos-*.so
Expand Down
1 change: 1 addition & 0 deletions platforms/packaging/bareos.spec
Expand Up @@ -742,6 +742,7 @@ echo "This is a meta package to install a full bareos system" > %{buildroot}%{_d
%dir %{script_dir}
%{script_dir}/bareos-config
%{script_dir}/bareos-config-lib.sh
%{script_dir}/bareos-explorer
%{script_dir}/btraceback.gdb
%if "%{_libdir}/bareos/" != "/usr/lib/bareos/"
%dir %{_libdir}/bareos/
Expand Down
1 change: 1 addition & 0 deletions scripts/Makefile.in
Expand Up @@ -63,6 +63,7 @@ install: installdirs
#$(INSTALL_SCRIPT) -m 700 bareos-password-setup.sh ${DESTDIR}${scriptdir}/bareos-password-setup.sh
$(INSTALL_SCRIPT) bareos-config ${DESTDIR}${scriptdir}/bareos-config
$(INSTALL_SCRIPT) bareos-config-lib.sh ${DESTDIR}${scriptdir}/bareos-config-lib.sh
$(INSTALL_SCRIPT) bareos-explorer ${DESTDIR}${scriptdir}/bareos-explorer
$(INSTALL_SCRIPT) btraceback $(DESTDIR)$(sbindir)/btraceback
#$(INSTALL_SCRIPT) logrotate $(DESTDIR)/etc/logrotate.d/bareos-dir

Expand Down
267 changes: 267 additions & 0 deletions scripts/bareos-explorer.in
@@ -0,0 +1,267 @@
#!/bin/sh
#
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2014-2014 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# 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. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# This script will collect all info of a bareos install like:
# - logfiles
# - bactraces
# - tracebacks
# - core files
#
set -a

#
# Source the Bareos config functions.
#
. @scriptdir@/bareos-config-lib.sh

working_dir=`get_working_dir`

get_compression_method()
{
#
# See what compression is available on the platform
#
bzip2=`which bzip2 2> /dev/null`
gzip=`which gzip 2> /dev/null`

if [ ! -z "${bzip2}" ]; then
compressor="${bzip2} -z -c"
comp_suffix=".bz2"
else
if [ ! -z "${gzip}" ]; then
compressor="${gzip} -c"
comp_suffix=".gz"
else
compressor="cat"
comp_suffix=""
fi
fi
}

collect_debug_info()
{
#
# If there is a logfile capture it and compress them when possible.
#
if [ -f log ]; then
${compressor} log > collect.$$/log${comp_suffix}
fi

#
# Capture all core files and compress them when possible.
#
for file in *.core.*
do
${compressor} ${file} > collect.$$/${file}${comp_suffix}
if [ ${REMOVE:-NO} = YES ]; then
rm -f ${file}
fi
done

#
# Capture all bactrace files
#
for file in *.bactrace
do
cp -p ${file} collect.$$
if [ ${REMOVE:-NO} = YES ]; then
rm -f ${file}
fi
done

#
# Capture all traceback files
#
for file in *.traceback
do
cp -p ${file} collect.$$
if [ ${REMOVE:-NO} = YES ]; then
rm -f ${file}
fi
done
}

collect_pkg_info()
{
case `uname -s` in
Linux)
LSB_DISTRIBUTOR=`lsb_release -i -s`
case ${LSB_DISTRIBUTOR} in
"SUSE LINUX")
PKG_TYPE="rpm"
if [ -f /etc/os-release ]; then
cat /etc/os-release
else
if [ -f /etc/SuSE-release ]; then
cat /etc/SuSE-release
fi
fi
;;
"openSUSE project")
PKG_TYPE="rpm"
if [ -f /etc/os-release ]; then
cat /etc/os-release
else
if [ -f /etc/SuSE-release ]; then
cat /etc/SuSE-release
fi
fi
;;
CentOS)
PKG_TYPE="rpm"
if [ -f /etc/redhat-release ]; then
cat /etc/redhat-release
fi
;;
Fedora)
PKG_TYPE="rpm"
if [ -f /etc/fedora-release ]; then
cat /etc/fedora-release
fi
;;
RedHatEnterprise*)
PKG_TYPE="rpm"
if [ -f /etc/redhat-release ]; then
cat /etc/redhat-release
fi
;;
Oracle*)
PKG_TYPE="rpm"
;;
MandrivaLinux)
PKG_TYPE="rpm"
;;
Arch|archlinux)
;;
LinuxMint)
;;
Debian)
PKG_TYPE="deb"
if [ -f /etc/debian_version ]; then
cat /etc/debian_version
fi
;;
Ubuntu)
PKG_TYPE="deb"
if [ -f /etc/debian_version ]; then
cat /etc/debian_version
fi
;;
Univention)
PKG_TYPE="deb"
if [ -f /etc/debian_version ]; then
cat /etc/debian_version
fi
;;
*)
;;
esac

case ${PKG_TYPE} in
deb)
dpkg-query -l '*bareos*'
;;
rpm)
rpm -qa | grep bareos
;;
*)
;;
esac
;;
SunOS)
for pkgname in `pkginfo | grep bareos | cut -d' ' -f2`
do
pkginfo -l ${pkgname}
done
;;
*)
;;
esac > collect.$$/pkginfo
}

collect()
{
output="bareos.capture.`date +%Y%m%d%H%M`.tar"
cd ${working_dir} || exit 1

#
# Create a collection dir
#
mkdir collect.$$

#
# See what compression we can use to make things somewhat smaller.
#
get_compression_method

#
# Collect the debug information like postmortem core files, logs
# and bactrace and traceback files.
#
collect_debug_info

#
# Collect the installed packages.
#
collect_pkg_info

#
# tar up the whole capture folder
#
tar cf ${output} collect.$$
rm -rf collect.$$

echo "Please upload the following file for support: ${workdir}/${output}"
}

usage()
{
echo "Usage: $0 [-hr]"
}

main()
{
#
# Parse options.
#
while getopts "hr" arg
do
case ${arg} in
r)
REMOVE="YES"
;;
h|\?)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
nr_shift=`expr $OPTIND - 1`
shift ${nr_shift}

collect $*
}

main $*

0 comments on commit 3feb4c3

Please sign in to comment.