Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[202012][Techsupport] Techsupport tmpfs logging #2996

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions scripts/generate_dump
Original file line number Diff line number Diff line change
Expand Up @@ -981,27 +981,53 @@ save_log_files() {
trap enable_logrotate HUP INT QUIT TERM KILL ABRT ALRM

start_t=$(date +%s%3N)
log_dir_1="/var/log/"
log_dir_2="/var/log.tmpfs/"
file_list=""

if [ -d "$log_dir_1" ]; then
file_list_1=$(find_files ${log_dir_1})
file_list="${file_list} ${file_list_1}"
fi

if [ -d "$log_dir_2" ]; then
file_list_2=$(find_files ${log_dir_2})
file_list="${file_list} ${file_list_2}"
fi

# gzip up all log files individually before placing them in the incremental tarball
for file in $(find_files "/var/log/"); do
for file in $file_list; do
dest_dir="log"
if [[ $file == *"tmpfs"* ]]; then
dest_dir="log.tmpfs"
fi
# ignore the sparse file lastlog
if [ "$file" = "/var/log/lastlog" ]; then
continue
fi
# don't gzip already-gzipped log files :)
# do not append the individual files to the main tarball
if [ -z "${file##*.gz}" ]; then
save_file $file log false false
save_file $file $dest_dir false false
else
save_file $file log true false
save_file $file $dest_dir true false
fi
done

# Append the log folder to the main tarball
($TAR $V -rhf $TARFILE -C $DUMPDIR ${BASE}/log \
|| abort "${ERROR_TAR_FAILED}" "tar append operation failed. Aborting for safety") \
&& $RM $V -rf $TARDIR/log
if [ -d "$log_dir_1" ]; then
($TAR $V -rhf $TARFILE -C $DUMPDIR ${BASE}/log \
|| abort "${ERROR_TAR_FAILED}" "tar append operation failed. Aborting for safety") \
&& $RM $V -rf $TARDIR/log
fi
if [ -d "$log_dir_2" ]; then
# Append the log.tmpfs folder to the main tarball
($TAR $V -rhf $TARFILE -C $DUMPDIR ${BASE}/log.tmpfs \
|| abort "${ERROR_TAR_FAILED}" "tar append operation failed. Aborting for safety") \
&& $RM $V -rf $TARDIR/log.tmpfs
fi
end_t=$(date +%s%3N)
echo "[ TAR /var/log Files ] : $(($end_t-$start_t)) msec" >> $TECHSUPPORT_TIME_INFO
echo "[ TAR /var/log and /var/log.tmpfs Files ] : $(($end_t-$start_t)) msec" >> $TECHSUPPORT_TIME_INFO

enable_logrotate
}
Expand Down
Loading