Shell脚本实现非法IP登陆自动报警
服务器的安全稳定是每个运维都希望达到的目标,毕竟网站一旦流量大了,访问高了,就会有一些无聊人来攻击,帮忙检测漏洞是好,但纯ddos的性质就很恶劣了.说远了,这篇文章只是检测有非法ip登录到服务器上就自动给运维报警,当然也可以改成短信报警,前提是你有短信网关.
#!/bin/bash #该脚本作用是检测是否有恶意IP登陆服务器并邮件报警 #可以结合139邮箱以达到短信及时通知到手机的功能 #适用系统centos5 Ldate=`which date` Lawk=`which awk` Llast=`which last` Lgrep=`which grep` Lsendmail=`which sendmail` Lifconfig=`which ifconfig` serverip=`$Lifconfig eth0|$Lgrep inet|$Lawk -F : '{print $2}'|$Lawk '{print $1}'` cutdate=`$Ldate |$Lawk '{print $1" "$2" "$3}'` hackerip=`$Llast|$Lgrep "$cutdate"|$Lawk '{print $3}'|$Lgrep -v 192.168.1x.xx` if [ -z $hackerip ] then exit else for logip in $hackerip do echo "hacker ip is $logip already login $serverip"|mail -s "SOS" rocdk890@139.com done fi
Shell脚本遍历目录并批量修改文件编码
在将windows上的jsp网页移植到linux环境中时,发现一个个的转换编码及修改默认编码类型太慢,写此脚本进行尝试文件遍历~好久不写,手生了。#!/bin/bash##
Shell脚本查看进程内存真实占用情况
#!/bin/bash#****************************************************************##ScriptName:pm#Author:osdba#CreateDate:2010-01-31#ModifyAuthor:#ModifyDate:2010-01-31#Function:showprocessesmemoryused#****
Shell脚本中判断变量为数字的3种方法
方法1:通过expr计算变量与一个整数值相加,如果能正常执行则为整数,否则执行出错,$将是非0的值expr$args+0&/dev/null方法2:打印变量通过sed替换的方式
标签:脚本,变量,遍历,整数,短信