最近后臺(tái)經(jīng)常有打不開(kāi)的情況,和開(kāi)發(fā)溝通過(guò)問(wèn)題,但是開(kāi)發(fā)一直找不到解決辦法。
于是就寫(xiě)了一個(gè)監(jiān)控腳本當(dāng)某個(gè)頁(yè)面無(wú)法訪問(wèn)的時(shí)候,自動(dòng)對(duì)tomcat進(jìn)行重啟
以下是腳本的具體內(nèi)容,我使用了nagios nrpe中自帶的一款插件進(jìn)行檢測(cè),以下
是具體的檢測(cè)腳本內(nèi)容:
vim check_http.sh
#!/bin/bash
DATETIME=`date +"%Y_%m_%d_%H_%M"`
HTTPOK=`/usr/local/nagios/libexec/check_http -H test.test.com -p 8081 -u /ls.jsp |awk '{print$2}'`
if [ $HTTPOK = "OK:" ];then
echo "$DATETIME HTTP is OK" >>/tmp/http
else
echo "$DATETIME HTTP is CRITICAL" >>/tmp/http
/bin/sh /var/shell/restart_tomcat.sh
fi
restart_tomcat.sh 腳本內(nèi)容:
#!/bin/bash
. /etc/profile
tomcatPath_stop="data/tomcat/bin/shutdown.sh"
tomcatPath_start="data/tomcat/bin/startup.sh"
$tomcatPath_stop && sleep 6 && $tomcatPath_start
本文名稱(chēng):使用Nagios插件檢測(cè)HTTP狀態(tài)
網(wǎng)址分享:
http://weahome.cn/article/jsjcds.html