def ping_monitor_task(): linuxInfo = ct.get_server_config('./config/server_ping_config.txt') try: ms = MonitorServer(linuxInfo) ms.ping_server_monitor() check_result_list = ms.ping_Check_flag_list if len(check_result_list)==0: check_result =False else: check_result = (sum(check_result_list)==len(check_result_list)) # print "check_result: ", check_result except Exception as e: check_result = False msg = str(e) logger.warning(msg) if check_result: logger.info("All Server is OK") else: msg = "服务器Ping值异常,请检查详细日志内容!" logger.warning(msg) # ct.send_sms_control("ping", msg) sysstr = platform.system() if sysstr == "Windows": ct.readTexts("Ping Monitor is Worning")
def fpga_task(): linuxInfo = ct.get_server_config('./config/fpga_config.txt') # linuxInfo = [['192.168.238.7', 22, 'trade', 'trade', 'tradeserver',/home/trade/FPGA']] try: ms = MonitorServer(linuxInfo) ms.fpga_monitor_run() check_result_list = ms.fpga_Check_flag_list logger.debug("check_result_list:") logger.debug(check_result_list) if len(check_result_list) == 0: check_result = False else: check_result = (sum(check_result_list) == len(check_result_list)) except Exception: check_result = False logger.error('Faild to check fpga!', exc_info=True) logger.info( "************************The FPGA File Monitor Result: ************************" ) if check_result: logger.info("OK,FPGA Server is OK") ct.send_sms_control("fpga", "OK:盘前FPGA文件检查正常") else: msg = "error:FPGA文件检查异常,请查看详细日志" logger.error(msg) # send_sms_control("fpga", "error:奇点服务器FPGA文件检查异常,请查看详细日志") sysstr = platform.system() if sysstr == "Windows": ct.readTexts("VIP Server is Worning")
def mem_monitor_task(): linuxInfo = ct.get_server_config('./config/server_status_config.txt') try: ms = MonitorServer(linuxInfo) ms.mem_monitor() check_result_list = ms.mem_Check_flag_list if len(check_result_list) == 0: check_result = False else: check_result = (sum(check_result_list) == len(check_result_list)) # print "check_result: ", check_result except Exception as e: check_result = False msg = str(e) logger.error(msg) logger.info( "************************The Monitor Result: ************************") if check_result: logger.info("All Server is OK") else: msg = "内存监控报警,请查看服务器详细信息" logger.error(msg) sysstr = platform.system() if sysstr == "Windows": ct.readTexts("Memory Monitor is Worning") ct.generate_file(check_result, 'Memory_Monitor')
def port_process_task(): linuxInfo = ct.get_server_config('./config/server_status_config.txt') try: ms = MonitorServer(linuxInfo) ms.socket_ps_monitor() check_result_list = ms.SocPs_Check_flag_list if len(check_result_list) == 0: check_result = False else: check_result = (sum(check_result_list) == len(check_result_list)) # print "check_result: ", check_result except Exception as e: check_result = False msg = str(e) logger.warning(msg) logger.info( "************************The Monitor Result: ************************") if check_result: logger.info("All Server is OK") else: msg = "端口和进程监控报警,请查看服务器详细信息!" logger.error(msg) sysstr = platform.system() if sysstr == "Windows": ct.readTexts("Port Process Monitor is Worning") ct.generate_file(check_result, 'Port_PS_Monitor')
def alltask(): linuxInfo = ct.get_server_config('./config/server_status_config.txt') try: ms = MonitorServer(linuxInfo) ms.monitor_run() check_result_list = ms.Check_flag_list # print "check_result_list:", check_result_list if len(check_result_list) == 0: check_result = False else: check_result = (sum(check_result_list) == len(check_result_list)) # print "check_result: ", check_result except Exception as e: check_result = False msg = str(e) logger.error(msg) logger.info( "************************The Monitor Result: ************************") if check_result: logger.info("All Server is OK") else: msg = "error: Basic Monitor is Worning, Please Check it!" logger.error(msg) # ct.fortunesms(msg) sysstr = platform.system() if sysstr == "Windows": ct.readTexts("Basic Monitor is Worning") # else: # ct.send_mail(msg,"Failed_Basic_Monitor") ct.generate_file(check_result, 'Basic_Monitor')
def common_monitor_task(task, single_handle, linuxInfo): #linuxInfo = ct.get_server_config('./config/server_status_config.txt') try: #single_handle = "core_file_info" ms = MonitorServer(linuxInfo, single_handle) task_monitor = ms.single_common_monitor task_monitor() check_result_list = ms.common_Check_flag_list if len(check_result_list)==0: check_result =False else: check_result = (sum(check_result_list)==len(check_result_list)) # print "check_result: ", check_result except Exception as e: check_result = False msg = str(e) logger.warning(msg) if check_result: msg = "OK,监控任务[%s]验证结果成功,All Server is OK!" % single_handle logger.info(msg) else: msg = task + "::" + single_handle + " 任务监控报警,请检查详细日志内容!" logger.warning(msg) # ct.send_sms_control("disk", msg) sysstr = platform.system() if sysstr == "Windows": ct.readTexts("Monitor task is Worning")
def fpgatask(): linuxInfo = ct.get_server_config('./config/fpga_config.txt') # linuxInfo = [['192.168.238.7', 22, 'trade', 'trade', 'tradeserver',/home/trade/FPGA']] try: ms = MonitorServer(linuxInfo) ms.fpga_monitor_run() check_result_list = ms.fpga_Check_flag_list logger.debug("check_result_list:") logger.debug(check_result_list) if len(check_result_list) == 0: check_result = False else: check_result = (sum(check_result_list) == len(check_result_list)) except Exception as e: check_result = False logger.error('Faild to check fpga!', exc_info=True) logger.info( "************************The FPGA File Monitor Result: ************************" ) if check_result: logger.info("FPGA Server is OK") else: msg = "error:FPGA is Exception, Please Check it!" logger.error(msg) # ct.fortunesms(msg) sysstr = platform.system() if sysstr == "Windows": ct.readTexts("VIP Server is Worning") # else: # ct.send_mail(msg,"Failed_FPGA_Monitor") ct.generate_file(check_result, 'FPAG_File_Monitor')