From 1387e295918b5e58b00440f48ce1c88e5a8f6235 Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 28 Aug 2015 09:58:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3cpu=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=E8=BF=87=E5=A4=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- log_handler.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/log_handler.py b/log_handler.py index 199afe1cb..5e5e4f698 100644 --- a/log_handler.py +++ b/log_handler.py @@ -69,7 +69,7 @@ def run(): try: file_time = int(os.stat(log_path).st_ctime) now_time = int(time.time()) - if now_time - file_time > 18000: + if now_time - file_time > 10800: if psutil.pid_exists(pid): kill_pid(pid) set_finish(pid_id) @@ -77,7 +77,29 @@ def run(): except OSError: pass +#function erorcheck is added by Lin to resolve CPU filled issue 2015.08.24 + +def errorcheck(): + f=os.popen("ps auxr | grep -v auxr|sed -n 2p") + a=f.read().strip() + f.close() + pid=0 + try: + if a is not None: + b=a.split(" ") + if b[-1]=='/opt/jumpserver/connect.py' and b[-2]=='python' and b[-8]=='R' and int(b[-3].split(':')[0])>100: + for i,j in enumerate(b): + if i==0 or j=='': + continue + else: + pid=int(j) + break + kill_pid(pid) + except : + pass + if __name__ == '__main__': while True: run() time.sleep(5) + errorcheck()