CollIBMHost.java 4.56 KB
package com.sitech.ismp.coll.centercoll;

import java.util.HashMap;
import java.util.Scanner;
import java.util.Vector;

import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.util.DES3;

public class CollIBMHost implements CollIBMHostMBean {

	public Vector<TblATO_KPIDETAIL> getConfig(HashMap<String, String> params) {
		CollIBMWithCMD cmd = new CollIBMWithCMD();
		return cmd.getConfig(params);
	}

	public Vector<TblATO_KPIDETAIL> getCpu(HashMap<String, String> params) {
		CollIBMWithCMD cmd = new CollIBMWithCMD();
		return cmd.getCpu(params);
	}

	public Vector<TblATO_KPIDETAIL> getMemory(HashMap<String, String> params) {
		CollIBMWithCMD cmd = new CollIBMWithCMD();
		return cmd.getMemory(params);
	}

	public Vector<TblATO_KPIDETAIL> getDisk(HashMap<String, String> params) {
		CollIBMWithCMD cmd = new CollIBMWithCMD();
		return cmd.getDisk(params);
	}

	public Vector<TblATO_KPIDETAIL> getFileSystem(HashMap<String, String> params) {
		CollIBMWithCMD cmd = new CollIBMWithCMD();
		return cmd.getFileSystem(params);
	}

	public Vector<TblATO_KPIDETAIL> getPing(HashMap<String, String> params) {
		CollIBMWithCMD cmd = new CollIBMWithCMD();
		return cmd.getPing(params);
	}
	public Vector<TblATO_KPIDETAIL> getBusiProcess(HashMap<String, String> params) {
		CollIBMWithCMD cmd = new CollIBMWithCMD();
		return cmd.getBusiProcess(params);
	}

	/**
	 * 采集文件变更指标
	 */
	@Override
	public Vector<TblATO_KPIDETAIL> getFileChange(HashMap<String, String> params) {
		CollIBMWithCMD cmd = new CollIBMWithCMD();
		return cmd.getFileChange(params);
	}

	/**
	 *采集大目录
	 * */
	@Override
	public Vector<TblATO_KPIDETAIL> getCatalog(HashMap<String, String> params) {
		CollIBMWithCMD cmd = new CollIBMWithCMD();
		return cmd.getCatalog(params);
	}

	public static void main(String[] args) {
		System.out
				.println("***************AIX Center Collect Test Begin*********************");
		String ipAddr = "172.21.1.69";
		String username = "yfbnms";
		String password = "test.com";
		String prototal = "ssh";
		String hostName = "dssyf";
		String methodStr = "7";
		String specPrompt = "dssyf:yfbnms:/yfbnms>";
        String pointIPs = "172.21.0.31,172.21.0.252";
        String process_name = "j2pg,/usr/sbin/syncd";
//		String ipAddr = read("IP_ADDR(remote host ip):\n");
//		String username = read("USERNAME:\n");
//		String password = read("PASSWORD:\n");
//		String prototal = read("PROTOTAL(ssh/telent):\n");
//		String hostName = read("HOST_NAME(remote host name):\n");
//		String methodStr = read("METHOD(0:getAll, 1:getConfig, 2:getCpu, 3:getMemory, 4:getDisk, 5:getFileSystem):\n");
//		String specPrompt = read("SPEC_PROMPT(like /yfbnms>):\n");

		System.out.println("IP_ADDR=" + ipAddr + ", USERNAME=" + username
				+ ", PASSWORD=" + password + ", PROTOTAL=" + prototal
				+ ", HOST_NAME=" + hostName + ", METHOD=" + methodStr);

		HashMap<String, String> params = new HashMap<String, String>();
		params.put("IP_ADDR", ipAddr);
		params.put("USERNAME", username);
		params.put("PASSWORD", DES3.encrypt(password));
		params.put("PROTOCOL", prototal);
		params.put("HOST_NAME", hostName);
		params.put("SPEC_PROMPT", specPrompt);
		params.put("POINT_IPS", pointIPs);
		params.put("PROCESS_NAME", process_name);

		int method = Integer.parseInt(methodStr);
		Vector<TblATO_KPIDETAIL> result = new Vector<TblATO_KPIDETAIL>();

		CollIBMHost collector = new CollIBMHost();

		switch (method) {
		case 0:
			result.addAll(collector.getConfig(params));
			result.addAll(collector.getCpu(params));
			result.addAll(collector.getMemory(params));
			result.addAll(collector.getDisk(params));
			result.addAll(collector.getFileSystem(params));
			break;
		case 1:
			result.addAll(collector.getConfig(params));
			break;
		case 2:
			result.addAll(collector.getCpu(params));
			break;
		case 3:
			result.addAll(collector.getMemory(params));
			break;
		case 4:
			result.addAll(collector.getDisk(params));
			break;
		case 5:
			result.addAll(collector.getFileSystem(params));
			break;
		case 6:
			result.addAll(collector.getPing(params));
			break;
		case 7:
			result.addAll(collector.getBusiProcess(params));
			break;
		default:
			break;
		}

		System.out
				.println("***************AIX Center Collect Test End*********************");
		System.out.println();
		for (int i = 0; i < result.size(); i++) {
			TblATO_KPIDETAIL record = (TblATO_KPIDETAIL) result.get(i);
			System.out.println(record.UNIT_ID + "\t" + record.KPI_ID + "\t"
					+ record.KPI_VALUE);
		}
	}
	
	private static String read(String prompt) {
		Scanner scanner = new Scanner(System.in);
		System.out.print(prompt);
		return scanner.nextLine();
	}
}