access_log=`cat /usr/local/nginx/logs/access.log |tr -s " " : |cut -d: -f1 |sort |uniq -c |awk '{print $1,$2}' > /tmp/acc.txt`
echo "今日总访问数量 : `cat /usr/local/nginx/logs/access.log |wc -l`"
echo -e "\n\t"
echo "##########################################################################*"
cat /tmp/acc.txt |egrep -w "^[0-9]{4,}"
if [ $? -eq 0 ];then
echo "有攻击嫌疑的ip,需要处理"
else
echo "状态正常"
fi
echo "##########################################################################*"
#!/bin/bash
echo "请将镜像文件放在/opt/目录下,并将镜像名字复制"
sleep 5
cd /etc/yum.repos.d/
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
def_ls=`ls /etc/yum.repos.d`
if [ "bak" = "$def_ls" ] ;then
echo "start curl 'aliyun.yum'"
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
else
exit
fi
sed -i 's/SELINUX=enforcing/SELINUX=disable/' /etc/selinux/config
systemctl stop firewalld
def_selinux=`cat /etc/selinux/config |egrep "^SELINUX=disable$"`
if [ "$def_selinux" = "SELINUX=disable" ];then
yum -y install libvirt* virt* qemu-kvm*
echo "strt yum_install libvirt* virt* qemu-kvm*"
if [ $? -eq 0 ] ;then
echo " install Ok"
else
echo " install not ok"
exit
fi
fi
systemctl start libvirtd
read -p "your creat number? : " def_read
read -p "cdrom_name : " def_cdrom
i=1
while [ "$i" -le "$def_read" ]
do
n=`cat /dev/urandom | tr -dc a-z0-9_ | head -c3 | sed 's/[ \r\b]//g'`
virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name {Centos7.$n} --memory 1024 --vcpus 1 --disk /opt/{centos2.$n}.raw,format=raw,size=10 --cdrom "/opt/$def_cdrom" --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole
let i++
echo "已经创建成功1台虚拟机"
done
echo "全部创建成功"