metrics: Rename function at memory usage script

This PR renames the function name for the memory usage script.

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
Gabriela Cervantes 2023-07-04 19:53:17 +00:00
parent b9d66e0d53
commit d8f90e89d5

View File

@ -33,7 +33,7 @@ MEM_TMP_FILE=$(mktemp meminfo.XXXXXXXXXX)
PS_TMP_FILE=$(mktemp psinfo.XXXXXXXXXX) PS_TMP_FILE=$(mktemp psinfo.XXXXXXXXXX)
function remove_tmp_file() { function remove_tmp_file() {
rm -rf "${MEM_TMP_FILE $PS_TMP_FILE}" rm -rf "${MEM_TMP_FILE}" "${PS_TMP_FILE}"
} }
trap remove_tmp_file EXIT trap remove_tmp_file EXIT
@ -99,7 +99,7 @@ get_pss_memory(){
# This will be help us to retrieve raw information # This will be help us to retrieve raw information
echo "${ps}" >> "${PS_TMP_FILE}" echo "${ps}" >> "${PS_TMP_FILE}"
data=$(sudo "${SMEM_BIN}" --no-header -P "^$ps" -c "pss" | sed 's/[[:space:]]//g') data=$(sudo "${SMEM_BIN}" --no-header -P "^${ps}" -c "pss" | sed 's/[[:space:]]//g')
# Save all the smem results # Save all the smem results
# This will help us to retrieve raw information # This will help us to retrieve raw information
@ -220,7 +220,7 @@ EOF
} }
# Try to work out the 'average memory footprint' of a container. # Try to work out the 'average memory footprint' of a container.
get_docker_memory_usage(){ get_memory_usage(){
hypervisor_mem=0 hypervisor_mem=0
virtiofsd_mem=0 virtiofsd_mem=0
shim_mem=0 shim_mem=0
@ -277,16 +277,16 @@ EOF
# Now if you do not have enough rights # Now if you do not have enough rights
# the smem failure to read the stats will also be trapped. # the smem failure to read the stats will also be trapped.
hypervisor_mem="$(get_pss_memory "${HYPERVISOR_PATH}")" hypervisor_mem="$(get_pss_memory ${HYPERVISOR_PATH})"
if [ "${hypervisor_mem}" == "0" ]; then if [ "${hypervisor_mem}" == "0" ]; then
die "Failed to find PSS for ${HYPERVISOR_PATH}" die "Failed to find PSS for ${HYPERVISOR_PATH}"
fi fi
virtiofsd_mem="$(get_pss_memory_virtiofsd "${VIRTIOFSD_PATH}")" virtiofsd_mem="$(get_pss_memory_virtiofsd ${VIRTIOFSD_PATH})"
if [ "${virtiofsd_mem}" == "0" ]; then if [ "${virtiofsd_mem}" == "0" ]; then
echo >&2 "WARNING: Failed to find PSS for ${VIRTIOFSD_PATH}" echo >&2 "WARNING: Failed to find PSS for ${VIRTIOFSD_PATH}"
fi fi
shim_mem="$(get_pss_memory "${SHIM_PATH}")" shim_mem="$(get_pss_memory ${SHIM_PATH})"
if [ "${shim_mem}" == "0" ]; then if [ "${shim_mem}" == "0" ]; then
die "Failed to find PSS for ${SHIM_PATH}" die "Failed to find PSS for ${SHIM_PATH}"
fi fi
@ -353,8 +353,6 @@ main(){
#Check for KSM before reporting test name, as it can modify it #Check for KSM before reporting test name, as it can modify it
check_for_ksm check_for_ksm
sudo systemctl restart containerd
init_env init_env
check_cmds "${SMEM_BIN}" bc check_cmds "${SMEM_BIN}" bc
@ -370,7 +368,7 @@ main(){
metrics_json_init metrics_json_init
save_config save_config
get_docker_memory_usage get_memory_usage
if [ "$RUNTIME" == "runc" ]; then if [ "$RUNTIME" == "runc" ]; then
get_runc_individual_memory get_runc_individual_memory