Creating your own service monitor


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » System Level

Creating your own service monitorLast Modified: Sep 24, 2005, 7:32 pm
As of version 1.24.0, DA can now do this automactially for you.  See This Link.  However, the following code will still work, and should allow for more customizations if needed.

Many admins run extra pieces of software that DA does not check for, to make sure it's running.  This is a simple script that enables an admin to keep an eye on any extra software he's running.  In this example, we'll be checking on the spamd proram.  Replace the bold items with your own info where applicable.

#!/bin/sh
COUNT=`ps -ax | grep -v grep | grep -c spamd`
if [ $COUNT -eq 0 ]; then
            #the command used to start spamd
            /usr/bin/spamd -d -c -m 5
   
            sleep 3

            COUNT=`ps -ax | grep -v grep | grep -c spamd`
            if [ $COUNT -eq 0 ]; then
                         echo -e "Subject: spamd is downnnspamd is downn.\n\n" | /usr/sbin/exim your@email.com
            fi
fi
exit 0;

Thow that code into your own script file, chmod it to 755, then add a root cronojob to check on it as often as you like.  DA checks for services once per minute.   However, this script doesn't know if it just sent an email the previous minute, so if the service is still down, you'll get one email every minute ;)  So maybe every 5 or 10 minutes is sufficient.

2003 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST