欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

linux系統(tǒng)使用python監(jiān)控apache服務(wù)器進(jìn)程腳本分享

 更新時(shí)間:2014年01月15日 11:18:35   作者:  
這篇文章主要介紹了linux系統(tǒng)使用python監(jiān)控apache服務(wù)器進(jìn)程的腳本,大家參考使用吧

crtrl.py監(jiān)控Apache服務(wù)器進(jìn)程的Python 腳本

復(fù)制代碼 代碼如下:

!/usr/bin/env Python
import os, sys, time

while True:
time.sleep(4)
try:
ret = os.popen('ps -C apache -o pid,cmd').readlines()
if len(ret) < 2:
print "apache 進(jìn)程異常退出, 4 秒后重新啟動(dòng)"
time.sleep(3)
os.system("service apache2 restart")
except:
print "Error", sys.exc_info()[1]

設(shè)置文件權(quán)限為執(zhí)行屬性(使用命令 chmod +x crtrl.py),然后加入到/etc/rc.local 即可,一旦 Apache 服務(wù)器進(jìn)程異常退出,該腳本自動(dòng)檢查并且重啟。 簡(jiǎn)單說(shuō)明一下清單 5 這個(gè)腳本不是基于/proc 偽文件系統(tǒng)的,是基于 Python 自己提供的一些模塊來(lái)實(shí)現(xiàn)的 。這里使用的是 Python 的內(nèi)嵌 time 模板,time 模塊提供各種操作時(shí)間的函數(shù)。

相關(guān)文章

最新評(píng)論