ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux_扫描应用程序端口,发现不能wget页面,就发送邮件通知

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

原创 Linux操作系统 作者:wangzhensheng 时间:2009-11-13 18:49:46 0 删除 编辑

#!/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秒)"<$mess $email -- -f 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博客 ” ,链接:https://blog.itpub.net/8806316/viewspace-1028706/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-01-02

  • 博文量
    137
  • 访问量
    260335