def handle(self):

        param_channel = self.get_argument("channel")
        #print param_status
        #config.logging.info('isExitsHandler:param_channel=%s' % (param_channel))
        project_mo_db = chn_monitor_db.channel_db()
        result = project_mo_db.isExist(param_channel)
        result = {
            "code": result
        }
        return self.write(result)
    def handle(self):
        param_channel = self.get_argument("channel")
        param_start = str(self.get_argument("start", None))
        param_end = str(self.get_argument("end", None))

        page_index = self.get_argument("iDisplayStart", None)
        page_capacity = self.get_argument("iDisplayLength", None)
        project_His_db = chn_monitor_db.channel_db()
        result = project_His_db.Query_History_Info(param_channel, param_start,
                                                   param_end, page_index,
                                                   page_capacity)
        return self.write(result)
    def handle(self):

        param_idc = self.get_argument("idc")
        param_status = self.get_argument("status")
        param_channel = self.get_argument("channel")
        param_thr_time = self.get_argument("thr_time")
        #print param_status
        project_mo_db = chn_monitor_db.channel_db()
        result = project_mo_db.Insert_Channel_info(param_idc, param_channel,
                                                   param_thr_time,
                                                   param_status)
        result = {"code": result}
        return self.write(result)
示例#4
0
 def probe2(self, m3u8s_info_list):                 #m3u8s-----[(id,status,local,idc,channel...),(),().....]
     info_list = [];
     for m3u8 in m3u8s_info_list:
         url = m3u8[4];
         (channel, delta, _now,_time) = test_ts(url);              #delta:local;_now:probe_time
         try:
             Temp_db = chn_monitor_db.channel_db()
             if int(delta)>int(m3u8[6]):
                 Temp_db.Update_Info_ByChannel(channel,delta,_now,config.CHN_STATUS_ALERT) #状态3代表异常
             else:
                 Temp_db.Update_Info_ByChannel(channel,delta,_now,config.CHN_STATUS_OK) #状态2代表正常
         except Exception,e:
             config.logging.error("probe2.Update_Info_ByChannel error,e=[%s]" %(e))
         if delta > int(m3u8[6]):  #300
             try:
                 Temp_db = chn_monitor_db.channel_db()
                 Temp_db.Insert_Alert_ByChannel(m3u8[3],channel,_time)
                 if self.alertFilter(url):               #控制5分钟发1次邮件2016.01.11
                     error_text = "live local(s) %s alert:%s:%s\n" % (delta, m3u8[3],url);
                     _sendEmail(error_text, delta, 'live');
             except Exception,e:
                 config.logging.error("probe2.sendemail error,e=[%s]" %(e))
    def handle(self):

        param_idc = self.get_argument("idc")
        param_status = self.get_argument("status")
        param_channel = self.get_argument("channel")
        page_index = self.get_argument("iDisplayStart", None)
        page_capacity = self.get_argument("iDisplayLength", None)
        config.logging.info(
            'QueryChnMonitorHandler:param_idc=%s,param_status=%s,param_channel=%s'
            % (param_idc, param_status, param_channel))
        project_mo_db = chn_monitor_db.channel_db()
        result = project_mo_db.Query_Channel_Info(param_idc, param_status,
                                                  param_channel, page_index,
                                                  page_capacity)
        return self.write(result)
示例#6
0
def services_alert():
    reload(sys)
    sys.setdefaultencoding('utf8')
    #log_info_file = "alert.log"
    #logging.basicConfig(filename=log_info_file, level=logging.INFO)
    items = [];
    idc_list=list()
    try:
        sql_idc = "SELECT IDC FROM monitor_channel GROUP BY IDC"
        idc_db = chn_monitor_db.channel_db()
        result = idc_db.the_db.execute(sql_idc)
        for row in idc_db.the_db.cur.fetchall():
            idc_list.append(row[0])
    except Exception,e:
        cur = datetime.datetime.fromtimestamp(float(time.time())).strftime('%Y-%m-%d %H:%M:%S')
        config.logging.error("idc_list error e=%s sql_idc=%s time=%s" %(e,sql_idc,str(cur)))
    def handle(self):

        param_id = self.get_argument("id")
        param_idc = self.get_argument("idc")
        param_status = self.get_argument("status")
        param_channel = self.get_argument("channel")
        param_thr_time = self.get_argument("thr_time")
        #print param_status
        config.logging.info(
            'updateChnMonitorHandler:param_id=%s,param_idc=%s,param_status=%s,param_channel=%s,param_thr_time=%s'
            %
            (param_id, param_idc, param_status, param_channel, param_thr_time))
        project_mo_db = chn_monitor_db.channel_db()
        result = project_mo_db.Update_Channel_Info(param_id, param_idc,
                                                   param_status, param_channel,
                                                   param_thr_time)
        result = {
            "code": result
        }
        return self.write(result)
示例#8
0
def run(live_probe):
    skip_times = 0;
    info_list = [];
    while 1:
        try:
            info_db = chn_monitor_db.channel_db()
            sql_info = ("SELECT * FROM monitor_channel WHERE STATUS!='%s' AND IDC='%s'" %(config.CHN_STATUS_STOP,live_probe.ip))
            result = info_db.the_db.execute(sql_info)
            live_probe.m3u8_list_temp=[]
            for row in info_db.the_db.cur.fetchall():
                live_probe.m3u8_list_temp.append(row)
            info_db.the_db.close()
        except Exception,e:
            config.logging.error("mysql connect error error=%s" %(e))
            time.sleep(0.1)
        try:
            info_list = live_probe.probe2(live_probe.m3u8_list_temp); #[(id,dic,...),(),.....]
        except Exception,e:
            config.logging.error("run.probe2 error,e=[%s]" %(e))
            continue
示例#9
0
                else:
                    Temp_db.Update_Info_ByChannel(channel,delta,_now,config.CHN_STATUS_OK) #状态2代表正常
            except Exception,e:
                config.logging.error("probe2.Update_Info_ByChannel error,e=[%s]" %(e))
            if delta > int(m3u8[6]):  #300
                try:
                    Temp_db = chn_monitor_db.channel_db()
                    Temp_db.Insert_Alert_ByChannel(m3u8[3],channel,_time)
                    if self.alertFilter(url):               #控制5分钟发1次邮件2016.01.11
                        error_text = "live local(s) %s alert:%s:%s\n" % (delta, m3u8[3],url);
                        _sendEmail(error_text, delta, 'live');
                except Exception,e:
                    config.logging.error("probe2.sendemail error,e=[%s]" %(e))
            else:
                try:
                    Temp_db = chn_monitor_db.channel_db()
                    Temp_db.Update_Alert_ByChannel(m3u8[3],channel,_now)
                except Exception,e:
                    config.logging.error("probe2.email-time less 5min error,e=[%s]" %(e))

        return info_list;

    def probe(self, ip):
        url = "http://" + ip + "/m3u8_conf/channel.xml";
        return test_m3u8(ip, url);

    def probe1(self, idc, ip):
        info_list = [];
        channels = self.FetchEPG();
        for channel in channels:
            url = 'http://%s/%s' % (ip, channel);