CollDB2.java 8.01 KB
// Decompiled Using: FrontEnd Plus v2.03 and the JAD Engine
// Available From: http://www.reflections.ath.cx
// Decompiler options: packimports(3) 
// Source File Name:   CollOracle.java

package com.sitech.ismp.coll.tivoli.db2;

import com.sitech.ismp.coll.CollBase;
import com.sitech.ismp.coll.tivoli.linux.CollLinux;
import com.sitech.util.Formater;
import java.io.PrintStream;
import java.util.*;

import org.apache.log4j.Logger;

// Referenced classes of package com.sitech.ismp.coll.tivoli:
//            CollOracleMBean, SoapParam, SoapClient, OracleSidHelper, 
//            CollOracleSoapHelper, CollOracleXmlHelper, UaOracleHelper, CheckKPIHelper

public class CollDB2
    implements CollDB2MBean
{
	private boolean debug;
    private SoapClient soapClient;
    private String pre_unitid;
    static Logger logger = Logger.getLogger("LOGER");
    public CollDB2()
    {
        debug = false;
        soapClient = null;
        pre_unitid = "10-11-30";
        String url = SoapParam.getString("SOAP_URL");
        soapClient = new SoapClient(url);
    }

    public Vector getPerformance_Thirty_Minute(HashMap params)
        throws Exception
    {
    	String host_name = (String)params.get("HOST_NAME");
        String sid = DB2SidHelper.getSid(host_name);
        String IP_ADDR = (String)params.get("IP_ADDR");
        String neat_sid = Formater.neatenunitid(sid);
        CollBase collResult = new CollBase();
        //得到soap请求 表空间利用率
        String soap_tbspaces_Oracle_Tablespaces = CollDB2SoapHelper.getSoap_tbspaces_Oracle_Tablespaces(sid, host_name);
        //发送soap请求,并返回结果
        String soap_tbspaces_Oracle_Tablespaces_res = soapClient.getSoapStringResponse(soap_tbspaces_Oracle_Tablespaces);
        List tbspaces_results = CollDB2XmlHelper.parseSoapResponse(soap_tbspaces_Oracle_Tablespaces_res);
        if(tbspaces_results == null || tbspaces_results.size() == 0)
        {
            System.out.println("@tivoli error, no tablespace info got by tivoli in collCpu " + new Date());
         } else
        {
        	 for(int i = 0; i < tbspaces_results.size(); i++)
            {
                Map rowMap = (Map)tbspaces_results.get(i);
                String tbs_used_percent = (String)rowMap.get("SPACE_USED_DMS_TABLE_PCT");
                String Tablespace_Name = (String)rowMap.get("TABLESPACE_NAME");
                String neatTablespace_Name = Formater.neatenunitid(Tablespace_Name);
                String Tablespace_Status = (String)rowMap.get("tbsp_state_name");
                              
                if (Tablespace_Status != null
						&& Tablespace_Status.equalsIgnoreCase("NORMAL")) {
					collResult
							.addKPI(pre_unitid + "-11:" + neat_sid
									+ "-TABLESPACES" + "-"
									+ neatTablespace_Name, "PM-00-03-004-01",
									String.valueOf(tbs_used_percent));
					
					System.out.println(pre_unitid + "-11:" + neat_sid
							+ "-TABLESPACES" + "-"
							+ neatTablespace_Name+ " PM-00-03-004-01 " + 
							String.valueOf(tbs_used_percent));					

				} else {
					collResult.addKPI(pre_unitid + "-11:" + neat_sid
							+ "-TABLESPACES" + "-" + neatTablespace_Name,
							"PM-00-03-004-01", "offline@"
									+ String.valueOf(tbs_used_percent));

				}
               
            }

        }
        //等待锁数量
        String soap_total_Oracle_Session_Summary = CollDB2SoapHelper.getSoap_total_Oracle_Session_Summary(sid, host_name);
        String soap_total_Oracle_Session_Summary_res = soapClient.getSoapStringResponse(soap_total_Oracle_Session_Summary);
        List Oracle_Session_Summary_res_results = CollDB2XmlHelper.parseSoapResponse(soap_total_Oracle_Session_Summary_res);
        if(Oracle_Session_Summary_res_results == null || Oracle_Session_Summary_res_results.size() == 0)
        {
         	System.out.println("@tivoli error, no Oracle_Session_Summary_res_results info got by tivoli in collCpu " + new Date());
        } else
        {
        	int total_invalue = 0;
         	for(int j=0;j<Oracle_Session_Summary_res_results.size();j++){
        	Map row_map = (Map)Oracle_Session_Summary_res_results.get(0);
            String locks_held = (String)row_map.get("locks_held");
            int intNumQueued = Integer.parseInt(locks_held);
            total_invalue = total_invalue + intNumQueued;
            
         	}
         	String unit_id = pre_unitid + "-10:" + neat_sid + "-SYS";
            collResult.addKPI(unit_id, "PM-10-12-10-23", String.valueOf(total_invalue));
        }
        return collResult.getKPISet();
    }
    //数据库会话数量 暂不监控
    public Vector getPerformance_One_Hour(HashMap params)
        throws Exception
    {
    	String host_name = (String)params.get("HOST_NAME");
        String ua_oracle_name = UaDB2Helper.getUaOracleName(host_name);
        String sid = DB2SidHelper.getSid(host_name);
        String IP_ADDR = (String)params.get("IP_ADDR");
        String neat_sid = Formater.neatenunitid(sid);
        CollBase collResult = new CollBase();        
        String soap_total_Oracle_Session_Summary = CollDB2SoapHelper.getSoap_total_Oracle_Session_Summary(sid, host_name);
        String soap_total_Oracle_Session_Summary_res = soapClient.getSoapStringResponse(soap_total_Oracle_Session_Summary);
        List Oracle_Session_Summary_res_results = CollDB2XmlHelper.parseSoapResponse(soap_total_Oracle_Session_Summary_res);
        if(Oracle_Session_Summary_res_results == null || Oracle_Session_Summary_res_results.size() == 0)
        {
            System.out.println("@tivoli error, no Oracle_Session_Summary_res_results info got by tivoli in collCpu " + new Date());
        } else
        {
            Map row_map = (Map)Oracle_Session_Summary_res_results.get(0);
            String Total_Sessions = (String)row_map.get("Total_Sessions");
            String unit_id = pre_unitid + "-10:" + neat_sid + "-SYS";
            collResult.addKPI(unit_id, "PM-00-03-009-03", Total_Sessions);
        }
        return collResult.getKPISet();
    }

   

    public Vector getFailure(HashMap params)
        throws Exception
    {
    	String host_name = (String)params.get("HOST_NAME");
        String sid = DB2SidHelper.getSid(host_name);
        String IP_ADDR = (String)params.get("IP_ADDR");
        String neat_sid = Formater.neatenunitid(sid);
        CollBase collResult = new CollBase();
        String soap_total_Oracle_Server = CollDB2SoapHelper.getSoap_total_Oracle_Server(sid, host_name);
        String soap_total_Oracle_Server_res = soapClient.getSoapStringResponse(soap_total_Oracle_Server);
        List Oracle_Server_res_results = CollDB2XmlHelper.parseSoapResponse(soap_total_Oracle_Server_res);
        if(Oracle_Server_res_results == null || Oracle_Server_res_results.size() == 0)
        {
            System.out.println("@tivoli error, no Oracle_Server_res_results info got by tivoli in collCpu " + new Date());
            String unit_id = pre_unitid + "-10:" + neat_sid + "-SYS";
            collResult.addKPI(unit_id, "FM-00-03-900-01", "DOWN");
        } else
        {
            Map row_map = (Map)Oracle_Server_res_results.get(0);
            String Server_Status = (String)row_map.get("db2_status");
            String unit_id = pre_unitid + "-10:" + neat_sid + "-SYS";
            if("".equals(Server_Status.trim()) || Server_Status.trim().length() == 0){
            	logger.info("databaseStatus SoAPRequest == " + soap_total_Oracle_Server);
            	logger.info("databaseStatus SoAPResponse== " + soap_total_Oracle_Server_res);
            }
            collResult.addKPI(unit_id, "FM-00-03-001-01", Server_Status.trim());
            collResult.addKPI(unit_id, "FM-00-03-900-01", "UP");
        }
          return collResult.getKPISet();
    }

    public static void main(String args[])
        throws Exception
    {
    	CollDB2 aix = new CollDB2();
		HashMap params = new HashMap();
		params.put("HOST_NAME","linux2");
		params.put("IP_ADDR","10.110.16.215");
		
		Vector v = new Vector();
		
		
		//v.addAll(aix.getFailure(params));
		//v.addAll(aix.getPerformance_Fifteen_Minute(params));		
		v.addAll(aix.getPerformance_Thirty_Minute(params));
    }
    
}