Process Monitoring Script

I need a script on Solaris 10 OS to monitor 3 seperate processes running. Each process has 3 of the same processes running a total of 9 processes and I need the ability to know if all of processes for each process is running and to email me if they aren't running. I'm new to Unix programming and need some expert help.

Here is my test script. I need some syntax assistance. Need someone to look at script and tell me where my errors are and how it could be written better. thx

#!/bin/ksh
while true;
do
isRunning=`ps -ef | grep -v grep | grep FAME | wc -l`
if [ $isRunning -eq 3 ]
then
echo "running"
else
echo "not running"
mailx -s "<Fame process not running correctly>" unixteam@xxx.com < /dev/null
isRunning1=`ps -ef | grep -v grep | grep exx | wc -l`
if [ $isRunning1 -eq 4 ]
then
echo "running"
else
echo "not running"
mailx -s "<exx process not running correctly>" unixteam@xxx.com < /dev/null
isRunning2=`ps -ef | grep -v grep | grep history | wc -l`
if [ $isRunning2-eq 3 ]
then
echo "running"
else
echo "not running""
mailx -s "<History process not running correctly>" unixteam@xxx.com < /dev/null
fi
done.

You left out a few 'fi' statements and had one too many double quotes on one of the echo commands:

#!/bin/ksh
while true ; do
  isRunning=`ps -ef | grep -v grep | grep FAME | wc -l`
  if [ $isRunning -eq 3 ]
    then
      echo "running"
    else
      echo "not running"
      mailx -s "Fame process not running correctly" unixteam@xxx.com < /dev/null
  fi

  isRunning1=`ps -ef | grep -v grep | grep exx | wc -l`
  if [ $isRunning1 -eq 4 ]
    then
      echo "running"
    else
      echo "not running"
      mailx -s "exx process not running correctly" unixteam@xxx.com < /dev/null
  fi

  isRunning2=`ps -ef | grep -v grep | grep history | wc -l`
  if [ $isRunning2 -eq 3 ]
    then
      echo "running"
    else
      echo "not running"
      mailx -s "History process not running correctly" unixteam@xxx.com < /dev/null
  fi
done

Otherwise, it should work, but not tested.

Works Great now! Thanks for you assistance!

No problem. For future reference, run 'ksh -n scriptname.sh' to check your scripts for syntax errors. Same option works for bash shell too.

Cheers,