From 85decc973069012de452a6b452d6733e844fd398 Mon Sep 17 00:00:00 2001 From: jumao Date: Tue, 3 Oct 2023 09:35:11 -0400 Subject: [PATCH] fix --- syncd/scripts/saidump.sh | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/syncd/scripts/saidump.sh b/syncd/scripts/saidump.sh index 5d5e504e9..86be3eeac 100755 --- a/syncd/scripts/saidump.sh +++ b/syncd/scripts/saidump.sh @@ -1,41 +1,37 @@ #!/bin/bash set -e -function debug() +save_saidump_by_rdb() { - /usr/bin/logger "$1" -} - -save_saidump_by_rdb() { local filepath="/var/run/redis/sonic-db/database_config.json" - #Get hostname, port, redis directory + # 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 + # 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" + logger "saidump.sh: hostname:$hostname, port:$port, redis_dir:$redis_dir" - debug "saidump.sh: [1] Config Redis consistency directory." + logger "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." + logger "saidump.sh: [2] SAVE." redis-cli -h $hostname -p $port SAVE > /dev/null - debug "saidump.sh: [3] Run rdb command to convert the dump files into JSON files." + logger "saidump.sh: [3] Run rdb command to convert the dump files into JSON files." 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 files' format as same as the saidump before. Then we can get the saidump's result in standard output." + logger "saidump.sh: [4] Run saidump -r to update the JSON files' format as same as the saidump before. Then we can get the saidump's result in standard output." saidump -r $redis_dir/dump.json -m 100 - debug "saidump.sh: [5] Clear the temporary files." + logger "saidump.sh: [5] Clear the temporary files." rm -f $redis_dir/dump.rdb rm -f $redis_dir/dump.json }