1 Star 0 Fork 111

chenjs/MySQLMTOP

forked from 茹憶/MySQLMTOP 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mtopd.py 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
ruzuojun 提交于 2017-07-28 15:36 . 代码目录结构重新调整和优化
#!/bin/env python
#coding:utf-8
import os, sys, string, time, datetime, traceback;
from multiprocessing import Process;
import global_functions as func
def job_run(script_name,times):
while True:
os.system("python "+script_name)
time.sleep(int(times))
def main():
print("%s: controller started." % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),))
monitor = func.get_option('monitor')
monitor_status = func.get_option('monitor_status')
monitor_replication = func.get_option('monitor_replication')
monitor_process = func.get_option('monitor_process')
alarm = func.get_option('alarm')
frequency_monitor = func.get_option('frequency_monitor')
frequency_alarm = func.get_option('frequency_alarm')
kill_process = func.get_option('kill_process')
joblist = []
if monitor=="1":
if monitor_status=="1":
job = Process(target = job_run, args = ('check_mysql_status_ext.py',frequency_monitor))
joblist.append(job)
job.start()
job = Process(target = job_run, args = ('check_mysql_status.py',frequency_monitor))
joblist.append(job)
job.start()
if monitor_replication=="1":
job = Process(target = job_run, args = ('check_mysql_replication.py',frequency_monitor))
joblist.append(job)
job.start()
if monitor_process=="1":
job = Process(target = job_run, args = ('check_mysql_process.py',4))
joblist.append(job)
job.start()
if alarm=="1":
job = Process(target = job_run, args = ('alarm_mysql.py',frequency_alarm))
joblist.append(job)
job.start()
if kill_process=="1":
job = Process(target = job_run, args = ('admin_mysql_kill_process.py',3))
joblist.append(job)
job.start()
for job in joblist:
job.join();
print("%s: controller finished." % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),))
if __name__ == '__main__':
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/chenjs50224274/MySQLMTOP.git
git@gitee.com:chenjs50224274/MySQLMTOP.git
chenjs50224274
MySQLMTOP
MySQLMTOP
master

搜索帮助