#!/pkg/bin/ksh
# -----------------------------------------------------------------------------
# show_tech_fast_bcc - Script to collect bundle consistency checker logs
#                    - This gets executed as part of show_tech_fast_bundles
#                    - CLI : show tech-support bundles
#
# June 2020, Abirami Kannan
#
# Copyright (c) 2020 by cisco Systems, Inc.
# All rights reserved.
#------------------------------------------------------------------------------

#Get node name RP0/RP1 to save log file
node_str=`uname -n | sed -e 's/xr-vm_node//'`

if test -f "/var/log/bcc_exception.log"; then
   
   #Create Directory to copy "show bundle consistency" CLI logs
   dir_name="bundle_pd_bcc$node_str"
   bcc_logs="$__tar_file_directory_on_node/$dir_name"
   mkdir $bcc_logs

   #Copy BCC logs from /var/log/ to __tar_file_directory_on_node/bundle_pd_bcc_<node name>
   cp /var/log/bcc_debug.log $bcc_logs/bcc_debug.log
   cp /var/log/bcc_inconsistencies.log $bcc_logs/bcc_inconsistencies.log
   cp /var/log/bcc_exception.log $bcc_logs/bcc_exception.log
   cp /var/log/bcc_programming_error.log $bcc_logs/bcc_programming_error.log
   cp /var/log/bcc_stale_entries.log $bcc_logs/bcc_stale_entries.log
   cp /var/log/bcc_delay_delete.log $bcc_logs/bcc_delay_delete.log
   cp /var/log/bcc_bundle_health.log $bcc_logs/bcc_bundle_health.log

   #Compress BCC folder
   tar -zcf "$bcc_logs.tgz" --absolute-names --directory=$__tar_file_directory_on_node $dir_name

   #Cleanup files
   rm -rf $bcc_logs
fi

