linux_掃描應用程式埠,發現不能wget頁面,就傳送郵件通知

wangzhensheng發表於2009-11-13

#!/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秒)"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 } >/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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章