waid 发表于 2018-8-21 09:05:25

shell判断内存使用率告警

  #!/usr/bin/bash
  ########################################
  #memory used
  #v1.0 by LIXIN 20180605
  ########################################
  mem_used=free -m |grep '^Mem' |awk '{print $3}'
  mem=free -m |grep 'Mem' |awk '{print $2}'
  mem_usage=$((mem_used100/mem))
  warning_file=/tmp/mem_warning.txt
  rm -f /tmp/_warning*
  if [ "$mem_usage" -ge 20 ]; then
  

    echo"memory's warning `date +%F-%H` memory:$mem_usage%" > $warning_file  

  fi
  if [ -f $warning_file ];then
  mail -s &quot;memory warning......&quot; -a $warning_filexinli_2014@163.com < $warning_file
  rm -f /tmp/_warning
  fi


页: [1]
查看完整版本: shell判断内存使用率告警