tunnel/checkmemnginx.sh

11 lines
293 B
Bash

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
MemTotal=`free -t |grep "Mem:" | awk '{print $2}'`
MemUsed=`free -t |grep "Mem:" | awk '{print $3}'`
MemPercent=$((MemUsed*100/MemTotal))
if [ $MemPercent -gt 80 ]
then
systemctl restart nginx
else
exit 1
fi