#!/usr/bin/python
#-*- coding: utf-8 -*-
import paramiko
import os
import commands
import time
os.environ['PATH'] = '$PATH:$HOME/bin:/veris/usr/bin:/veris/usr/sbin'
os.environ['LD_LIBRARY_PATH'] = '/veris/usr/lib64:$LD_LIBBRARY_PATH'
port=5320
veris_name="billing"
error_file="/veris/%s/mysql/%d/log/error/error_%d.log" % (veris_name,port,port)
if os.path.isfile(error_file):
if "mysqld restarted" in open(error_file).read():
check_mysql_cmd = "mysqladmin -h127.0.0.1 -P%d -uroot -pxxxxxx ping 2>/dev/null" % port
try:
is_up=commands.getoutput(check_mysql_cmd)
except Exception, err1:
print err1
if is_up == "mysqld is alive":
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("10.1.196.90",22,"aibilling", "123456")
try:
stdin, stdout, stderr = ssh.exec_command("srm")
except Exception, err2:
print err2
print stdout.read()
ssh.close()
error_path=os.path.dirname(error_file)
error_name=os.path.basename(error_file)
os.rename(error_file,error_path + os.sep + "bak" + os.sep + time.strftime('%Y%m%d.%H%M.') + error_name)
版权声明:QQ:597507041