⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mibconfig.java

📁 一个java编写的拓扑自动发现程序
💻 JAVA
字号:
/*
 * Created on 2008-03-04
 * author percy
 * version 1.0
 */
package com.sitech.net.topo;

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

import sitech.www.frame.jdbc.SqlQuery;

public class MibConfig {
	public MibConfig() {
	}

	public HashMap getMap(String class_level1, String class_level2,
			String name, String version) throws Exception {
		try {
			HashMap hs_map = new HashMap();
			String sql_mib_info = null;
			if (class_level2 == null && name == null) {
				sql_mib_info = "select NAME,MIB_VALUE from TB_CFG_SNMP_MIBOID where CLASS_LEVEL1='"
						+ class_level1
						+ "' and VERSION='"
						+ version
						+ "'  and enable='1'";
				// System.out.println(sql_mib_info);
			} else if (class_level2 != null && name == null) {
				sql_mib_info = "select NAME,MIB_VALUE from TB_CFG_SNMP_MIBOID where CLASS_LEVEL1='"
						+ class_level1
						+ "' and VERSION='"
						+ version
						+ "'  and enable='1' and CLASS_LEVEL2='"
						+ class_level2
						+ "' ";
			} else if (class_level2 != null && name != null) {
				sql_mib_info = "select NAME,MIB_VALUE from TB_CFG_SNMP_MIBOID where CLASS_LEVEL1='"
						+ class_level1
						+ "' and VERSION='"
						+ version
						+ "'  and enable='1' and CLASS_LEVEL2='"
						+ class_level2
						+ "' and NAME='" + name + "' ";
			}
			List list_mib_info = SqlQuery.findList(sql_mib_info);
			for (int j = 0; j < list_mib_info.size(); j++) {
				String[] item = (String[]) list_mib_info.get(j);
				hs_map.put(item[1].trim(), item[0].trim());
			}
			return hs_map;
		} catch (Exception e) {
			throw e;
		}
	}

	public Vector getVector(String class_level1, String class_level2,
			String name, String version) throws Exception {
		try {
			Vector v_oid = new Vector();
			String sql_mib_info = null;
			if (class_level2 == null && name == null) {
				sql_mib_info = "select MIB_VALUE,oid_type from TB_CFG_SNMP_MIBOID where CLASS_LEVEL1='"
						+ class_level1
						+ "' and VERSION='"
						+ version
						+ "'  and enable='1'";
				System.out.println(sql_mib_info);
			} else if (class_level2 != null && name == null) {
				sql_mib_info = "select MIB_VALUE,oid_type from TB_CFG_SNMP_MIBOID where CLASS_LEVEL1='"
						+ class_level1
						+ "' and VERSION='"
						+ version
						+ "'  and enable='1' and CLASS_LEVEL2='"
						+ class_level2
						+ "' ";
			} else if (class_level2 != null && name != null) {
				sql_mib_info = "select MIB_VALUE,oid_type from TB_CFG_SNMP_MIBOID where CLASS_LEVEL1='"
						+ class_level1
						+ "' and VERSION='"
						+ version
						+ "'  and enable='1' and CLASS_LEVEL2='"
						+ class_level2
						+ "' and NAME='" + name + "' ";
			}
			List list_mib_info = SqlQuery.findList(sql_mib_info);
			for (int j = 0; j < list_mib_info.size(); j++) {
				String[] item = (String[]) list_mib_info.get(j);
				if (item[1].equals("1")) // 判断是否为标量
				{
					v_oid.add("." + item[0].trim() + ".0");
				} else if (item[1].equals("0")) { // 判断是否为表量
					v_oid.add("." + item[0].trim());
				}
			}

			return v_oid;
		} catch (Exception e) {
			throw e;
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -