예제 #1
0
def main():
    log_level="debug"
    log_config=global_logs.CLogConfig(level=log_level)
    log_name="./log/redis_data_back.log"
    log_config._path="%s.%s"%(log_name,func_time.today())
    log=global_logs.initLog(log_config,logmodule="back")
    if log == None:
        print "init data back log error!"

    log.info("backup data begin...")
    backup_data(log)
    log.info("delete old backup data")
    delete_old_data(log)
    log.info("backup data end...")
예제 #2
0
def main():
    log_level = "info"
    log_config = global_logs.CLogConfig(level=log_level)
    log_name = "./log/check_redis_status.log"
    log_config._path = "%s.%s" % (log_name, func_time.today())
    log = global_logs.initLog(log_config, logmodule="status")
    if log == None:
        print "init log error!"

    servers = func.mysql_query(
        "select id,host,port,passwd,application_id,status from servers where is_delete=0;"
    )
    frequency_monitor = func.get_option('frequency_monitor')
    if servers:
        #print("servers %s" %(servers,));
        log.info("check_mysql_status controller started...")
        init_table()
        plist = []
        for row in servers:
            server_id = row[0]
            host = row[1]
            port = row[2]
            passwd = row[3]
            application_id = row[4]
            status = row[5]
            if status <> 0:
                p = Process(target=check_redis_status,
                            args=(host, port, passwd, server_id,
                                  application_id, frequency_monitor, log))
                plist.append(p)
                p.start()

        for p in plist:
            p.join()
        #set replication delay
        sql = "delete from redis_replication_last;"
        func.mysql_exec(sql, '')
        sql = "insert into redis_replication_last select * from redis_replication;"
        func.mysql_exec(sql, '')
        sql = "update redis_replication a,redis_replication_last b,servers c set a.delay=b.master_repl_offset-a.slave_repl_offset where a.master_host=c.host and a.master_port=c.port and b.server_id=c.id and a.is_slave=1 and b.is_master=1;"
        func.mysql_exec(sql, '')
        log.info("check_mysql_status controller finished...")
예제 #3
0
def main():
    log_level="info"
    log_config=global_logs.CLogConfig(level=log_level)
    log_name="./log/check_redis_status.log"
    log_config._path="%s.%s"%(log_name,func_time.today())
    log=global_logs.initLog(log_config,logmodule="status")
    if log == None:
        print "init log error!"

    servers=func.mysql_query("select id,host,port,passwd,application_id,status from servers where is_delete=0;")
    frequency_monitor = func.get_option('frequency_monitor')
    if servers:
	 #print("servers %s" %(servers,));
         log.info("check_mysql_status controller started..." );
         init_table()
         plist = []
         for row in servers:
             server_id=row[0]
             host=row[1]
             port=row[2]
             passwd=row[3]
             application_id=row[4]
             status=row[5]
             if status <> 0:
		 p = Process(target = check_redis_status, args = (host,port,passwd,server_id,application_id,frequency_monitor,log))
                 plist.append(p)
                 p.start()

         for p in plist:
             p.join()
         #set replication delay
         sql="delete from redis_replication_last;"
         func.mysql_exec(sql,'')
         sql="insert into redis_replication_last select * from redis_replication;"
         func.mysql_exec(sql,'')
         sql="update redis_replication a,redis_replication_last b,servers c set a.delay=b.master_repl_offset-a.slave_repl_offset where a.master_host=c.host and a.master_port=c.port and b.server_id=c.id and a.is_slave=1 and b.is_master=1;"
         func.mysql_exec(sql,'')
         log.info("check_mysql_status controller finished..." )
예제 #4
0
#!/usr/bin/env python
#-*-coding:utf-8-*-
import os
import subprocess
import time
import datetime
import global_logs
from datetime import *
import global_functions as func
import global_time as func_time

log_level="debug"
log_config=global_logs.CLogConfig(level=log_level)
log_name="./log/alarm_redis.log"
log_config._path="%s.%s"%(log_name,func_time.today())
log=global_logs.initLog(log_config,logmodule="alarm")
if log == None:
    print "init data back log error!"

def getTimeInterVal(t_convergent_type,t_alarm_interval,t_alarm_num,t_alarm_strike_time):
	if t_convergent_type==0:
		return t_alarm_strike_time+t_alarm_interval*t_alarm_num
        elif t_convergent_type==1:
		return t_alarm_strike_time+t_alarm_interval*(t_alarm_num*(t_alarm_num+1))/2
        elif t_convergent_type==2:
		return int(t_alarm_strike_time+t_alarm_interval*(2**t_alarm_num-1))
        elif t_convergent_type==3:       
		return int(t_alarm_strike_time+t_alarm_interval*(t_alarm_interval**t_alarm_num-1)/(t_alarm_interval-1))
        else:
		#convergent_type error! not in (0 1 2 3)
		return 0
예제 #5
0
#!/usr/bin/env python
#-*-coding:utf-8-*-
import os
import subprocess
import time
import datetime
import global_logs
from datetime import *
import global_functions as func
import global_time as func_time

log_level = "debug"
log_config = global_logs.CLogConfig(level=log_level)
log_name = "./log/alarm_redis.log"
log_config._path = "%s.%s" % (log_name, func_time.today())
log = global_logs.initLog(log_config, logmodule="alarm")
if log == None:
    print "init data back log error!"


def getTimeInterVal(t_convergent_type, t_alarm_interval, t_alarm_num,
                    t_alarm_strike_time):
    if t_convergent_type == 0:
        return t_alarm_strike_time + t_alarm_interval * t_alarm_num
    elif t_convergent_type == 1:
        return t_alarm_strike_time + t_alarm_interval * (t_alarm_num *
                                                         (t_alarm_num + 1)) / 2
    elif t_convergent_type == 2:
        return int(t_alarm_strike_time + t_alarm_interval *
                   (2**t_alarm_num - 1))
    elif t_convergent_type == 3: