summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils/Makefile.am2
-rw-r--r--utils/pb-console1
-rwxr-xr-xutils/pb-sos76
3 files changed, 78 insertions, 1 deletions
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
OpenPOWER on IntegriCloud