#!/pkg/bin/ksh
#--------------------------------------------------------------------
# pd_ctrace_dump - spitfire cpa ctrace buffer dump script
#
# Copyright (c) 2019-2020 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

dump_cpa_buffers() { 
    # Below are the processes which need the kill
    # signal to be sent to it to dump trace buffers
    proc_arr_dump_sig=(shelfmgr envmon fpd_client ledmgr watchdog)   
    
    for proc in ${proc_arr_dump_sig[@]};
    do
        # Sending signal to dump some ctrace buffers
        # which are not populated by above mechanism
        dump_signal=$(grep DUMP_SIGNAL /var/log/ctrace/$proc/ctrace.info | cut -d ' ' -f 2)
        kill -$dump_signal `pidof $proc`
    done
}

dump_cpa_buffers
