diff --git a/bin/check.sh b/bin/check.sh index 25cf474c..2129e7e0 100755 --- a/bin/check.sh +++ b/bin/check.sh @@ -355,6 +355,15 @@ function copy_logs cp "${KAMLB_LOG}" "${LOG_DIR}/kamailio-lb.log" } +function memdbg +{ + if [ -x /usr/share/ngcp-system-tools/kamcmd/memdbg ] ; then + ngcp-sercmd proxy memdbg all >/dev/null + mkdir -p "${MLOG_DIR}" + ngcp-memdbg-csv "${KAM_LOG}" "${MLOG_DIR}" >/dev/null + fi +} + # $1 sipp xml scenario file function run_sipp { @@ -463,6 +472,9 @@ function run_sipp if [ "${CAPTURE}" = "1" ] ; then stop_capture fi + if [[ ${MEMDBG} = 1 ]] ; then + memdbg + fi copy_logs # if any scenario has a log... error if [ "$(find "${SCEN_CHECK_DIR}" -name 'sipp_scenario*errors.log' 2>/dev/null|wc -l)" -ne 0 ]; then @@ -495,7 +507,7 @@ function test_filepath function usage { - echo "Usage: check.sh [-hCDRTGgJ] [-d DOMAIN ] [-p PROFILE ] -s [GROUP] check_name" + echo "Usage: check.sh [-hCDRTGgJKm] [-d DOMAIN ] [-p PROFILE ] -s [GROUP] check_name" echo "Options:" echo -e "\t-C: skip creation of domain and subscribers" echo -e "\t-R: skip run sipp" @@ -509,11 +521,12 @@ function usage echo -e "\t-J kamailio json output ON. PARSE skipped" echo -e "\t-K enable tcpdump capture" echo -e "\t-s scenario group. Default: scenarios" + echo -e "\t-m enable memdbg csv" echo "Arguments:" echo -e "\tcheck_name. Scenario name to check. This is the name of the directory on GROUP dir." } -while getopts 'hCd:p:Rs:DTPGgJK' opt; do +while getopts 'hCd:p:Rs:DTPGgJKm' opt; do case $opt in h) usage; exit 0;; C) SKIP=1;; @@ -528,6 +541,7 @@ while getopts 'hCd:p:Rs:DTPGgJK' opt; do G) GRAPH=1;; g) GRAPH_FAIL=1;; J) JSON_KAM=1;; + m) MEMDBG=1;; esac done shift $((OPTIND - 1)) @@ -553,6 +567,7 @@ SCEN_DIR="${BASE_DIR}/${GROUP}" SCEN_CHECK_DIR="${SCEN_DIR}/${NAME_CHECK}" DOMAIN=${DOMAIN:-"spce.test"} PROFILE="${PROFILE:-CE}" +MLOG_DIR="${BASE_DIR}/mem" if [ "${PROFILE}" != "CE" ] && [ "${PROFILE}" != "PRO" ]; then echo "PROFILE ${PROFILE} unknown" diff --git a/run_tests.sh b/run_tests.sh index ff35b7cd..70c1726f 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -63,7 +63,7 @@ function cfg_debug_off fi } -while getopts 'hlcp:Kx:t:' opt; do +while getopts 'hlcp:Kx:t:m' opt; do case $opt in h) usage; exit 0;; l) SHOW_SCENARIOS=1;; @@ -72,6 +72,7 @@ while getopts 'hlcp:Kx:t:' opt; do K) SKIP_CAPTURE=1;; x) GROUP=$OPTARG;; t) TIMEOUT=$OPTARG;; + m) MEMDBG=1;; esac done shift $((OPTIND - 1)) @@ -138,14 +139,22 @@ echo "$(date) - Initial mem stats" VERSION="${PROFILE}_$(cut -f1 -d' '< /etc/ngcp_version)_" "${BIN_DIR}/mem_stats.py" --private_file="${MLOG_DIR}/${VERSION}_${GROUP}_initial_pvm.cvs" \ --share_file="${MLOG_DIR}/${VERSION}_${GROUP}_initial_shm.cvs" +if [[ ${MEMDBG} = 1 ]] ; then + ngcp-memdbg-csv /var/log/ngcp/kamailio-proxy.log "${MLOG_DIR}" >/dev/null +fi get_scenarios if [[ ${SKIP_CAPTURE} = 1 ]] ; then - echo "$(date) enable capture" + echo "$(date) - enable capture" OPTS+="-K" fi +if [[ ${MEMDBG} = 1 ]] ; then + echo "$(date) - enable memdbg" + OPTS+="-m" +fi + for t in ${SCENARIOS}; do echo "$(date) - Run[${GROUP}/${PROFILE}]: $t =================================================" log_temp="${LOG_DIR}/${t}" @@ -163,6 +172,9 @@ done echo "$(date) - Final mem stats" "${BIN_DIR}/mem_stats.py" --private_file="${MLOG_DIR}/${VERSION}_${GROUP}_final_pvm.cvs" \ --share_file="${MLOG_DIR}/${VERSION}_${GROUP}_final_shm.cvs" +if [[ ${MEMDBG} = 1 ]] ; then + ngcp-memdbg-csv /var/log/ngcp/kamailio-proxy.log "${MLOG_DIR}" >/dev/null +fi cfg_debug_off