Exemple #1
0
def dealSql():
	try:
		dblist = connectDb.getConnectInfo()
		dbconn = connectDb.connectDb(dblist)
		dbconncr = dbconn.cursor()
		#业务类型为1、2、6、7(告警类) 3、8(采集类)
		dbconncr.execute("select * from monitor.t_mot_conf a where a.business_type in('1','2','6','7','3','8','13')")
		#dbconncr.execute("select * from monitor.t_mot_conf a where a.business_type in('2')")	
		result = dbconncr.fetchall()
		for confArray in result:
			#要执行的SQL是预警类
			if confArray[9] == '1':
            			if confArray[2] in ["SQL00", "SQL01"]:
					sql0(confArray[1], dbconncr, confArray[4], confArray[7], confArray[0], confArray[2], confArray[3])
				elif confArray[2] in ["SQL10", "SQL11"]:
					startTimeInterValList = getTimeInterval.getInterVal(confArray[5], dbconncr)
					for startTimeIndex in range(len(startTimeInterValList)):
						sql1(confArray[1], dbconncr, startTimeInterValList[startTimeIndex][0], confArray[5], 
						confArray[4], confArray[0], confArray[7], confArray[2], confArray[3], startTimeInterValList[startTimeIndex][1], dbconn)
				else:
					with open(r'error.log','a') as error_log:
                        			print >> error_log,('%s %s $s' % (time.ctime(), "'M_ID:'" + confArray[0], 'SQL Tpye Error:'))
			#信息采集
			else:
				if  confArray[2] == "SQL1":
					startTimeInterValList = getTimeInterval.getInterVal(confArray[5], dbconncr)
					for startTimeIndex in range(len(startTimeInterValList)):
						dealCollectInfo.sql1(confArray[1], dbconncr, startTimeInterValList[startTimeIndex][0],  confArray[5], 
						confArray[0], startTimeInterValList[startTimeIndex][1], dbconn)		
		connectDb.closeConnect(dbconn)
	except Exception,e:
		with open(r'error.log','a') as error_log:
			print >> error_log,('%s %s %s' % (time.ctime(),'Deal Data Faild:',e))
Exemple #2
0
def dealSql():
	try:
		dblist = connectDb.getConnectInfo()
		#VOP库连接
		dbconn = connectDb.connectDb(dblist[0])
                dbconncr = dbconn.cursor()
		#业务类型为12(告警类)
		dbconncr.execute("select * from monitor.t_mot_conf a where a.business_type = '12' and not exists(select 1 from monitor.t_mot_noacq_plan t where t.acq_bg_time < to_char(sysdate,'hh24miss') and t.acq_ed_time > to_char(sysdate,'hh24miss') and a.m_id = t.m_id)")
		result = dbconncr.fetchall()
		for confArray in result:
			#要执行的SQL是预警类
			if confArray[9] == '1':
            			if confArray[2] in ["SQL00", "SQL01"]:
					sql0(confArray[1], dbconncr, confArray[4], confArray[7], confArray[0], confArray[2], confArray[3], confArray[5], dbconn)
				elif confArray[2] in ["SQL10", "SQL11"]:
					startTimeInterValList = getTimeInterval.getInterVal(confArray[5], dbconncr)
					for startTimeIndex in range(len(startTimeInterValList)):
						sql1(confArray[1], dbconncr, startTimeInterValList[startTimeIndex][0], confArray[5], 
						confArray[4], confArray[0], confArray[7], confArray[2], confArray[3], startTimeInterValList[startTimeIndex][1], dbconn)
				else:
					with open(r'error.log','a') as error_log:
                        			print >> error_log,('%s %s $s' % (time.ctime(), "'M_ID:'" + confArray[0], 'SQL Tpye Error:'))
			#信息采集
			else:
				if  confArray[2] == "SQL1":
					startTimeInterValList = getTimeInterval.getInterVal(confArray[5], dbconncr)
					for startTimeIndex in range(len(startTimeInterValList)):
						dealCollectInfo.sql1(confArray[1], dbconncr, startTimeInterValList[startTimeIndex][0],  confArray[5], 
						confArray[0], startTimeInterValList[startTimeIndex][1], dbconn)		
		connectDb.closeConnect(dbconn)
	except Exception,e:
		with open(r'error.log','a') as error_log:
			print >> error_log,('%s %s %s' % (time.ctime(),'Deal Data Faild:',e))