4 Star 25 Fork 544

zhiyoucai / Lepus

forked from 茹憶 / Lepus 
Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
lepus.py 1.90 KB
Copy Edit Web IDE Raw Blame History
#!/bin/env python
# coding:utf-8
from multiprocessing import Process
import include.functions as func
import os
import sys
import string
import time
import datetime
import logging
import logging.config
log_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'etc/logger.ini')
logging.config.fileConfig(log_file_path)
logger = logging.getLogger("lepus")
path = './include'
sys.path.insert(0, path)
def job_run(script_name, times):
while True:
os.system("python "+script_name+".py")
time.sleep(int(times))
def main():
logger.info("lepus controller start.")
monitor = str(func.get_option('monitor'))
monitor_mysql = str(func.get_option('monitor_mysql'))
monitor_oracle = str(func.get_option('monitor_oracle'))
monitor_os = str(func.get_option('monitor_os'))
alarm = str(func.get_option('alarm'))
frequency_monitor = func.get_option('frequency_monitor')
frequency_monitor_alarm = int(frequency_monitor)+10
joblist = []
if monitor == "1":
if monitor_mysql == "1":
job = Process(target=job_run, args=(
'check_mysql', frequency_monitor))
joblist.append(job)
job.start()
time.sleep(3)
if monitor_oracle == "1":
job = Process(target=job_run, args=(
'check_oracle', frequency_monitor))
joblist.append(job)
job.start()
time.sleep(3)
if monitor_os == "1":
job = Process(target=job_run, args=('check_os', frequency_monitor))
joblist.append(job)
job.start()
time.sleep(3)
if alarm == "1":
job = Process(target=job_run, args=(
'alarm', frequency_monitor_alarm))
joblist.append(job)
job.start()
for job in joblist:
job.join()
logger.info("lepus controller finished.")
if __name__ == '__main__':
main()

Comment ( 0 )

Sign in for post a comment

Python
1
https://gitee.com/zhiyoucai/Lepus.git
git@gitee.com:zhiyoucai/Lepus.git
zhiyoucai
Lepus
Lepus
master

Search