#!/bin/sh
# User editable settings
service_name="spamd" # Set to name of the running service.
start_command=$(/usr/bin/spamd -d -c -m 5) # Set to the start command of the service your monitoring.
mail_command=$(/usr/bin/exim) # Set to the path of your email program. Shouldnt need editing.
email="[email protected]" # Change to your email address.
################ DONT TOUCH ##################
COUNT=$(ps xua | grep -v grep | grep -c $service_name)
if [ "$COUNT" -eq "0" ]; then
# The command used to start the service.
$start_command
sleep 3
COUNT=$(ps xua | grep -v grep | grep -c $service_name)
if [ "$COUNT" -eq "0" ]; then
echo -e "Subject: $service_name is down.\n\n$service_name is down.\n\n" | $mail_command $email
fi
fi
exit 0