diff options
author | Colin Guthrie <colin@mageia.org> | 2013-04-11 22:30:44 +0000 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2013-04-11 22:30:44 +0000 |
commit | 935d25c5f9af1258f3e828479a4d14e183a2a527 (patch) | |
tree | 5cbf51850190916df462acd7dd62dc24e75b34a2 /rescue/grabjournallogs | |
parent | 8152af03a422a65927068955da2593fcdea265c6 (diff) | |
download | drakx-backup-do-not-use-935d25c5f9af1258f3e828479a4d14e183a2a527.tar drakx-backup-do-not-use-935d25c5f9af1258f3e828479a4d14e183a2a527.tar.gz drakx-backup-do-not-use-935d25c5f9af1258f3e828479a4d14e183a2a527.tar.bz2 drakx-backup-do-not-use-935d25c5f9af1258f3e828479a4d14e183a2a527.tar.xz drakx-backup-do-not-use-935d25c5f9af1258f3e828479a4d14e183a2a527.zip |
rescue: add a script to simplfy grabbing of journal logs for bug reports
Diffstat (limited to 'rescue/grabjournallogs')
-rw-r--r-- | rescue/grabjournallogs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/rescue/grabjournallogs b/rescue/grabjournallogs new file mode 100644 index 000000000..ef2ea4a1d --- /dev/null +++ b/rescue/grabjournallogs @@ -0,0 +1,51 @@ +#!/bin/bash + +if ! mountpoint -q /mnt ; then + echo "I do not seem to see a Mageia install mounted on /mnt. You need to mount it first!" >&2 + exit 1 +fi + +if [ ! -f /mnt/etc/machine-id ]; then + echo "Cannot find machine-id file (/mnt/etc/machine-id)" >&2 + exit 1 +fi + +MID=$(cat /mnt/etc/machine-id) +echo +echo "Found machine-id: $MID" +if [ ! -d /mnt/var/log/journal/$MID ]; then + echo "Cannot find journal log directory (/mnt/var/log/journal/<machine-id>)" >&2 + exit 1 +fi + +TIMEFRAME=24 +if [ -n "$1" ]; then + NEWTIMEFRAME=$(( 0 + $1 )) + if [ $NEWTIMEFRAME -gt 0 ]; then + TIMEFRAME=$NEWTIMEFRAME + fi +fi +SINCE="$(LC_ALL=c date --date=$TIMEFRAME' hours ago' +'%F %T')" +echo "Will collect logs from the last $TIMEFRAME hour(s)" +echo " NB give numeric argument to override capture period" + +TEMPFILE=$(mktemp /tmp/grabjournallogs.XXXXXX) +echo -n "Extracting logs... " +journalctl -D /mnt/var/log/journal/$MID --since "$SINCE" -o short >$TEMPFILE +echo "done" + +if [ $(cat $TEMPFILE | wc -l) -lt 2 ]; then + rm -f $TEMPFILE + echo >&2 + echo "Cannot find any logs. Consider increasing the capture period by passing a" >&2 + echo "numeric argument larger than $TIMEFRAME." >&2 + exit 1 +fi + +echo -n "Compressing logs... " +cat $TEMPFILE | xz >/journallogs.xz +rm -f $TEMPFILE +echo "done" + +echo +echo "Your logs have been extracted to the file 'journallogs.xz'" |