#!/bin/bash

source /etc/profile

mt=lgy@rashost.com
ip=$(ifconfig|grep "inet addr" | awk '{print $2}'| awk -F: '{print $2}'| head -1)

cm=$(free -m | grep buffers/cache | awk '{print $4}')
jm=100

cl=$(uptime | awk -F average: '{print $2}'| awk '{print $1}' | awk -F, '{print $1}')
jl=5

if [ `expr $cm \>= $jm` -eq 1 ]
then
	echo Memory is enough
else
	echo Memory is not enough
	free -m | mail -s "$ip -> Memory is not enough" $mt
	pkill -9 php
	pkill -9 php
	pkill -9 php
fi

if [ `expr $cl \>= $jl` -eq 1 ]
then
	echo Load is high
	uptime | mail -s "$ip -> Load is high" $mt
	pkill -9 php
	pkill -9 php
	pkill -9 php
else
	echo Load is not high
fi
