From 24e3ee88a23ab0e6ca8a8c5a83641cead9ca8c24 Mon Sep 17 00:00:00 2001 From: Vivek Date: Sat, 18 Nov 2023 19:27:06 -0800 Subject: [PATCH] Add container rsyslog.conf to the sys dump (#3039) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What I did Added a new directory to generate_dump for collecting any container specific config files etc to the sys dump. For now only the rsyslog.conf is added How I did it How to verify it Run the dump and see if the rsyslogd files are present root@r-leopard-41:/home/admin# tree -a sonic_dump_r-leopard-41_20230815_013600/dump/container_dumps/ sonic_dump_r-leopard-41_20230815_013600/dump/container_dumps/ ├── bgp │ └── rsyslog.conf ├── database │ └── rsyslog.conf ├── dhcp_relay │ └── rsyslog.conf ├── eventd │ └── rsyslog.conf ├── lldp │ └── rsyslog.conf ├── mgmt-framework │ └── rsyslog.conf ├── pmon │ └── rsyslog.conf ├── radv │ └── rsyslog.conf ├── snmp │ └── rsyslog.conf ├── swss │ └── rsyslog.conf ├── syncd │ └── rsyslog.conf ├── teamd │ └── rsyslog.conf └── telemetry └── rsyslog.conf 13 directories, 13 files --- scripts/generate_dump | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/generate_dump b/scripts/generate_dump index e6acb8a417..552854becb 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -1670,6 +1670,22 @@ save_dump_state_all_ns() { done } +############################################################################### +# Save important files that are present in container storage for better debugging +# Files will be saved under dump// +# Types of Files Saved: +# 1) rsyslogd.conf +############################################################################### +save_container_files() { + trap 'handle_error $? $LINENO' ERR + local CONTAINER_FDUMP="container_dumps" + # Get the running container names + container_names=$(docker ps --format '{{.Names}}' --filter status=running) + for name in $container_names; do + $MKDIR $V -p $LOGDIR/$CONTAINER_FDUMP/$name + copy_from_docker $name "/etc/rsyslog.conf" $LOGDIR/$CONTAINER_FDUMP/$name/rsyslog.conf + done +} ############################################################################### # Main generate_dump routine @@ -1797,6 +1813,8 @@ main() { wait save_redis_info & + save_container_files & + if $DEBUG_DUMP then save_dump_state_all_ns &