Simple bash script check services if are running

#!/bin/sh
#/etc/rc.d/init.d/checkservice
################ Check MySQL #################
RESTART="/script/restart-all-services or some"
Fail2BAN="/etc/rc.d/init.d/fail2ban restart"
LOGFILE=/var/log/raport.log
SERVICE='mysqld'
hostName=`echo $HOSTNAME | awk 'BEGIN { FS = "." } ; { print $2 }'`
eMail=" some email address"
raport="/var/log/raport.log"
#sendrap= `echo cat $raport`| `mailx -s 'Vps-'$hostName'-Service-check' $eMail`

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is OK" 
else
    echo `date` >> $LOGFILE
    echo "$SERVICE is not running, restarting $SERVICE" >> $LOGFILE
        checkmysql=`ps ax | grep -v grep | grep -c mysqld`
                if [ $checkmysql -le 0 ]
                then
                        $RESTART
			sendrap= `echo cat $raport`| `mailx -s 'Vps-'$hostName'-Service-check' $eMail`
                                if ps ax | grep -v grep | grep $SERVICE > /dev/null
                                then
                            echo "$SERVICE service is now restarted, everything is OK" 
			        fi
                fi
fi

############### Check Apache ################
SERVICE='httpd'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is OK" 
else
    echo `date` >> $LOGFILE
    echo "$SERVICE is not running, restarting $SERVICE" >> $LOGFILE
        checkapache=`ps ax | grep -v grep | grep -c httpd`
                if [ $checkapache -le 0 ]
                then
                        $RESTART
			sendrap= `echo cat $raport`| `mailx -s 'Vps-'$hostName'-Service-check' $eMail`
                                if ps ax | grep -v grep | grep $SERVICE > /dev/null
                then
                            echo "$SERVICE service is now restarted, everything is OK"
			     
                                fi
                fi
fi

############### Check Nginx ####################
SERVICE='nginx'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is OK" 
else
    echo `date` >> $LOGFILE
    echo "$SERVICE is not running, restarting $SERVICE" >> $LOGFILE
        checknginx=`ps ax | grep -v grep | grep -c nginx`
                if [ $checknginx -le 0 ]
                then
                        $RESTART
			sendrap= `echo cat $raport`| `mailx -s 'Vps-'$hostName'-Service-check' $eMail`
                                if ps ax | grep -v grep | grep $SERVICE > /dev/null
                                then
                            echo "$SERVICE service is now restarted, everything is OK" 
                                fi
                fi
fi


############### Check PHP ####################
SERVICE='php-fpm'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is OK" 
else
    echo `date` >> $LOGFILE
    echo "$SERVICE is not running, restarting $SERVICE" >> $LOGFILE
        checkphp=`ps ax | grep -v grep | grep -c php`
                if [ $checkphp -le 0 ]
                then
                        $RESTART
			sendrap= `echo cat $raport`| `mailx -s 'Vps-'$hostName'-Service-check' $eMail`
                                if ps ax | grep -v grep | grep $SERVICE > /dev/null
                                then
                            echo "$SERVICE service is now restarted, everything is OK" 
                                fi
                fi
fi


############### Check Qmail ####################
SERVICE='qmail'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is OK" 
else
    echo `date` >> $LOGFILE
    echo "$SERVICE is not running, restarting $SERVICE" >> $LOGFILE
        checkqmail=`ps ax | grep -v grep | grep -c qmail`
                if [ $checkqmail -le 0 ]
                then
                        $RESTART
			sendrap= `echo cat $raport`| `mailx -s 'Vps-'$hostName'-Service-check' $eMail`
                                if ps ax | grep -v grep | grep $SERVICE > /dev/null
                                then
                            echo "$SERVICE service is now restarted, everything is OK" 
                                fi
                fi
fi

################ Check Fail2Ban #################
SERVICE='fail2ban'

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is OK" 
else
    echo `date` >> $LOGFILE
    echo "$SERVICE is not running, restarting $SERVICE" >> $LOGFILE
        checkfail2ban=`ps ax | grep -v grep | grep -c fail2ban`
                if [ $checkfail2ban -le 0 ]
                then
                        $Fail2BAN
			sendrap= `echo cat $raport`| `mailx -s 'Vps-'$hostName'-Service-check' $eMail`
                                if ps ax | grep -v grep | grep $SERVICE > /dev/null
                                then
                            echo "$SERVICE service is now restarted, everything is OK" 
                                fi
                fi
fi
######################END############################

exit 0


------------------------------------------------------------------
then in crontab at every two minute
*/2 *  * * * root /etc/rc.d/init.d/checkservice