Issue related to memory script

  Kiến thức lập trình

Please find below script and it is failing due to standard in syntax error. Please check the same and help to fix all issues.

I need to fetch Memory utilization Details with the help of script.

#########################

#!/bin/bash

mem_tot=`free -m|grep Mem|awk '{print $2}'`

mem_avlbl=`free -m|grep Mem|awk '{print $7}'`

avlbl_per=`echo "("$mem_avlbl" / "$mem_tot")*100" | bc -l | awk '{printf("%.0f\n",$1)}'`

#echo $mem_tot

#echo $mem_avlbl

#echo $avlbl_per

if [ "$avlbl_per" -lt "10" ]

then

echo "Memory High Usage, Memory_Tot=$mem_tot, Memory_Avlbl=$mem_avlbl, Mem_Avlbl_Per=$avlbl_per"

else

echo "Memory Usage Below Threshold, Memory_Tot=$mem_tot, Memory_Avlbl=$mem_avlbl, Mem_Avlbl_Per=$avlbl_per"

fi

1

LEAVE A COMMENT