Shell腳本監(jiān)控網(wǎng)站頁面正常打開情況
現(xiàn)在單位為了省錢,我用了shell腳本,簡單的寫了一個(gè)監(jiān)控。通過curl一個(gè)固定頁面的200狀態(tài)碼,如果是200,就說網(wǎng)站是正常的,如果不是200就自動(dòng)重啟網(wǎng)站,然后發(fā)郵件到QQ郵箱。自己在上QQ的同時(shí),通過微信也可以收到報(bào)警,不但可以收到報(bào)警,還可以解決問題?;旧弦部梢越鉀Qweb的故障。
#! /bin/bash
source /etc/profile
A="web is Good !"
ip=`ifconfig eth0 | grep "inet addr" | awk -F "[: ]+" '{print $4}'`
tt1=`curl -I -s http://xx.8x.18x.xx:1657/product/pro_detail_-rg000785.shtml | head -1 | cut -d " " -f2`
Process=`ps -ef | grep java | egrep "tomcat1" | awk -F " " '{print $2}'`
if [ $tt1 = "200" ]
then
echo "$A" >>/home/taoyake/scripts/website-error.`date +%F`.log
else
/opt/tomcat1/bin/shutdown.sh
cd /opt/tomcat1/work/Catalina/
rm -rf localhost
kill -9 $Process
/opt/tomcat1/bin/startup.sh
echo "1657 is reload." >>/home/taoyake/scripts/website-error.`date +%F`.log
echo "1657 is reload." | mail -s "website-1657" "505065674@qq.com"
fi
more /home/taoyake/scripts/reload_website-1658.sh
#! /bin/bash
source /etc/profile
B="1658 is Good !"
ip=`ifconfig eth0 | grep "inet addr" | awk -F "[: ]+" '{print $4}'`
tt1=`curl -I -s http://xx.xx.183.xx:1658/product/pro_detail_-rg000785.shtml | head -1 | cut -d " " -f2`
Process=`ps -ef | grep java | egrep "tomcat2" | awk -F " " '{print $2}'`
if [ $tt1 = "200" ]
then
echo "$B" >>/home/taoyake/scripts/website-1658-access.`date +%F`.log
else
/opt/tomcat2/bin/shutdown.sh
cd /opt/tomcat2/work/Catalina/
rm -rf localhost
kill -9 $Process
/opt/tomcat2/bin/startup.sh
echo "1658 is reload." >>/home/taoyake/scripts/website-1658-error.`date +%F`.log
echo "1658 is reload." | mail -s "website-1658" "505065674@qq.com"
fi
[root@web ~]# crontab -l
*/10 * * * * /usr/sbin/ntpdate time.windows.com >/dev/null 2>&1
*/5 * * * * /bin/sh /home/taoyake/scripts/reload_website.sh >/dev/null 2>&1
*/5 * * * * /bin/sh /home/taoyake/scripts/reload_website-1658.sh >/dev/null 2>&1

相關(guān)文章
shell批量curl接口腳本的簡單實(shí)現(xiàn)方法
這篇文章主要跟大家介紹了關(guān)于shell批量curl接口腳本的簡單實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用shell具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-08-08
shell實(shí)現(xiàn)自動(dòng)adsl撥號并檢測連接狀況腳本分享
這篇文章主要介紹了shell實(shí)現(xiàn)自動(dòng)adsl撥號并檢測連接狀況腳本分享,本文給出了兩個(gè)腳本,一個(gè)是自動(dòng)撥號腳本,一個(gè)是檢測連接狀態(tài)腳本,需要的朋友可以參考下2014-12-12
shell腳本正則匹配文件中的Email并寫入到文件中代碼分享
有時(shí)我們會處理日志文件,或其他文本文件,并將里面含有的Email讀取出來,可以利用shell處理文件的方法來讀取2014-04-04
linux 中的ls命令參數(shù)詳解及l(fā)s命令的使用實(shí)例
這篇文章主要介紹了linux 中的ls命令參數(shù)詳解及l(fā)s命令的使用實(shí)例,需要的朋友可以參考下2017-08-08
關(guān)于使用shell腳本循環(huán)處理文本的問題
今天給大家普及關(guān)于使用shell腳本循環(huán)處理文本的問題,其實(shí)操作步驟很簡單,本文通過腳本實(shí)例給大家講解,感興趣的朋友跟隨小編一起看看吧2021-06-06

