Simple bash snippet to check if a service is running, if not -> send a mail to root. In this snippet
#!/bin/sh
SERVICE=apache2;
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "$SERVICE service running, everything is fine"
else
echo "$SERVICE is not running, try to start it."
sudo service $SERVICE start
echo "$SERVICE is not running!" | mail -s "$SERVICE down" root
fi