@@ -106,7 +106,6 @@ save_bcmcmd() {
106
106
local filename=$2
107
107
local filepath=" ${LOGDIR} /$filename "
108
108
local do_gzip=${3:- false}
109
- local tarpath=" ${BASE} /dump/$filename "
110
109
local timeout_cmd=" timeout --foreground ${TIMEOUT_MIN} m"
111
110
local cmd=$( escape_quotes " $cmd " )
112
111
if [ ! -d $LOGDIR ]; then
@@ -141,12 +140,9 @@ save_bcmcmd() {
141
140
fi
142
141
if $do_gzip ; then
143
142
gzip ${filepath} 2> /dev/null
144
- tarpath=" ${tarpath} .gz"
145
143
filepath=" ${filepath} .gz"
146
144
fi
147
- ($TAR $V -rhf $TARFILE -C $DUMPDIR " $tarpath " \
148
- || abort " ${EXT_TAR_FAILED} " " tar append operation failed. Aborting to prevent data loss." ) \
149
- && $RM $V -rf " $filepath "
145
+
150
146
end_t=$( date +%s%3N)
151
147
echo " [ save_bcmcmd:$cmd ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
152
148
}
@@ -180,7 +176,7 @@ save_bcmcmd_all_ns() {
180
176
}
181
177
182
178
# ##############################################################################
183
- # Runs a comamnd and saves its output to the incrementally built tar .
179
+ # Runs a comamnd and saves its output to the file .
184
180
# Command gets timedout if it runs for more than TIMEOUT_MIN minutes.
185
181
# Globals:
186
182
# LOGDIR
@@ -208,7 +204,6 @@ save_cmd() {
208
204
local filename=$2
209
205
local filepath=" ${LOGDIR} /$filename "
210
206
local do_gzip=${3:- false}
211
- local tarpath=" ${BASE} /dump/$filename "
212
207
local timeout_cmd=" timeout --foreground ${TIMEOUT_MIN} m"
213
208
local cleanup_method=${4:- dummy_cleanup_method}
214
209
local redirect=' &>'
@@ -230,7 +225,6 @@ save_cmd() {
230
225
# as one argument, e.g. vtysh -c "COMMAND HERE" needs to have
231
226
# "COMMAND HERE" bunched together as 1 arg to vtysh -c
232
227
if $do_gzip ; then
233
- tarpath=" ${tarpath} .gz"
234
228
filepath=" ${filepath} .gz"
235
229
# cleanup_method will run in a sub-shell, need declare it first
236
230
local cmds=" $cleanup_method_declration ; $cmd $redirect_eval | $cleanup_method | gzip -c > '${filepath} '"
@@ -260,13 +254,35 @@ save_cmd() {
260
254
fi
261
255
fi
262
256
263
- ($TAR $V -rhf $TARFILE -C $DUMPDIR " $tarpath " \
264
- || abort " ${EXT_TAR_FAILED} " " tar append operation failed. Aborting to prevent data loss." ) \
265
- && $RM $V -rf " $filepath "
266
257
end_t=$( date +%s%3N)
267
258
echo " [ save_cmd:$cmd ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
268
259
}
269
260
261
+ # ##############################################################################
262
+ # Save all collected data to tar archive.
263
+ # Globals:
264
+ # DUMPDIR
265
+ # TAR
266
+ # TARFILE
267
+ # V
268
+ # BASE
269
+ # Arguments:
270
+ # None
271
+ # Returns:
272
+ # None
273
+ # ##############################################################################
274
+ save_to_tar () {
275
+ trap ' handle_error $? $LINENO' ERR
276
+ local start_t=$( date +%s%3N)
277
+ local end_t=0
278
+
279
+ cd $DUMPDIR
280
+ $TAR $V -rhf $TARFILE " $BASE "
281
+
282
+ end_t=$( date +%s%3N)
283
+ echo " [ save_to_tar ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
284
+ }
285
+
270
286
# ##############################################################################
271
287
# Dummy cleanup method.
272
288
# Globals:
@@ -407,7 +423,7 @@ get_vtysh_namespace() {
407
423
# ##############################################################################
408
424
# Runs a vtysh command in all namesapces for a multi ASIC platform, and in
409
425
# default (host) namespace in single ASIC platforms. Saves its output to the
410
- # incrementally built tar .
426
+ # file .
411
427
# Globals:
412
428
# None
413
429
# Arguments:
@@ -437,7 +453,7 @@ save_vtysh() {
437
453
}
438
454
439
455
# ##############################################################################
440
- # Runs an ip command and saves its output to the incrementally built tar .
456
+ # Runs an ip command and saves its output to the file .
441
457
# Globals:
442
458
# None
443
459
# Arguments:
@@ -456,7 +472,7 @@ save_ip() {
456
472
}
457
473
458
474
# ##############################################################################
459
- # Runs a bridge command and saves its output to the incrementally built tar .
475
+ # Runs a bridge command and saves its output to the file .
460
476
# Globals:
461
477
# None
462
478
# Arguments:
@@ -769,8 +785,8 @@ save_proc() {
769
785
( [ -e $f ] && $CP $V -r $f $TARDIR /proc ) || echo " $f not found" > $TARDIR /$f
770
786
fi
771
787
done
772
- $TAR $V -rhf $TARFILE -C $DUMPDIR --mode=+rw $BASE /proc
773
- $RM $V -rf $TARDIR /proc
788
+
789
+ chmod ugo+rw -R $DUMPDIR / $BASE /proc
774
790
}
775
791
776
792
# ##############################################################################
@@ -837,7 +853,7 @@ save_platform_info() {
837
853
}
838
854
839
855
# ##############################################################################
840
- # Runs a comamnd and saves its output to the incrementally built tar .
856
+ # Runs a comamnd and saves its output to the file .
841
857
# Globals:
842
858
# LOGDIR
843
859
# BASE
@@ -862,16 +878,13 @@ save_file() {
862
878
local orig_path=$1
863
879
local supp_dir=$2
864
880
local gz_path=" $TARDIR /$supp_dir /$( basename $orig_path ) "
865
- local tar_path=" ${BASE} /$supp_dir /$( basename $orig_path ) "
866
881
local do_gzip=${3:- true}
867
- local do_tar_append=${4:- true}
868
882
if [ ! -d " $TARDIR /$supp_dir " ]; then
869
883
$MKDIR $V -p " $TARDIR /$supp_dir "
870
884
fi
871
885
872
886
if $do_gzip ; then
873
887
gz_path=" ${gz_path} .gz"
874
- tar_path=" ${tar_path} .gz"
875
888
if $NOOP ; then
876
889
echo " gzip -c $orig_path > $gz_path "
877
890
else
@@ -885,11 +898,6 @@ save_file() {
885
898
fi
886
899
fi
887
900
888
- if $do_tar_append ; then
889
- ($TAR $V -rhf $TARFILE -C $DUMPDIR " $tar_path " \
890
- || abort " ${EXT_PROCFS_SAVE_FAILED} " " tar append operation failed. Aborting to prevent data loss." ) \
891
- && $RM $V -f " $gz_path "
892
- fi
893
901
end_t=$( date +%s%3N)
894
902
echo " [ save_file:$orig_path ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
895
903
}
@@ -1269,16 +1277,12 @@ save_log_files() {
1269
1277
# don't gzip already-gzipped log files :)
1270
1278
# do not append the individual files to the main tarball
1271
1279
if [ -z " ${file##* .gz} " ]; then
1272
- save_file $file log false false
1280
+ save_file $file log false
1273
1281
else
1274
- save_file $file log true false
1282
+ save_file $file log true
1275
1283
fi
1276
1284
done
1277
1285
1278
- # Append the log folder to the main tarball
1279
- ($TAR $V -rhf $TARFILE -C $DUMPDIR ${BASE} /log \
1280
- || abort " ${EXT_TAR_FAILED} " " tar append operation failed. Aborting for safety" ) \
1281
- && $RM $V -rf $TARDIR /log
1282
1286
end_t=$( date +%s%3N)
1283
1287
echo " [ TAR /var/log Files ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
1284
1288
@@ -1303,11 +1307,7 @@ save_warmboot_files() {
1303
1307
else
1304
1308
mkdir -p $TARDIR
1305
1309
$CP $V -rf /host/warmboot $TARDIR
1306
-
1307
- ($TAR $V --warning=no-file-removed -rhf $TARFILE -C $DUMPDIR --mode=+rw \
1308
- $BASE /warmboot \
1309
- || abort " ${EXT_TAR_FAILED} " " Tar append operation failed. Aborting for safety." ) \
1310
- && $RM $V -rf $TARDIR
1310
+ chmod ugo+rw -R $DUMPDIR /$BASE /warmboot
1311
1311
fi
1312
1312
end_t=$( date +%s%3N)
1313
1313
echo " [ Warm-boot Files ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
@@ -1469,8 +1469,7 @@ main() {
1469
1469
/proc/pagetypeinfo /proc/partitions /proc/sched_debug /proc/slabinfo \
1470
1470
/proc/softirqs /proc/stat /proc/swaps /proc/sysvipc /proc/timer_list \
1471
1471
/proc/uptime /proc/version /proc/vmallocinfo /proc/vmstat \
1472
- /proc/zoneinfo \
1473
- || abort " ${EXT_PROCFS_SAVE_FAILED} " " Proc saving operation failed. Aborting for safety."
1472
+ /proc/zoneinfo
1474
1473
end_t=$( date +%s%3N)
1475
1474
echo " [ Capture Proc State ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
1476
1475
@@ -1574,9 +1573,6 @@ main() {
1574
1573
# 2nd counter snapshot late. Need 2 snapshots to make sense of counters trend.
1575
1574
save_counter_snapshot $asic 2
1576
1575
1577
- $RM $V -rf $TARDIR
1578
- $MKDIR $V -p $TARDIR
1579
- $MKDIR $V -p $LOGDIR
1580
1576
# Copying the /etc files to a directory and then tar it
1581
1577
$CP -r /etc $TARDIR /etc
1582
1578
rm_list=$( find -L $TARDIR /etc -maxdepth 5 -type l)
@@ -1588,30 +1584,13 @@ main() {
1588
1584
# Remove secret from /etc files before tar
1589
1585
remove_secret_from_etc_files $TARDIR
1590
1586
1591
- start_t=$( date +%s%3N)
1592
- ($TAR $V --warning=no-file-removed -rhf $TARFILE -C $DUMPDIR --mode=+rw \
1593
- --exclude=" etc/alternatives" \
1594
- --exclude=" */etc/passwd*" \
1595
- --exclude=" */etc/shadow*" \
1596
- --exclude=" */etc/group*" \
1597
- --exclude=" */etc/gshadow*" \
1598
- --exclude=" */etc/ssh*" \
1599
- --exclude=" *get_creds*" \
1600
- --exclude=" *snmpd.conf*" \
1601
- --exclude=" */etc/mlnx" \
1602
- --exclude=" */etc/mft" \
1603
- --exclude=" */etc/sonic/*.cer" \
1604
- --exclude=" */etc/sonic/*.crt" \
1605
- --exclude=" */etc/sonic/*.pem" \
1606
- --exclude=" */etc/sonic/*.key" \
1607
- --exclude=" */etc/ssl/*.pem" \
1608
- --exclude=" */etc/ssl/certs/*" \
1609
- --exclude=" */etc/ssl/private/*" \
1610
- $BASE /etc \
1611
- || abort " ${EXT_TAR_FAILED} " " Tar append operation failed. Aborting for safety." ) \
1612
- && $RM $V -rf $TARDIR
1613
- end_t=$( date +%s%3N)
1614
- echo " [ TAR /etc Files ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
1587
+ # Remove unecessary files
1588
+ $RM $V -rf $TARDIR /etc/alternatives $TARDIR /etc/passwd* \
1589
+ $TARDIR /etc/shadow* $TARDIR /etc/group* $TARDIR /etc/gshadow* \
1590
+ $TARDIR /etc/ssh* $TARDIR /get_creds* $TARDIR /snmpd.conf* \
1591
+ $TARDIR /etc/mlnx $TARDIR /etc/mft $TARDIR /etc/sonic/* .cer \
1592
+ $TARDIR /etc/sonic/* .crt $TARDIR /etc/sonic/* .pem $TARDIR /etc/sonic/* .key \
1593
+ $TARDIR /etc/ssl/* .pem $TARDIR /etc/ssl/certs/ $TARDIR /etc/ssl/private/*
1615
1594
1616
1595
save_log_files
1617
1596
save_crash_files
@@ -1631,6 +1610,8 @@ finalize() {
1631
1610
# Save techsupport timing profile info
1632
1611
save_file $TECHSUPPORT_TIME_INFO log false
1633
1612
1613
+ save_to_tar
1614
+
1634
1615
if $DO_COMPRESS ; then
1635
1616
RC=0
1636
1617
$GZIP $V $TARFILE || RC=$?
0 commit comments