summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2015-05-28 14:02:34 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-05-24 11:08:15 +1000
commit0ccde6508f7ba3c94caafd8ee013cbbf6bee4c2b (patch)
tree24822e60b2a3a5fc63121862b390a14de6007f15 /utils
parented8a3ad086e56fa40c72c531b3f563e35a7c0753 (diff)
downloadpetitboot-0ccde6508f7ba3c94caafd8ee013cbbf6bee4c2b.zip
petitboot-0ccde6508f7ba3c94caafd8ee013cbbf6bee4c2b.tar.gz
utils: Add diagnostic scriptv1.1.0
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 <sam@mendozajonas.com>
Diffstat (limited to 'utils')
-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