#!/bin/sh

PROG="doris"

while true; do
	mem_used=`ps -C $PROG u | grep -v RSS | awk '{print $6}'`
	mem_rate=`ps -C $PROG -o %mem | tail -1`
	#cpu_used=`ps -C $PROG -o %cpu | tail -1`
	#echo "`date` -- $PROG used mem : $mem_used, $mem_rate%, $cpu_used%" >> doris_kill_by_mem.log
	if [ -z $mem_used ]; then
		mem_used=0
	elif [ $mem_used -gt 102400000 ]; then
		echo "`date` -- $PROG used mem : $mem_used, $mem_rate%, kill it!" >> RESTART.log
		killall $PROG;
	fi
	
	sleep 10

done
