linux_扫描应用程序端口,发现不能wget页面,就发送邮件通知

#!/bin/sh
hosts="10.46.64.49 10.46.64.50"
ports="6001 6003 6005 6007"
#apps="/ /fmccehalladmin/ /fjheart/ /mzonehr/ /pay/ /service/ /fjzp/ /sitestat2/"
apps="/ /fjheart/ /mzonehr/ /pay/ /service/ /fjzp/ /sitestat2/"
status="status.jsp"

send_mail()
{
mess="$1"
cat /app/apache/bin/mail_list |grep -v '^#'|while read email
do
mail -s "fj mobile weblogic alert !!! $(date +%Y年%m月%d日 %H时%M分%S秒)"master@fj.chinamobile.com -F fjmaster
done
}


echo_ok()
{
h="$1"
p="$2"
a="$3"
printf "${h} $p $a :app and port is Avlive :) n"
}

echo_err()
{
h="$1"
p="$2"
a="$3"
printf "${h} $p $a :app or port is down !!! :( n"
printf "${h} $p $a :app or port is down !!! :( n" >>./.app_port.log
}

for h in $hosts
do
for p in $ports
do
for a in $apps
do
if [ $h = '10.46.64.49' ] && [ $p = "6003" ]
then
p="6003"
fi
if [ $a = "/sitestat2/" ]
then
status="index.jsp"
else
status="status.jsp"
fi
if wget http://${h}:${p}${a}${status} >/dev/null 2>&1
then
echo_ok ${h} $p $a
else
echo_err ${h} $p $a
fi
rm -rf ./${status}*
rm -rf ./failed.jsp*
#rm -rf ./index.jsp*
done
done
done
printf "app port scan over ... nnn"
cat ./.app_port.log

if [ -s ./.app_port.log ]
then
send_mail ./.app_port.log
else
echo "all application is ok"
fi
>./.app_port.log
rm -rf ./${status}*
rm -rf ./failed.jsp*
# rm -rf ./index.jsp*

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8806316/viewspace-1028706/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/8806316/viewspace-1028706/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值