vendredi 31 mars 2017

if statement not working in shell script

Below is my script and the val1 value is 3 and Val2 value is 0 , but defaultly the condition checks the if statement. not going to else condition. can anyone help where i missed or done wrong here?

op1=$(top -bn1 | grep "Cpu(s)" | awk '{print$2}' | sed -e 's/%us,//g')
op2=$(top -bn1 | grep "load average" | awk '{print$12}' |sed -e 's/,//g')
val2=${op2%.*}
val1=${op1%.*}
echo $val1
echo $val2

if [ val1 > 50 ] || [ val2 > 50 ] ; then

  echo -e "CPU Percentage on $HOSTNAME is  $op1  and Current  Load is  $op2  Which are higher than 50% usage. Kindly Login to $HOSTNAME and examine  the process. If apache process consume the more space kindly excute the below instructed command to restart all the SWLB's. \n\n Host Name    : $HOSTNAME   \n User ID          : inauat \n Path              :/inautilus/xjp/ers/servers \n Script Name : apache_all.sh  \n\n Note: If the SWLB restart dosen't resolve the problem reach Unix support  to investigate further. "| mutt -s " $HOSTNAME CPU Status Alert  " "satheesh.charles@bnymellon.com" -c "SCharles@inautix.co.in"

else
    echo  'CPU load appears normal '
fi

Aucun commentaire:

Enregistrer un commentaire