]> git.ozlabs.org Git - petitboot/commitdiff
utils: Add diagnostic script v1.1.0
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 28 May 2015 04:02:34 +0000 (14:02 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 24 May 2016 01:08:15 +0000 (11:08 +1000)
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>
utils/Makefile.am
utils/pb-console
utils/pb-sos [new file with mode: 0755]

index 403f46d5b3e5562477ad69bf1c2ec55412db49e0..f1b852e2fe865743532632e4ac7ce501b80789aa 100644 (file)
@@ -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
 
index c071a2f6e5bcce686f82dbf0d098addf111a9c63..282fca1193604ff57b7aff102844648ecd4e5f70 100644 (file)
@@ -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 (executable)
index 0000000..2e9802e
--- /dev/null
@@ -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