How to install Clamdwatch...


Grab the latest version

____SNIP____
$ wget http://mikecathey.com/code/clamdwatch/clamdwatch.txt
--09:18:09--  http://mikecathey.com/code/clamdwatch/clamdwatch.txt
           => `clamdwatch.txt'
Resolving mikecathey.com... done.
Connecting to mikecathey.com[66.58.25.29]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3,128 [text/plain]
100%[============================>] 3,128          2.98M/s    ETA 00:00

09:18:09 (2.98 MB/s) - `clamdwatch.txt' saved [3128/3128]
____SNIP____


Make it executable

____SNIP____
$ chmod +x clamdwatch.txt 
____SNIP____ 


Change the name to something reasonable.

____SNIP____
$ mv clamdwatch.txt clamdwatch.pl  
____SNIP____ 


Make sure the path to perl is right.

____SNIP____ 
$ which perl
/usr/local/bin/perl
$ head -1 clamdwatch.pl 
#!/usr/local/bin/perl -w
____SNIP____


Make sure the socket variable ($Socket) is correct. Make
it match the clamav.conf value. Clamdwatch 0.7test1 supports
connecting to clamd via TCP socket.  If you're using a TCP
socket, make the socket variable = 3310 (or the like)

____SNIP____  You'll get more than 2 matches, ignore the rest...
# grep Socket /etc/clamav/clamav.conf clamdwatch.pl    
/etc/clamav/clamav.conf:LocalSocket /var/amavis/clamd
clamdwatch.pl:my $Socket = "/var/amavis/clamd";
____SNIP____

Make cron run the script. Add something like this to your crontab
The -q switch makes clamdwatch.pl not print "Clamd Running" if
everything is ok.

You'll need to adjust this a bit if your OS doesn't have killall, 
make sure the path to the clamd socket is right, and make sure
the path to the clamd init script is right.

____SNIP____ add to /etc/crontab or the like
*/1 *   * * * root      /usr/local/bin/clamdwatch.pl -q && ( /usr/bin/killall -9 clamd; rm -fr /var/amavis/clamd; /etc/init.d/clamav-daemon start 2>&1 )
____SNIP____

NOTES: This could create problems if your virus db is somehow corrupt
and cause clamd to be killed and restarted every minute.
