file="/tmp/mp_utils_stop"
if [ "$1" = "" ]
then
echo "You must provide interval time!"
echo "ex: mp_util_start 2s"
echo "2s --> 2sec interval"
echo "ex: mp_util_start 1h"
echo "1h --> 2hour interval"
exit 1
fi
# If we find mp_utils_stop, which means mp_utils stopped
# So, we should not do any snapshot just comeout
# when we do mp_util start, lets delete this file.
if [ -f "$file" ]
then
rm -rf $file
MP_UTIL_STOP=no
fi

DNAME_FILE="/tmp/dname_file.txt"
mp_util -b --dname_show > "$DNAME_FILE"

echo "Enabling MP_UTIL for below Daemons and snapshot will be taken at $1 interval"
mp_util -c -m 1

filename="$DNAME_FILE"
while read -r line
do
    mp_util -m "$line"	
done < "$filename"

sleep 10
while [ "$MP_UTIL_STOP" != "yes" ]
do
if [ -f "$file" ]
then
        MP_UTIL_STOP=yes
fi
	echo "Taking a memory snapshot at" $(date)

	while read -r line
	do
		mp_util -e "$line"
	done < "$filename"
	sleep "$1"
done
 

