[PATCH 1/2] utils: Add diagnostic script
Samuel Mendoza-Jonas
sam.mj at au1.ibm.com
Thu May 28 14:44:11 AEST 2015
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 at 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.mj at au1.ibm.com>
---
utils/Makefile.am | 2 +-
utils/pb-sos | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 1 deletion(-)
create mode 100755 utils/pb-sos
diff --git a/utils/Makefile.am b/utils/Makefile.am
index 9b36619..daf98bb 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-sos b/utils/pb-sos
new file mode 100755
index 0000000..7e1eda3
--- /dev/null
+++ b/utils/pb-sos
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+diagdir="diag"
+tarfile="pb-sos.tar"
+tarflags=""
+corefile="/core"
+verbose=0
+
+usage() {
+ echo "usage: $0 [-v] [-f file] [-d user at host:/path]"
+}
+
+log() {
+ if [ $verbose -eq 1 ]
+ then
+ echo $1
+ fi
+}
+
+ARGS=`getopt vd:f: "$@"`
+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;;
+ -*)
+ echo >&2 usage
+ exit 1;;
+ *) break;;
+ esac
+ shift
+done
+
+mkdir /$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
--
2.1.0
More information about the Petitboot
mailing list