summaryrefslogtreecommitdiffstats
path: root/utils/pb-sos
blob: e3e8f6bb393bf9309b524790248f22581cb931d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh

diagdir="diag"
tarfile="pb-sos.tar"
tarflags="-cf"
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="--verbose $tarflags";;
	-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

# Add Skiboot log
log "Adding Skiboot log"
cat /sys/firmware/opal/msglog > /$diagdir/msglog

log "Compressing..."
cd /

tar $tarflags $tarfile $diagdir
gzip < $tarfile > $tarfile.gz
rm -f $tarfile
tarfile="$tarfile.gz"

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