CollCTIServer.java 11.1 KB
package com.sitech.ismp.coll.i2000;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;

import org.apache.log4j.Logger;

import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.ismp.coll.i2000.db.nmsguest.CTIIVDNINF;
import com.sitech.ismp.coll.i2000.db.nmsguest.CTIIVDNINFDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.CTINECONNECT;
import com.sitech.ismp.coll.i2000.db.nmsguest.CTINECONNECTDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_AIP_OFDINC;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_AIP_OFDINCDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_AGCTR;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_AGCTRDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_AGHPSUM;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_AGHPSUMDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_IVRCINF;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_IVRCINFDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_RUNINF;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_RUNINFDao;

public class CollCTIServer implements CollCTIServerMBean{
	Logger logger = Logger.getLogger("I2000");
	//private String current_unit_id = "test_unit_id";
	private String current_unit_id = "01-17-11";
	
	public Vector getPerformance_One_Hour(HashMap params)throws Exception
	{
		Vector collResult = new Vector();
		String DevIPAddr = (String)params.get("DevIPAddr");
		Integer devip = new Integer(Integer.parseInt(DevIPAddr));
		HashMap params1 = new HashMap();
		params1.put("devip",devip);
		logger.info("= CollCTIServer getPerformance_One_Hour = ");
		//PM-02-17-011-02	�����Ŷӻ�ĺ�����	��һ�����������ڽ����Ŷӻ���ĺ��������	1Сʱ
		//tbl_perf_aip_ofdinc��seiz
		//PM-02-17-011-03	������	��һ����������������ͷ�ϵͳ�Ŷӻ���ĺ�����ռ�����������İٷֱȣ�100%��	1Сʱ
		//tbl_perf_aip_ofdinc����100*intcgcl/seiz,��λΪ%
		//lianlian 2006-11-13
		TBL_PERF_AIP_OFDINCDao tbl_perf_aip_ofdincdao = new TBL_PERF_AIP_OFDINCDao();
		List list_ofdincdao = tbl_perf_aip_ofdincdao.getCOLLINFO();
		if(list_ofdincdao==null||list_ofdincdao.size()==0)
		{
			logger.error("@i2000 error, no getCOLLINFO info got by i2000 in CollCTIServer "+new Date());
		}
		else
		{
			int intvalue = 0;
			for(int i=0;i<list_ofdincdao.size();i++)
			{
				TBL_PERF_AIP_OFDINC obj = (TBL_PERF_AIP_OFDINC)list_ofdincdao.get(i);
				int intdevip = obj.getDEVIP();
				int incofd = obj.getINCOFD();
				int seiz = obj.getSEIZ();
				int intcgcl = obj.getINTCGCL();
				Date time = obj.getTIME();
				if(seiz>0)
				{
					intvalue = 100*intcgcl/seiz;
				}
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + incofd,"PM-02-17-011-02",String.valueOf(seiz),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + incofd,"PM-02-17-011-03",String.valueOf(intvalue),time);
			}
		}
		
		//PM-02-17-011-04	�Զ�������	��һ������������·�ɵ�IVR���̵ĺ��и������	1Сʱ
		//tbl_perf_cti_ivrcinf��incallnum
		//lianlian 2006-11-13
		TBL_PERF_CTI_IVRCINFDao tbl_perf_cti_ivrcinfdao = new TBL_PERF_CTI_IVRCINFDao();
		List list_ivrcinfdao = tbl_perf_cti_ivrcinfdao.getAUTOCALLCOUNT();
		if(list_ivrcinfdao==null||list_ivrcinfdao.size()==0)
		{
			logger.error("@i2000 error, no getAUTOCALLCOUNT info got by i2000 in CollCTIServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_ivrcinfdao.size();i++)
			{
				TBL_PERF_CTI_IVRCINF obj = (TBL_PERF_CTI_IVRCINF)list_ivrcinfdao.get(i);
				int intdevip = obj.getDEVIP();
				int vdnid = obj.getVDNID();
				int subccno = obj.getSUBCCNO();
				int incallnum = obj.getINCALLNUM();
				Date time = obj.getTIME();
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-011-04",String.valueOf(incallnum),time);
			}
		}
		
		//PM-02-17-011-05	�˹�������	��һ������������·�ɵ��˹���ϯ�ĺ��и������	1Сʱ
		//tbl_perf_cti_agctr��connectednum+calllostnum
		//lianlian 2006-11-13
		TBL_PERF_CTI_AGCTRDao tbl_perf_cti_agctrdao = new TBL_PERF_CTI_AGCTRDao();
		List list_agctrdao = tbl_perf_cti_agctrdao.getMANUALCALLCOUNT();
		if(list_agctrdao==null||list_agctrdao.size()==0)
		{
			logger.error("@i2000 error, no getMANUALCALLCOUNT info got by i2000 in CollCTIServer "+new Date());
		}
		else
		{
			int intvalue = 0;
			for(int i=0;i<list_agctrdao.size();i++)
			{
				TBL_PERF_CTI_AGCTR obj = (TBL_PERF_CTI_AGCTR)list_agctrdao.get(i);
				int intdevip = obj.getDEVIP();
				int vdnid = obj.getVDNID();
				int subccno = obj.getSUBCCNO();
				int connectednum = obj.getCONNECTEDNUM();
				int calllostnum = obj.getCALLLOSTNUM();
				Date time = obj.getTIME();
				intvalue = connectednum+calllostnum;
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-011-05",String.valueOf(intvalue),time);
			}
		}
		
		return collResult;
	}
	
	public Vector getPerformance_One_Minute(HashMap params)throws Exception
	{
		Vector collResult = new Vector();
		String DevIPAddr = (String)params.get("DevIPAddr");
		Integer devip = new Integer(Integer.parseInt(DevIPAddr));
		HashMap params1 = new HashMap();
		params1.put("devip",devip);
		logger.info("= CollCTIServer getPerformance_One_Minute = ");
		//PM-02-17-011-01	CTI LINK����״̬	�ڲ����ʱCTI���������Ŷӻ�֮�������״̬	1����
		//CTINeConnect��cnstat�ֶ�,������豸nodeid��Ϣ���Դ�nodeid�л�ȡ
		//lianlian 2006-11-13
		CTINECONNECTDao ctineconnectdao = new CTINECONNECTDao();
		List list_ctineconnectdao = ctineconnectdao.getCTILINKSTATUS();
		if(list_ctineconnectdao==null||list_ctineconnectdao.size()==0)
		{
			System.out.println("@i2000 error, no getCTILINKSTATUS info got by i2000 in CollCTIServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_ctineconnectdao.size();i++)
			{
				CTINECONNECT obj = (CTINECONNECT)list_ctineconnectdao.get(i);
				String nodeid = obj.getNODEID();
				String cnnodeid = obj.getCNNODEID();
				String cnstat = obj.getCNSTAT();
				this.setResult(collResult,current_unit_id + ":" + nodeid + "-" + cnnodeid,"PM-02-17-011-01",cnstat,new Date());
			}
		}
		//PM-02-17-011-07	ǩ����ϯ��	�ڲ����ʱǩ�뵽CTI�������е���ϯ�������	1����
		//tbl_perf_cti_aghpsum��agentloginnums
		//PM-02-17-011-08	������ϯ��	�ڲ����ʱCTI�������п�����ϯ�ĸ������	1����
		//tbl_perf_cti_aghpsum��agentidlenums
		//lianlian 2006-11-13
		TBL_PERF_CTI_AGHPSUMDao tbl_perf_cti_aghpsumdao = new TBL_PERF_CTI_AGHPSUMDao();
		List list_aghpsumdao = tbl_perf_cti_aghpsumdao.getAGENT_LOGIN_IDLE_NUMS();
		if(list_aghpsumdao==null||list_aghpsumdao.size()==0)
		{
			logger.error("@i2000 error, no getAGENT_LOGIN_IDLE_NUMS info got by i2000 in CollCTIServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_aghpsumdao.size();i++)
			{
				TBL_PERF_CTI_AGHPSUM obj = (TBL_PERF_CTI_AGHPSUM)list_aghpsumdao.get(i);
				int intdevip = obj.getDEVIP();
				int vdnid = obj.getVDNID();
				int subccno = obj.getSUBCCNO();
				int agentloginnums = obj.getAGENTLOGINNUMS();
				int agentidlenums = obj.getAGENTIDLENUMS();
				Date time = obj.getTIME();
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-011-07",String.valueOf(agentloginnums),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-011-08",String.valueOf(agentidlenums),time);
			}
		}
		//PM-02-17-011-09	CPU������	�ڲ����ʱ���������ڵĻ�����CPU�����ʣ�100%��	1����
		//tbl_perf_cti_runinf��cpur
		//PM-02-17-011-10	�ڴ�������	�ڲ����ʱ���������ڵĻ������ڴ������ʣ�100%��	1����
		//tbl_perf_cti_runinf��memr
		//lianlian 2006-11-13
		TBL_PERF_CTI_RUNINFDao tbl_perf_runinfdao = new TBL_PERF_CTI_RUNINFDao();
		List list_runinfdao = tbl_perf_runinfdao.getCPUR_AND_MEMR();
		//û��selectȨ�ޣ�������Ȩ�޿�ֱ��ʹ��
		if(list_runinfdao==null||list_runinfdao.size()==0)
		{
			logger.error("@i2000 error, no getCPUR_AND_MEMR info got by i2000 in CollCTIServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_runinfdao.size();i++)
			{
				TBL_PERF_CTI_RUNINF obj = (TBL_PERF_CTI_RUNINF)list_runinfdao.get(i);
				int intdevip = obj.getDEVIP();
				int cpur = obj.getCPUR();
				int memr = obj.getMEMR();
				Date time = obj.getTIME();
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-011-09",String.valueOf(cpur),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-011-10",String.valueOf(memr),time);
			}
		}

		return collResult;
	}
	public Vector getConfiguration(HashMap params)throws Exception
	{
		Vector collResult = new Vector();
		logger.info("= CollCTIServer getConfiguration = ");
		//CM-02-17-011-01	������	ϵͳ�Ľ����루��1860��1861��	һ��
		//CTIIVDNINF�е�inno�ֶ�
		CTIIVDNINFDao ctiivdninfdao = new CTIIVDNINFDao();
		List list_ctiivdninfdao = ctiivdninfdao.getINNUM();
		if(list_ctiivdninfdao==null||list_ctiivdninfdao.size()==0)
		{
			logger.error("@i2000 error, no getINNUM info got by i2000 in CollCTIServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_ctiivdninfdao.size();i++)
			{
				CTIIVDNINF obj = (CTIIVDNINF)list_ctiivdninfdao.get(i);
				String ccid = obj.getCCID();
				String vdnid = obj.getVDNID();
				String innoid = obj.getINNOID();
				String inno = obj.getINNO();
				this.setResult(collResult,current_unit_id + ":" + ccid + "-" + vdnid + "-" + innoid,"CM-02-17-011-01",inno,new Date());
			}
		}
		
		return collResult;
	}
	
	private void setResult(Vector result,  String unitID, String kpiID , String value,Date cll_time) {
		try {
			TblATO_KPIDETAIL record;
			record = new TblATO_KPIDETAIL();
			record.setCLL_TIME(new Date());
			record.setKPI_ID(kpiID);
			record.setKPI_VALUE(value);
			record.setUNIT_ID(unitID);
			record.setCLL_TIME(cll_time);
			result.add(record);
		} catch (Exception e) {

			e.printStackTrace();
		}
	}
	
	public static void main(String args[])throws Exception
	{
		String DevIPAddr = "1000";
		HashMap params = new HashMap();
		params.put("DevIPAddr",DevIPAddr);
		Vector collResult = new Vector();
		
		CollCTIServerMBean MBean = new CollCTIServer();
		collResult.addAll(MBean.getConfiguration(params));
		collResult.addAll(MBean.getPerformance_One_Minute(params));
		collResult.addAll(MBean.getPerformance_One_Hour(params));
		
		String temp[][]=CheckKPIHelper.CheckCTIServerKPI(collResult);
		for(int i=0;i<temp.length;i++)
		{
			System.out.println("KPI_ID : " + temp[i][0] + "---" + temp[i][1]);
		}
		
		//String filename = "CTIServerKPIValue.xls";
		//CheckKPIHelper.WriteKPIValue2File(collResult,filename);
	}
}