metrics: Fix function of how to retrieve multiple values

This PR fixes the function of how to add multiple values of pss memory.

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
Gabriela Cervantes 2023-07-05 18:17:57 +00:00
parent 18968f428f
commit 1c3dbafbf0

View File

@ -99,13 +99,14 @@ function 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' | tr '\n' ' ' | sed 's/[[:blank:]]*$//')
# 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
echo "${data}" >> "${MEM_TMP_FILE}" echo "${data}" >> "${MEM_TMP_FILE}"
for i in "${data}"; do gral_data=$(echo "${data// /+}" | bc)
for i in "${gral_data}"; do
if (( $i > 0 ));then if (( $i > 0 ));then
mem_amount=$(( i + mem_amount )) mem_amount=$(( i + mem_amount ))
(( count++ )) (( count++ ))
@ -143,7 +144,7 @@ function get_pss_memory_virtiofsd() {
echo "${virtiofsd_path}" >> "${PS_TMP_FILE}" echo "${virtiofsd_path}" >> "${PS_TMP_FILE}"
virtiofsd_pids=$(ps aux | grep virtiofsd | awk '{print $2}') virtiofsd_pids=$(ps aux | grep [v]irtiofsd | awk '{print $2}' | head -1)
data=$(sudo smem --no-header -P "^${virtiofsd_path}" -c pid -c "pid pss") data=$(sudo smem --no-header -P "^${virtiofsd_path}" -c pid -c "pid pss")
for p in "${virtiofsd_pids}"; do for p in "${virtiofsd_pids}"; do