From 0ccde6508f7ba3c94caafd8ee013cbbf6bee4c2b Mon Sep 17 00:00:00 2001 From: Samuel Mendoza-Jonas Date: Thu, 28 May 2015 14:02:34 +1000 Subject: utils: Add diagnostic script Add a simple script to gather up useful information in the unlikely event a user runs into trouble. Usage: pb-sos [-v] [-f file] [-d user@host:/path] Options -v verbose output -f file Supply filename for tar archive (default pb-sos.tar) -d host Supply user, hostname, and path to transfer archive to a remote host Signed-off-by: Samuel Mendoza-Jonas --- utils/Makefile.am | 2 +- utils/pb-console | 1 + utils/pb-sos | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100755 utils/pb-sos (limited to 'utils') diff --git a/utils/Makefile.am b/utils/Makefile.am index 403f46d..f1b852e 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -12,7 +12,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -dist_sbin_SCRIPTS += utils/pb-udhcpc utils/pb-plugin +dist_sbin_SCRIPTS += utils/pb-udhcpc utils/pb-plugin utils/pb-sos dist_pkglibexec_SCRIPTS = utils/pb-console sbin_PROGRAMS += utils/pb-event utils/pb-config diff --git a/utils/pb-console b/utils/pb-console index c071a2f..282fca1 100644 --- a/utils/pb-console +++ b/utils/pb-console @@ -127,5 +127,6 @@ do $ui $verbose_opt reset echo "Exiting petitboot. Type 'exit' to return." + echo "You may run 'pb-sos' to gather diagnostic data" $shell done diff --git a/utils/pb-sos b/utils/pb-sos new file mode 100755 index 0000000..2e9802e --- /dev/null +++ b/utils/pb-sos @@ -0,0 +1,76 @@ +#!/bin/sh + +diagdir="diag" +tarfile="pb-sos.tar" +tarflags="" +corefile="/core" +verbose=0 + +usage() { + echo "usage: $0 [-v] [-f file] [-d user@host:/path]" +} + +log() { + if [ $verbose -eq 1 ] + then + echo $1 + fi +} + +ARGS=`getopt vd:f:h "$@"` +rc=$? +set -- $ARGS +if [ $# -lt 1 ] || [ $rc -ne 0 ]; then + usage + exit 1 +fi + +while [ $# -gt 0 ] +do + case "$1" in + -v) verbose=1; tarflags="$tarflags --verbose";; + -f) tarfile="$2"; shift;; + -d) desthost="$2"; shift;; + --) shift; break;; + -h) + usage + exit 1;; + -*) + usage + exit 1;; + *) break;; + esac + shift +done + +mkdir -p /$diagdir + +# Include version of pb-discover +pb-discover --version > /$diagdir/version + +# Unconditionally grab relevant /var/log files +log "Adding files from /var/log" +cp -r /var/log/messages /var/log/petitboot /$diagdir/ + +# Check if pb-discover segfaulted +if [ -r $corefile ] +then + log "Adding core dump" + cp /core /$diagdir/ +fi + +# Copy dmesg +log "Adding dmesg" +dmesg > /$diagdir/dmesg + +log "Compressing..." +cd / +tar $tarflags -cf $tarfile $diagdir + +echo "Complete, tarfile location $tarfile" + +# Optionally scp out to a host +if [ -n "${desthost+1}" ]; then + echo "Copying to remote host $desthost" + scp $tarfile $desthost +fi -- cgit v1.2.1