Skip to content

Commit

Permalink
#16466 fixing based on review comments:
Browse files Browse the repository at this point in the history
To add the rdbtools into base docker.
Move saidump.sh from host to syncd docker container.
  • Loading branch information
JunhongMao committed Sep 30, 2023
1 parent 65fc011 commit aaac734
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 50 deletions.
4 changes: 0 additions & 4 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,6 @@ SONIC_VERSION_CACHE=${SONIC_VERSION_CACHE} \
DBGOPT="${DBGOPT}" \
scripts/collect_host_image_version_files.sh $CONFIGURED_ARCH $IMAGE_DISTRO $TARGET_PATH $FILESYSTEM_ROOT

## Copy saidump.sh
sudo cp ./files/scripts/saidump.sh $FILESYSTEM_ROOT/usr/local/bin/saidump.sh
sudo chmod +x $FILESYSTEM_ROOT/usr/local/bin/saidump.sh

# Remove GCC
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y remove gcc

Expand Down
46 changes: 0 additions & 46 deletions files/scripts/saidump.sh

This file was deleted.

4 changes: 4 additions & 0 deletions platform/broadcom/docker-syncd-brcm-dnx/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor/"]

# Copy saidump.sh
COPY ["saidump.sh", "/usr/bin/"]
RUN chmod +x /usr/bin/saidump.sh

## Clean up
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs
Expand Down
43 changes: 43 additions & 0 deletions platform/broadcom/docker-syncd-brcm-dnx/saidump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -e

function debug()
{
/usr/bin/logger "$1"
}

save_saidump_by_rdb() {
local filepath="/var/run/redis/sonic-db/database_config.json"

#Get hostname, port, redis directory
local redis_config=$(python3 -c "
import json
with open('$filepath') as json_file:
data = json.load(json_file)
print(data['INSTANCES']['redis']['hostname'], data['INSTANCES']['redis']['port'], data['INSTANCES']['redis']['unix_socket_path'])")

#split
redis_config=(${redis_config// / })
local hostname=${redis_config[0]}
local port=${redis_config[1]}
local redis_dir=`dirname ${redis_config[2]}`
debug "saidump.sh: hostname:$hostname, port:$port, redis_dir:$redis_dir"

debug "saidump.sh: [1] Config Redis consistency directory."
redis-cli -h $hostname -p $port CONFIG SET dir $redis_dir > /dev/null

debug "saidump.sh: [2] SAVE."
redis-cli -h $hostname -p $port SAVE > /dev/null

debug "saidump.sh: [3] Run the rdb command to convert the dump.rdb into a JSON file."
rdb --command json $redis_dir/dump.rdb | tee $redis_dir/dump.json > /dev/null

debug "saidump.sh: [4] Run saidump -r to update the JSON file's format, and then get the result in the standard output."
saidump -r $redis_dir/dump.json -m 100

debug "saidump.sh: [5] Clear the temporary files."
rm -f $redis_dir/dump.rdb
rm -f $redis_dir/dump.json
}

save_saidump_by_rdb

0 comments on commit aaac734

Please sign in to comment.