#!/bin/bash
PATH=/usr/bin:/bin:$PATH
EG_BIN=/opt/egurkha/bin
export EG_BIN PATH
Check=`/opt/egurkha/NetFlow/bin/xvt /opt/egurkha/NetFlow/bin/stop_netflowd`
export Check
if [ $Check = "FALSE" ]
then
echo "The eG NetFlow collector must be run by the eG user. Exiting ..."
exit
fi
#============================================================================
# stop_netflowd: shell script that stops NetFlow collector 
#============================================================================

pid_list=`ps -e -o pid,args | grep -i "NetFlow" | grep -v "grep" | grep -v "stop_netflowd"| awk '{print $1}'`

#get the list of pids 
if [ "$pid_list" ] 	# if NetFlow collector is running
then
	for pid in $pid_list    # for each pid
	do
		# kill each child
		kill -9 $pid #> /dev/null 2>&1 
		#z=1
	done
fi
#if z 
#if [$1]
echo "------------------------------------------------"
echo "NetFlow collector has been stopped successfully."
echo "------------------------------------------------"
#fi 