diff mbox

[2/2] pb-sos: effectively compress the pb-sos file with gzip

Message ID 20170711180405.11868-2-gpiccoli@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Guilherme G. Piccoli July 11, 2017, 6:04 p.m. UTC
Currently the pb-sos tool creates a TAR file with logs, but without
compressing it using gzip, for example. Even the output of command
says "Compressing...", but in fact no compression is done.

This patch uses gzip to effectively compress the logs. It achieves
83% of compression, observed after a simple experiment.
Also, makes use of $tarflags variable instead of pass the flags
directly in the command call.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
---
 utils/pb-sos | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/utils/pb-sos b/utils/pb-sos
index c619d7e..e94a40a 100755
--- a/utils/pb-sos
+++ b/utils/pb-sos
@@ -2,7 +2,7 @@ 
 
 diagdir="diag"
 tarfile="pb-sos.tar"
-tarflags=""
+tarflags="-cf"
 corefile="/core"
 verbose=0
 
@@ -28,7 +28,7 @@  fi
 while [ $# -gt 0 ]
 do
     case "$1" in
-	-v)	verbose=1; tarflags="$tarflags --verbose";;
+	-v)	verbose=1; tarflags="--verbose $tarflags";;
 	-f)	tarfile="$2"; shift;;
 	-d)	desthost="$2"; shift;;
 	--)	shift; break;;
@@ -68,7 +68,11 @@  cat /sys/firmware/opal/msglog > /$diagdir/msglog
 
 log "Compressing..."
 cd /
-tar $tarflags -cf $tarfile $diagdir
+
+tar $tarflags $tarfile $diagdir
+gzip < $tarfile > $tarfile.gz
+rm -f $tarfile
+tarfile="$tarfile.gz"
 
 echo "Complete, tarfile location $tarfile"