def home(): if request.args.get('trace'): TRACE = request.args.get('trace') haap.get_trace(TRACE, trace_level_cfg) else: pass if mode == 'rt': StatusHAAP = haap_rt_info_to_show() StatusHAAP.sort(key=operator.itemgetter(0)) StatusSANSW = sansw_rt_info_to_show() StatusSANSW.sort(key=operator.itemgetter(0)) tlu_haap = s.time_now_to_show() tlu_sansw = s.time_now_to_show() status_warning = 0 elif mode == 'db': lstWarningList = db.get_unconfirm_warning() if request.method == 'GET' and lstWarningList: error = 1 else: db.update_warning() error = 0 engine = haap_info_to_show() sansw = sansw_info_to_show() status_warning = db.get_unconfirm_warning() if engine: tlu_haap = engine[0] StatusHAAP = engine[1] StatusHAAP.sort(key=operator.itemgetter(0)) else: tlu_haap = s.time_now_to_show() StatusHAAP = [0] if sansw: tlu_sansw = sansw[0] StatusSANSW = sansw[1] StatusSANSW.sort(key=operator.itemgetter(0)) else: tlu_sansw = s.time_now_to_show() StatusSANSW = [0] return render_template("monitor.html", Title_HAAP=lstDescHAAP, Title_SANSW=lstDescSANSW, tlu_haap=tlu_haap, tlu_sansw=tlu_sansw, status_haap=StatusHAAP, status_sansw=StatusSANSW, status_warning=status_warning, interval_web_refresh=interval_web_refresh)
def __init__(self, statusRT, statusDB, haap_Alias): self.alias = haap_Alias self.host = statusRT[0] self.statusRT = statusRT self.statusDB = statusDB self.strTimeNow = s.time_now_to_show() self.lstWarningToSend = []
def sansw_judge(total_RT, total_DB, sansw_IP, sansw_Alias): strTimeNow = s.time_now_to_show() if (total_DB != None) and (total_RT != None): intErrorIncrease = total_RT - total_DB intWarninglevel = s.is_Warning(intErrorIncrease, tuplThresholdTotal) if intWarninglevel: msg = warning_message_sansw(intWarninglevel) db.insert_warning(strTimeNow, sansw_IP, 'switch', intWarninglevel, msg, 0) se.send_warnmail( [[strTimeNow, sansw_IP, sansw_Alias, intWarninglevel, msg]])
def uptime_second(self): uptime_list = self.uptime_list() time_show = s.time_now_to_show() if uptime_list: intSecond = 0 # d, h, m, s means days hours minutes seconds d = uptime_list[0] h = uptime_list[1] m = uptime_list[2] # st : second uptime st = uptime_list[3] if d: intSecond += d * 24 * 3600 if h: intSecond += h * 3600 if m: intSecond += m * 60 if st: intSecond += st return intSecond else: return 0
def test_time_now_to_show(): assert sun.time_now_to_show()