@@ -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:
@@ -770,8 +786,8 @@ save_proc() {
770
786
( [ -e $f ] && $CP $V -r $f $TARDIR /proc ) || echo " $f not found" > $TARDIR /$f
771
787
fi
772
788
done
773
- $TAR $V -rhf $TARFILE -C $DUMPDIR --mode=+rw $BASE /proc
774
- $RM $V -rf $TARDIR /proc
789
+
790
+ chmod ugo+rw -R $DUMPDIR / $BASE /proc
775
791
}
776
792
777
793
# ##############################################################################
@@ -822,9 +838,7 @@ save_proc_stats() {
822
838
( $CP $V -r $stats_file $TARDIR /proc_stats ) || echo " $stats_file error" > $TARDIR /$stats_file
823
839
fi
824
840
825
- $TAR $V -rhf $TARFILE -C $DUMPDIR --mode=+rw $BASE /proc_stats
826
- $RM $V -rf $TARDIR /proc_stats
827
- $RM -rf $stats_file
841
+ chmod ugo+rw -R $DUMPDIR /$BASE /proc_stats
828
842
}
829
843
830
844
# ##############################################################################
@@ -916,16 +930,13 @@ save_file() {
916
930
local orig_path=$1
917
931
local supp_dir=$2
918
932
local gz_path=" $TARDIR /$supp_dir /$( basename $orig_path ) "
919
- local tar_path=" ${BASE} /$supp_dir /$( basename $orig_path ) "
920
933
local do_gzip=${3:- true}
921
- local do_tar_append=${4:- true}
922
934
if [ ! -d " $TARDIR /$supp_dir " ]; then
923
935
$MKDIR $V -p " $TARDIR /$supp_dir "
924
936
fi
925
937
926
938
if $do_gzip ; then
927
939
gz_path=" ${gz_path} .gz"
928
- tar_path=" ${tar_path} .gz"
929
940
if $NOOP ; then
930
941
echo " gzip -c $orig_path > $gz_path "
931
942
else
@@ -939,11 +950,6 @@ save_file() {
939
950
fi
940
951
fi
941
952
942
- if $do_tar_append ; then
943
- ($TAR $V -rhf $TARFILE -C $DUMPDIR " $tar_path " \
944
- || abort " ${EXT_PROCFS_SAVE_FAILED} " " tar append operation failed. Aborting to prevent data loss." ) \
945
- && $RM $V -f " $gz_path "
946
- fi
947
953
end_t=$( date +%s%3N)
948
954
echo " [ save_file:$orig_path ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
949
955
}
@@ -1290,7 +1296,7 @@ collect_barefoot() {
1290
1296
done
1291
1297
1292
1298
for file in $( find /tmp/bf_logs -type f) ; do
1293
- save_file " ${file} " log true true
1299
+ save_file " ${file} " log true
1294
1300
done
1295
1301
}
1296
1302
@@ -1346,16 +1352,12 @@ save_log_files() {
1346
1352
# don't gzip already-gzipped log files :)
1347
1353
# do not append the individual files to the main tarball
1348
1354
if [ -z " ${file##* .gz} " ]; then
1349
- save_file $file log false false
1355
+ save_file $file log false
1350
1356
else
1351
- save_file $file log true false
1357
+ save_file $file log true
1352
1358
fi
1353
1359
done
1354
1360
1355
- # Append the log folder to the main tarball
1356
- ($TAR $V -rhf $TARFILE -C $DUMPDIR ${BASE} /log \
1357
- || abort " ${EXT_TAR_FAILED} " " tar append operation failed. Aborting for safety" ) \
1358
- && $RM $V -rf $TARDIR /log
1359
1361
end_t=$( date +%s%3N)
1360
1362
echo " [ TAR /var/log Files ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
1361
1363
@@ -1380,11 +1382,7 @@ save_warmboot_files() {
1380
1382
else
1381
1383
mkdir -p $TARDIR
1382
1384
$CP $V -rf /host/warmboot $TARDIR
1383
-
1384
- ($TAR $V --warning=no-file-removed -rhf $TARFILE -C $DUMPDIR --mode=+rw \
1385
- $BASE /warmboot \
1386
- || abort " ${EXT_TAR_FAILED} " " Tar append operation failed. Aborting for safety." ) \
1387
- && $RM $V -rf $TARDIR
1385
+ chmod ugo+rw -R $DUMPDIR /$BASE /warmboot
1388
1386
fi
1389
1387
end_t=$( date +%s%3N)
1390
1388
echo " [ Warm-boot Files ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
@@ -1546,8 +1544,7 @@ main() {
1546
1544
/proc/pagetypeinfo /proc/partitions /proc/sched_debug /proc/slabinfo \
1547
1545
/proc/softirqs /proc/stat /proc/swaps /proc/sysvipc /proc/timer_list \
1548
1546
/proc/uptime /proc/version /proc/vmallocinfo /proc/vmstat \
1549
- /proc/zoneinfo \
1550
- || abort " ${EXT_PROCFS_SAVE_FAILED} " " Proc saving operation failed. Aborting for safety."
1547
+ /proc/zoneinfo
1551
1548
save_proc_stats
1552
1549
end_t=$( date +%s%3N)
1553
1550
echo " [ Capture Proc State ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
@@ -1567,7 +1564,6 @@ main() {
1567
1564
save_cmd " systemd-analyze plot" " systemd.analyze.plot.svg"
1568
1565
1569
1566
save_platform_info
1570
-
1571
1567
save_cmd " show vlan brief" " vlan.summary"
1572
1568
save_cmd " show version" " version"
1573
1569
save_cmd " show platform summary" " platform.summary"
@@ -1582,8 +1578,8 @@ main() {
1582
1578
1583
1579
save_ip_info
1584
1580
save_bridge_info
1585
-
1586
1581
save_frr_info
1582
+
1587
1583
save_bgp_info
1588
1584
save_evpn_info
1589
1585
@@ -1663,9 +1659,6 @@ main() {
1663
1659
# 2nd counter snapshot late. Need 2 snapshots to make sense of counters trend.
1664
1660
save_counter_snapshot $asic 2
1665
1661
1666
- $RM $V -rf $TARDIR
1667
- $MKDIR $V -p $TARDIR
1668
- $MKDIR $V -p $LOGDIR
1669
1662
# Copying the /etc files to a directory and then tar it
1670
1663
$CP -r /etc $TARDIR /etc
1671
1664
rm_list=$( find -L $TARDIR /etc -maxdepth 5 -type l)
@@ -1677,30 +1670,13 @@ main() {
1677
1670
# Remove secret from /etc files before tar
1678
1671
remove_secret_from_etc_files $TARDIR
1679
1672
1680
- start_t=$( date +%s%3N)
1681
- ($TAR $V --warning=no-file-removed -rhf $TARFILE -C $DUMPDIR --mode=+rw \
1682
- --exclude=" etc/alternatives" \
1683
- --exclude=" */etc/passwd*" \
1684
- --exclude=" */etc/shadow*" \
1685
- --exclude=" */etc/group*" \
1686
- --exclude=" */etc/gshadow*" \
1687
- --exclude=" */etc/ssh*" \
1688
- --exclude=" *get_creds*" \
1689
- --exclude=" *snmpd.conf*" \
1690
- --exclude=" */etc/mlnx" \
1691
- --exclude=" */etc/mft" \
1692
- --exclude=" */etc/sonic/*.cer" \
1693
- --exclude=" */etc/sonic/*.crt" \
1694
- --exclude=" */etc/sonic/*.pem" \
1695
- --exclude=" */etc/sonic/*.key" \
1696
- --exclude=" */etc/ssl/*.pem" \
1697
- --exclude=" */etc/ssl/certs/*" \
1698
- --exclude=" */etc/ssl/private/*" \
1699
- $BASE /etc \
1700
- || abort " ${EXT_TAR_FAILED} " " Tar append operation failed. Aborting for safety." ) \
1701
- && $RM $V -rf $TARDIR
1702
- end_t=$( date +%s%3N)
1703
- echo " [ TAR /etc Files ] : $(( $end_t - $start_t )) msec" >> $TECHSUPPORT_TIME_INFO
1673
+ # Remove unecessary files
1674
+ $RM $V -rf $TARDIR /etc/alternatives $TARDIR /etc/passwd* \
1675
+ $TARDIR /etc/shadow* $TARDIR /etc/group* $TARDIR /etc/gshadow* \
1676
+ $TARDIR /etc/ssh* $TARDIR /get_creds* $TARDIR /snmpd.conf* \
1677
+ $TARDIR /etc/mlnx $TARDIR /etc/mft $TARDIR /etc/sonic/* .cer \
1678
+ $TARDIR /etc/sonic/* .crt $TARDIR /etc/sonic/* .pem $TARDIR /etc/sonic/* .key \
1679
+ $TARDIR /etc/ssl/* .pem $TARDIR /etc/ssl/certs/ $TARDIR /etc/ssl/private/*
1704
1680
1705
1681
save_log_files
1706
1682
save_crash_files
@@ -1720,6 +1696,8 @@ finalize() {
1720
1696
# Save techsupport timing profile info
1721
1697
save_file $TECHSUPPORT_TIME_INFO log false
1722
1698
1699
+ save_to_tar
1700
+
1723
1701
if $DO_COMPRESS ; then
1724
1702
RC=0
1725
1703
$GZIP $V $TARFILE || RC=$?
0 commit comments