I had a problem with freshclam, I run it in daemon mode and for some reason it died. A couple of days passed before I realized this, and restarted it. This by itself its not that bad, although my virus signatures were out of date. :(

<plug>
I recently came across monit, a daemon that watches and optionally restarts user configured processes (http://www.tildeslash.com/monit/) which did the trick for me.
</plug>


I have the following init script to start freshclam at boottime (please lookout for line-wrap):

--BEGIN--
#!/bin/sh
#
# freshclam     This shell script takes care of starting and stopping
#               freshclam daemon
#
# chkconfig: 345 26 74
# description: freshclam updates ClamAV databases

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

RETVAL=0
OPTIONS="-d"
prog="freshclam"
pidfile="/var/run/freshclam.pid"
PATH=$PATH:/usr/local/bin

[ -x /usr/local/bin/freshclam ] || exit 0

start() {
# Start daemon.
echo -n $"Starting $prog: "
daemon $prog $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
[ $RETVAL -eq 0 ] && ps -eo pid,args |grep "$prog $OPTIONS" |awk '{print $1}' > $pidfile
return $RETVAL
}


stop() {
        # Stop daemons.
        echo -n $"Shutting down $prog: "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        [ $RETVAL -eq 0 ] && rm -f $pidfile
        return $RETVAL
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  condrestart)
        if [ -f /var/lock/subsys/$prog ]; then
            stop
            start
            RETVAL=$?
        fi
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

exit $RETVAL
--END--

Using this, I add the following configuration to monit:

--BEGIN--
# MONIT
check process freshclam
   with pidfile /var/run/freshclam.pid
   start program "/etc/init.d/freshclam start"
   stop  program "/etc/init.d/freshclam stop"
--END--

With this program, if the daemon dies, it is restarted automatically by the system and I get a mail message notifying me that the daemon was restarted.


-- Jorge Valdes Intercom El Salvador




------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Clamav-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/clamav-users

Reply via email to