Script to check processes and send an email

I searched through the forum and couldn't quite find what I was looking for. I have a script that looks for a process "DW" to be running. If it is not it will email a notice to an account. I would like to add the functionality to have it also email a seperate notice if there is more that one of the "DW" processes running at the same time. The script looks like:

#!/bin/ksh

DATE=$(date +%m%d%y)
TIME=$(date +%H%M)
RECIPIENT=test@mydomain.com

DPID=$(ps -ef | grep dw | grep -v grep)
if [ "${DPID}" = "" ]
   then
	echo "The data warehouse manager for DB $ORACLE is down at $TIME on $DATE" | mail -s "$ORACLEID DW is down" $RECIPIENT
fi
#!/bin/ksh

DATE=$(date +%m%d%y)
TIME=$(date +%H%M)
RECIPIENT=test@mydomain.com

DPID=$(ps -ef | grep "[d]w" | wc -l)
if [ "${DPID}" -eq 0 ]
   then
	echo "The data warehouse manager for DB $ORACLE is down at $TIME on $DATE" | mail -s "$ORACLEID DW is down" $RECIPIENT
elif [ "${DPID}" -gt 1 ]
  then
        echo "More than one instance of warehouse manager running" | mail -s "Multiple instances of warehouse manager" $RECIPIENT
fi