#!/bin/bash

TOTAL=$(free -m | awk '/Mem/{print $2}')
FREE=$(free -m | awk '/Mem/{print $4}')

FREE_RATE=$(awk 'BEGIN{print('"${FREE}"'/'"${TOTAL}"'*100)}')

if [[ $(awk 'BEGIN{print('"${FREE}"'/'"${TOTAL}"'>'0.15')?0:1}') -eq 0 ]];then
   checkStatus=OK
   msg="当前系统剩余内存为：${FREE_RATE}%"
else
   checkStatus=fail
   msg="当前系统剩余内存为: ${FREE_RATE}%"
fi

echo "{\"checkValue\": \"${FREE_RATE}%\", \"checkStatus\": \"${checkStatus}\", \"msg\": \"${msg}\"}"

