#!/bin/sh

# This script will start Egurkha DB2 monitoring script

EG_HOME=/opt/egurkha
export EG_HOME
db2user=`id |awk '{print$1}'|cut -d "(" -f2|cut -d ")" -f1`
val=`ps -e -o pid,user,args| grep runEgPerfmonitor |grep $db2user| grep -v grep | wc -l`

if [ $val -gt 0 ]
then
	echo "**************************************************************"
	echo " "
	echo "Trying to stop the eG DB2 Monitoring ........"
	echo " "
	sleep 1
	run_pid=`ps -e -o user,pid,args |grep runEgPerfmonitor|grep $db2user |grep -v grep|awk '{print$2}'`				
	# This process is running kill it
	kill -9 $run_pid
	sleep 1
	
	echo "The eG DB2 Monitor was stopped sucessfully !"
	echo ""
	echo "**************************************************************"
	
else		
	
	echo "**************************************************************"	
	echo ""
	echo "The eG DB2 Monitor is not running yet !"
	echo ""
	echo "**************************************************************"	
fi	
