#!/bin/sh # # Copyright (C) 2004 Sergey Y. Afonin # License: none # You can use, redistribute and modify it without any limitations # # This script is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY. # # clamd specific (based on clamd log) # cron string: # 05 5 * * * root /usr/local/bin/virusstat-total # # v 0.3 2005-02-15 # fix: add "grep -v LibClamAV" # # v 0.2 2004-12-?? # fix: change regexp for sed # # v 0.1 2004-10-02 # initial release # # !!! Be sure that clamd.log rotated daily PATH="/root/bin:/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin" export PATH CAT='bzcat' LOG='/var/log/clamav/clamd.log.1.bz2' SERVER='AV Server' VIRADMINS='root@localhost,postmaster@localhost' ALLVIR=`bzcat $LOG |grep FOUND|grep -v LibClamAV|wc -l` (echo Summary: $ALLVIR viruses was blocked yesterday. && echo &&\ echo Statistic by virus names: && echo &&\ $CAT $LOG |grep FOUND|grep -v LibClamAV|\ sed -e 's/^.*->.*: \(.*\) FOUND/\1/'|\ sort|uniq -c|sort -r &&\ echo && echo "Scanned by ClamAV Antivirus (http://www.clamav.net/)")|\ mail -s "Virus Statistic total on $SERVER" $VIRADMINS