PHP-FPM監控shell

!/bin/bashphp


#監控的網頁地址
url="http://dev2.jwsmed.com"bash

#fastcgi啓動/重啓/中止腳本路徑
PROG=/data/fistsoft/php/sbin/php-fpmcurl

#fastcgi重啓記錄日誌文件
LOG=/data/services/logs/php_5525/restart.logphp-fpm

#返回結果正常記錄日誌
LOG2=/data/services/logs/php_5525/check.logui

#時間
time=`date`url

#取得http狀態碼
status=$(curl -H "dev2.jwsmed.com" -m 5 -L -s -w %{http_code} http://127.0.0.1 -o /dev/null)rest

#若是不是200,就寫入日誌,而後從新啓動
if [ "$status" != "200" ]; then
echo "=============$(date) Return code $status,pgp-fpm had been restarted===========" >> $LOG
$PROG
else
#記錄正常狀態的日誌
echo "php-fpm is running ${time} ===========^-^============^-^" >> $LOG2
fi日誌

*/1 * * * * /bin/bash /usr/local/sbin/php-fpm_check.sh

#!/bin/bash
#check php-fpm server up/down
TelLog=/tmp/telphp.log
while :
do
sleep 15;
/usr/bin/telnet 127.0.0.1 9001 << ! > $TelLog
quit
!
SOK=`cat $TelLog | grep "Escape character" |wc -l`
if [ $SOK -eq 1 ];then
echo "php-fpm is ok"
else
/data/fistsoft/php/sbin/php-fpm &
fi
donecode

相關文章
相關標籤/搜索