#bin/bash

. /etc/profile

#set mail message
title_msg=Clamav每日杀毒
#mail reciver
recipient=
#projectname
project=
#scandir
check_list=
logfile=/tmp/2.log

#get today time
Today=`date  +"%Y.%m.%d"`

#check clamav everyday work
echo "" > $logfile
/data/clamav/bin/clamscan -r --bell -i $check_list -l $logfile
result=`grep -rn "Infected files" $logfile |awk -F ': ' '{print $2}'`
server_ip=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|grep -v Bcast:0.0.0.0|awk '{print $2}'|tr -d "addr:"`
res_file=`cat $logfile`
if [ "$result" == 0 ];then
    echo bufa
else
    echo -e " project:$project \n 扫描时间:$Today \n 服务器IP:$server_ip \n 扫描结果:扫描发现有病毒文件,请管理员关注!\n\n 具体内容如下:\n $res_file" | mail -s "$title_msg" $recipient
    echo fa
fi

发表回复

您的电子邮箱地址不会被公开。

Captcha Code