CollWeblogic7WithSNMP.java 36.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
package com.sitech.ismp.coll;

/**
 * 
 * update by 2006-9-11
 * update by 2006-9-12
 * 
 * 编号 KPI_ID KPI名称 KPI描述 1 PM-00-04-003-01 当前应用服务器的内存堆使用比率 当前应用服务器的内存堆使用比率 2
 * PM-00-04-003-02 当前数据库连接池使用比率 当前数据库连接池使用比率 3 PM-00-04-001-03 消息队列等待请求数量
 * PM-00-04-003-03 ---------当前连接池数目
 * 
 * 
 * 编号 KPI_ID KPI名称 KPI描述 1 FM-00-04-003-01 异常主机地址或主机名
 * 如果应用服务器采用群集系统,其中某台机器出现异常,则反映该机器的地址或名称 2 FM-00-04-003-02 异常事务数
 * 在采样周期内未能正常完成的事务个数 10分钟 数值型 major 3 FM-00-04-001-01 服务运行状态 (UP-----运行正常
 * DOWN------不正常运行 2006-08-15)
 * 
 * 编号 KPI_ID KPI名称 KPI描述 1 CM-00-04-003-01 应用服务器运行模式 应用服务器群集还是单机 2
 * CM-00-04-003-02 允许应用服务器支配的内存堆大小(MB) 允许应用服务器支配的内存堆大小(MB) 3 CM-00-04-003-03
 * 配置的总线程数 配置的总线程数 4 CM-00-04-003-04 配置的数据库连接池大小 配置的数据库连接池大小 5 CM-00-04-003-05
 * 应用服务器的系统日志路径 应用服务器的系统日志路径 6 CM-00-04-003-06 应用服务器的用户日志路径 应用服务器的用户日志路径 7
 *  
 */

/*
 * 说明:普通类,主要用snmp方法实现weblogic7.0的采集
 *  
 */

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

import org.apache.log4j.Logger;

import com.adventnet.snmp.beans.SnmpTarget;
import com.adventnet.snmp.snmp2.SnmpOID;
import com.sitech.ismp.app.coll.RPCTarget;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.util.Formater;

public class CollWeblogic7WithSNMP implements CollWeblogicWithSNMPMBean {

	SnmpTarget target = null;

	String ObjectIP = null;

	private boolean DEBUG = false;

	RPCTarget rpctarget = null;

	static Logger logger = Logger.getLogger("LOGER");

	String hostname = "";

	String community = null;

	String ip = null;

	int port = 0;

	String servicename = null;
	
	String snmp_version ="1";

	private Vector result = new Vector();

	public Vector coll(HashMap params) {
		String community = "public";
		community = (String) params.get("COMMUNITY");
		String ip = (String) params.get("IP"); // 要采集的weblogic7.0 IP
		String hostname = ip;
		int port = Integer.parseInt((String) params.get("PORT")); // SNMP端口
		String servicename = (String) params.get("SERVICENAME"); // weblogic7.0所开的server
		String snmp_version = (String) params.get("SNMP_VERSION"); 
		if(snmp_version!=null&&!snmp_version.equals("")){
			this.snmp_version = snmp_version;
		}
		this.hostname = hostname;
		this.ip = ip;
		this.port = port;
		this.community = community;
		this.servicename = servicename;
		logger.info(ip); // 记录日志

		// 与weblogic7.0建立初始化连接
		initWeblogic(ip, servicename, port, hostname, community);

		// 进行采集操作
		collWeblogic7();

		// 将采集到的数据写入文件 version 2
		// 2006-08-07
		callCollBase();

		// 返回操作
		return result;
	}

	private void setResult(String value, String unitID, String kpiID) {
		try {
			TblATO_KPIDETAIL record;
			record = new TblATO_KPIDETAIL();
			record.setCLL_TIME(new java.util.Date()); // 采集所消耗的时间
			record.setKPI_ID(kpiID); // kpi编号
			record.setKPI_VALUE(value); // 具体采集得到的值信息
			record.setUNIT_ID(unitID); // unit
			record.setCLL_TIME(new Date()); // 日期
			result.add(record);
		} catch (Exception e) {
			logger.error(e);
		}
	}

	private void callCollBase() {
		CollBase coll = new CollBase();
		coll.addKPISet(result);
		coll.saveKPI2File();
		coll.displayKPI();
	}

	private void noneffective() {

		String unitID = "10-12-11-10-10:" + hostname + "-total";
		// CM-00-04-003-03 配置的总线程数
		setResult("noneffective", unitID, "CM-00-04-003-03");
		// FM-00-04-003-01 异常主机地址或主机名
		setResult("noneffective", unitID, "FM-00-04-003-01");
		// FM-00-04-003-02 异常事务数
		setResult("noneffective", unitID, "FM-00-04-003-02");

	}

	private void collWeblogic7() {
		try {

			// 采集连接池情况
			collConnPoolValues();
			// 采集日志路径
			collLog();
			// 采集内存堆相关
			collHeap();
			// 采集JTA相关
			collJTA();
			// 采集群集相关
			collCluser();

			// 采集消息队列
			collQueue();
			// noneffective();
			// 服务运行状态
			collRunState();
			// String unitID = "10-12-11-10-10:" + hostname + "-total";
			// FM-00-04-003-03 主机状态 true 连接正常 false 连接失败可能宕机
			// setResult("true", unitID, "FM-00-04-003-03");
			release();
		} catch (Exception e) {
			// 10-12-11-10-10------->10-12-11-11-10
			String unitID = "10-12-11-10-10:" + hostname + "-total";
			// FM-00-04-003-03 主机状态 true 连接正常 false 连接失败可能宕机
			setResult("false", unitID, "FM-00-04-003-03");
			logger.error(e);
		}
	}

	private void collConnPoolValues() {
		try {
			HashMap hs = new HashMap();
			hs.put("JDBCPOOL.NUM", "1");
			getjdbcConnectionPoolMaxCapacity();
			getJdbcPoolUseRate(hs);
			getjdbcConnectionPoolActiveConnectionsCurrentCount();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	private void collJTA() {
		getserverRuntimeName();
		getserverRuntimeListenAddress();
		getserverRuntimeListenPort();
		getserverRuntimeAdminServerHost();
		getserverRuntimeAdminServerListenPort();
	}

	/**
	 * serverRuntimeName: .1.3.6.1.4.1.140.625.360.1.15 weblogic 运行的服务器的名称:
	 * .1.3.6.1.4.1.140.625.360.1.15
	 */
	private void getserverRuntimeName() {
		// System.out.println("Begin getserverRuntimeName");
		String unitid = "10-12-11-11-10:";
		Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain
		// name
		String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
		String domainName = domain[domain.length - 2]; // get Domain

		Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", false); // host
		// name

		String hostName = (String) vc_hostName.elementAt(0);
		unitid = unitid + this.ip + "-" + this.servicename + "-" + domainName
				+ "-" + this.servicename + "-serverName";

		boolean bool = true;
		Vector vc_active = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.15", bool);

		if (vc_active.size() > 0) {
			String count = (String) vc_active.elementAt(0);
			setResult(count, unitid, "CM-00-04-003-07");
		}
		// System.out.println("End getserverRuntimeName");
	}

	/**
	 * the address on which this server is listening for
	 * connections(boss/172.16.9.1): .1.3.6.1.4.1.140.625.360.1.30
	 * weblogic运行的服务器的侦听地址(boss/172.16.9.1): .1.3.6.1.4.1.140.625.360.1.30
	 */
	private void getserverRuntimeListenAddress() {
		System.out.println("Begin getserverRuntimeListenAddress");
		// System.out.println("Begin getserverRuntimeName");
		String unitid = "10-12-11-11-10:";
		Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain
		// name
		String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
		String domainName = domain[domain.length - 2]; // get Domain

		Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", false); // host
		// name

		String hostName = (String) vc_hostName.elementAt(0);
		unitid = unitid + this.ip + "-" + this.servicename + "-" + domainName
				+ "-" + this.servicename + "-hostAddress";
		boolean bool = true;
		Vector vc_active = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.30", bool);
		if (vc_active.size() > 0) {
			String count = (String) vc_active.elementAt(0);
			setResult(count, unitid, "CM-00-04-003-08");
			// setResult((String)params.get("WEBLOGIC.server")+"@"+(String)params.get("WEBLOGIC.IP"),"serverListenAddress","CM-10-13-10-11");
		}
		System.out.println("End getserverRuntimeListenAddress");
	}

	/**
	 * port on which this server is listening for connections:
	 * .1.3.6.1.4.1.140.625.360.1.35 weblogic 运行的服务器的侦听端口:
	 * .1.3.6.1.4.1.140.625.360.1.35
	 */
	private void getserverRuntimeListenPort() {
		System.out.println("Begin getserverRuntimeListenPort");
		String unitid = "10-12-11-11-10:";
		Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain
		// name
		String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
		String domainName = domain[domain.length - 2]; // get Domain

		Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", false); // host
		// name

		String hostName = (String) vc_hostName.elementAt(0);
		unitid = unitid + this.ip + "-" + this.servicename + "-" + domainName
				+ "-" + this.servicename + "-servicePort";
		boolean bool = true;
		Vector vc_active = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.35", bool);
		if (vc_active.size() > 0) {
			String count = (String) vc_active.elementAt(0);
			setResult(count, unitid, "CM-00-04-003-09");
		}
		System.out.println("End getserverRuntimeListenPort");
	}

	/**
	 * the address on which admin server is listening for connections(boss or
	 * 172.16.9.1): .1.3.6.1.4.1.140.625.360.1.70 weblogic
	 * 运行的服务器的管理服务器的侦听地址(boss or 172.16.9.1): .1.3.6.1.4.1.140.625.360.1.70
	 */
	private void getserverRuntimeAdminServerHost() {
		System.out.println("Begin getserverRuntimeAdminServerHost");
		String unitid = "10-12-11-11-10:";
		Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain
		// name
		String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
		String domainName = domain[domain.length - 2]; // get Domain

		Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", false); // host
		// name

		String hostName = (String) vc_hostName.elementAt(0);
		unitid = unitid + this.ip + "-" + this.servicename + "-" + domainName
				+ "-" + this.servicename + "-serviceAddress";
		boolean bool = true;
		Vector vc_active = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", bool);
		if (vc_active.size() > 0) {
			String count = (String) vc_active.elementAt(0);
			setResult(count, unitid, "CM-00-04-003-10");
		}
		System.out.println("End getserverRuntimeAdminServerHost");
	}

	/**
	 * the port on which admin server is listening for connections:
	 * .1.3.6.1.4.1.140.625.360.1.75 weblogic 运行的服务器的管理服务器的侦听短端口:
	 * .1.3.6.1.4.1.140.625.360.1.75
	 */
	private void getserverRuntimeAdminServerListenPort() {
		System.out.println("Begin getserverRuntimeAdminServerListenPort");
		String unitid = "10-12-11-11-10:";
		Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain
		// name
		String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
		String domainName = domain[domain.length - 2]; // get Domain

		Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", false); // host
		// name

		String hostName = (String) vc_hostName.elementAt(0);
		unitid = unitid + this.ip + "-" + this.servicename + "-" + domainName
				+ "-" + this.servicename + "-serverListenPort";
		boolean bool = true;
		Vector vc_active = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.75", bool);
		if (vc_active.size() > 0) {
			String count = (String) vc_active.elementAt(0);
			setResult(count, unitid, "CM-00-04-003-11");
		}
		System.out.println("End getserverRuntimeAdminServerListenPort");
	}

	private void collCluster() {
		String domainName = "";
		boolean bool = true;
		Vector clusters = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.31", bool);// Cluster
		if (clusters.size() > 0) {
			domainName = (String) clusters.elementAt(0);
		}
		//
		// 1 CM-00-04-003-01 应用服务器运行模式 应用服务器群集还是单机 1天 字符型
		String cluster = "false";
		if (!clusters.isEmpty()) {
			cluster = "true";
		}
		String unitID = "10-12-11-10-10:" + this.ip + "-"
				+ Formater.neatenunitid(domainName) + "-" + "runmodel";
		setResult(cluster, unitID, "CM-00-04-003-01");

	}

	/**
	 * @author pc103
	 * @date 2006-07-21
	 * @exception
	 * @exp 说明:采集内存堆 通过该采集可以知道JVM堆中可用的内存数量,OID等相关信息 1 PM-00-04-003-01
	 *      当前应用服务器的内存堆使用比率 当前应用服务器的内存堆使用比率 10分钟 数值型 2 2 CM-00-04-003-02
	 *      允许应用服务器支配的内存堆大小(MB) 允许应用服务器支配的内存堆大小(MB) 1天 数值型
	 */
	private void collHeap() {
		getJVMMEM();
		// getFreeJVMMEM();
		// getUsedJVMMEM();
		getJVMMEMUseRate();
	}

	/**
	 * 当前总情况 The current size of the JVM heap in bytes:
	 * .1.3.6.1.4.1.140.625.340.1.30 当前JVM中的堆内存值: .1.3.6.1.4.1.140.625.340.1.30
	 * 
	 * ==========unitID有变,unitID=10-12-11-10-10--->10-12-11-11-10
	 */
	private void getJVMMEM() {
		String unitID = "10-12-11-11-10:";
		String hostName = "";
		String domainName = "";
		try {
			Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
					false); // domain name
			String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
			domainName = domain[domain.length - 2]; // get Domain

			Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70",
					false); // host name
			hostName = (String) vc_hostName.elementAt(0);
			unitID = unitID + this.ip + "-" + this.servicename + "-"
					+ domainName + "-" + this.servicename + "-HeapSize";
			System.out.println("Begin getJVMMEM");
			Vector JVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.30", false);
			if (JVMMEM.size() > 0) {
				String state = String.valueOf(JVMMEM.elementAt(0));
				setResult(state, unitID, "CM-00-04-003-02");
			}
		} catch (Exception e) {
			logger.error(e);
		}
		System.out.println("End getJVMMEM");
	}

	/**
	 * 允许使用的 The current amount of free memory in the JVM heap in bytes:
	 * .1.3.6.1.4.1.140.625.340.1.25 JVM 中free memory值:
	 * .1.3.6.1.4.1.140.625.340.1.25
	 */
	private void getFreeJVMMEM() {
		System.out.println("Begin getFreeJVMMEM");
		Vector FreeJVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.25", false);
		if (FreeJVMMEM.size() > 0) {
			String state = String.valueOf(FreeJVMMEM.elementAt(0));
			System.out.println("FreeJVM==" + state);
			setResult(state, "FreeJVM", "CM-00-04-003-02");
		}
		System.out.println("End getFreeJVMMEM");
	}

	/**
	 * 使用过的 The current size of the JVM heap in bytes:
	 * .1.3.6.1.4.1.140.625.340.1.30 当前JVM中的堆内存值: .1.3.6.1.4.1.140.625.340.1.30
	 * The current amount of free memory in the JVM heap in bytes:
	 * .1.3.6.1.4.1.140.625.340.1.25 JVM 中free memory值:
	 * .1.3.6.1.4.1.140.625.340.1.25 JVM 中的使用的内存值=JVM中的堆内存值 - JVM 中的剩余内存 =
	 * (.1.3.6.1.4.1.140.625.340.1.30)-(.1.3.6.1.4.1.140.625.340.1.25)
	 */
	private void getUsedJVMMEM() {
		System.out.println("Begin getJVMMEMUseRate");
		Vector JVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.30", false);
		if (JVMMEM.size() > 0) {
			int state_all = Integer.parseInt((String) JVMMEM.elementAt(0));
			Vector FreeJVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.25",
					false);
			if (FreeJVMMEM.size() > 0) {
				int state_free = Integer.parseInt((String) FreeJVMMEM
						.elementAt(0));
				int state_use = state_all - state_free;
				setResult(String.valueOf(state_use), "UsedJvm",
						"CM-00-04-003-03");
			}
		}
		System.out.println("End getJVMMEMUseRate");
	}

	/**
	 * The current size of the JVM heap in bytes: .1.3.6.1.4.1.140.625.340.1.30
	 * 当前JVM中的堆内存值: .1.3.6.1.4.1.140.625.340.1.30 The current amount of free
	 * memory in the JVM heap in bytes: .1.3.6.1.4.1.140.625.340.1.25 JVM 中free
	 * memory值: .1.3.6.1.4.1.140.625.340.1.25 JVM 中的使用的内存值=JVM中的堆内存值 - JVM
	 * 中的剩余内存 JVM中的内存使用率= JVM 中的使用的内存值*100/JVM中的堆内存值 =
	 * (.1.3.6.1.4.1.140.625.340.1.30)-(.1.3.6.1.4.1.140.625.340.1.25)*100F/(.1.3.6.1.4.1.140.625.340.1.30)
	 * 
	 * ==============10-12-11-10-10----->10-12-11-11-10
	 */
	private void getJVMMEMUseRate() {

		String unitID = "10-12-11-11-10:";
		String hostName = "";
		String domainName = "";

		System.out.println("Begin getJVMMEMUseRate");
		try {
			Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
					false); // domain name
			String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
			domainName = domain[domain.length - 2]; // get Domain

			Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70",
					false); // host name
			hostName = (String) vc_hostName.elementAt(0);
			unitID = unitID + this.ip + "-" + this.servicename + "-"
					+ domainName + "-" + this.servicename + "-HeapPercent";
			Vector JVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.30", false);
			if (JVMMEM.size() > 0) {
				int state_all = Integer.parseInt((String) JVMMEM.elementAt(0));
				Vector FreeJVMMEM = walkKPIInfo(
						".1.3.6.1.4.1.140.625.340.1.25", false);
				if (FreeJVMMEM.size() > 0) {
					int state_free = Integer.parseInt((String) FreeJVMMEM
							.elementAt(0));
					int state_use = state_all - state_free;
					if (state_all != 0) {
						float userate = state_use * 100F / state_all;
						setResult(String.valueOf(userate), unitID,
								"PM-00-04-003-01");
						System.out.println("JVMMEMUseRate=" + userate);
					}

				}
			}
		} catch (Exception e) {
			logger.error(e);
		}
		System.out.println("End getJVMMEMUseRate");
	}

	/**
	 * @author pc103
	 * @date 2006-07-21
	 * @param 采集日志文件
	 *            5 CM-00-04-003-05 应用服务器的系统日志路径 应用服务器的系统日志路径 1天 字符串型 6
	 *            CM-00-04-003-06 应用服务器的用户日志路径 应用服务器的用户日志路径 1天 字符串型
	 * 
	 */
	private void collSysLog() {
		String unitID = "10-12-11-11-10:";
		String hostName = "";
		String domainName = "";
		boolean bool = true;
		String logPath = "";
		String serverName = "";
		try {
			Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
					false); // domain name
			String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
			domainName = domain[domain.length - 2]; // get Domain

			Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70",
					false); // host name
			hostName = (String) vc_hostName.elementAt(0);
			unitID = unitID + this.ip + "-" + servicename + "-" + domainName
					+ "-" + this.servicename + "-log";
			Vector LogPath = walkKPIInfo(".1.3.6.1.4.1.140.625.700.1.25.32",
					bool);// logPath and logFileName
			for (Iterator it = LogPath.iterator(); it.hasNext();) {
				System.out.println("--------" + it.next().toString());
			}
			if (LogPath.size() > 0) {
				setResult((String) LogPath.elementAt(0), unitID,
						"CM-00-04-003-06");
			}

		} catch (Exception e) {
			logger.error(e);
		}
	}

	private void collUsrLog() {
		String unitID = "10-12-11-11-10:";
		String hostName = "";
		String domainName = "";
		boolean bool = true;
		String logPath = "";
		String serverName = "";
		try {
			Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
					false); // domain name
			String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
			domainName = domain[domain.length - 2]; // get Domain

			Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70",
					false); // host name
			hostName = (String) vc_hostName.elementAt(0);
			unitID = unitID + this.ip + "-" + this.servicename + "-"
					+ domainName + "-" + "log";
			Vector LogPath = walkKPIInfo(".1.3.6.1.4.1.140.625.700.1.25.32",
					bool);// logPath and logFileName

			if (LogPath.size() > 0) {

				setResult((String) LogPath.elementAt(0), unitID,
						"CM-00-04-003-07");
			}

		} catch (Exception e) {
			logger.error(e);
		}
	}

	/**
	 * "10-12-11-10-10:";----------> "10-12-11-11-10:"; 2006-9-11
	 */
	private void collUsrLogTwo() {
		String unitID = "10-12-11-11-10:"; // update by 2006-9-12
											// 10-12-11-11-12--->10-12-11-11-11
		String hostName = "";
		String domainName = "";
		boolean bool = true;
		String logPath = "";
		String serverName = "";
		try {
			Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
					false); // domain name
			String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
			domainName = domain[domain.length - 2]; // get Domain

			Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70",
					false); // host name
			hostName = (String) vc_hostName.elementAt(0);
			unitID = unitID + this.ip + "-" + servicename + "-" + domainName
					+ "-" + "log";
			Vector LogPath = walkKPIInfo(
					".1.3.6.1.4.1.140.625.700.1.25.32.100", bool);// logPath
																	// and
			// logFileName

			if (LogPath.size() > 0) {

				setResult((String) LogPath.elementAt(0), unitID,
						"CM-00-04-003-05");
			}

		} catch (Exception e) {
			logger.error(e);
		}
	}

	private void collLog() {
		this.collSysLog();
		// this.collUsrLog();
		this.collUsrLogTwo();

	}

	/**
	 * 服务器运行状态
	 * 
	 */
	private void collRunState() {
		String unitID = "10-12-11-11-10:"; // update by 2006-9-12
											// 10-12-11-11-13-->10-12-11-11-11:
		String hostName = "";
		String domainName = "";
		boolean bool = true;
		String logPath = "";
		String serverName = "";
		try {
			Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
					false); // domain name
			String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
			domainName = domain[domain.length - 2]; // get Domain

			Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70",
					false); // host name
			hostName = (String) vc_hostName.elementAt(0);
			unitID = unitID + this.ip + "-" + this.servicename + "-RunState";
			// hostName + "-" + domainName + "-" + "RunState";

			Vector stateRun = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.60", bool);// logPath
			// and
			// logFileName

			String state = (String) stateRun.elementAt(0);
			if (state != null && state.length() > 0 && state.equals("RUNNING")) {
				state = "UP";
			} else {
				state = "DOWN";
			}
			if (stateRun.size() > 0) {
				setResult(state, unitID, "FM-00-04-001-01");
			}

		} catch (Exception e) {
			logger.error(e);
		}
	}

	/**
	 * @author pc103
	 * @date 2006-07-21
	 * @exception
	 * @exp 说明:采集消息队列等待消息队列的请求数量 kpi_id= PM-00-04-001-03
	 * 
	 */
	private void collQueue() {
		boolean bool = true;
		String unitID = "10-12-11-11-10:" + this.ip + "-" + this.servicename
				+ "-";
		String domainName = "";
		try {
			Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
					false); // domain name
			String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
			domainName = domain[domain.length - 2]; // get Domain
			Vector queueName = walkKPIInfo(".1.3.6.1.4.1.140.625.180.1.35.32",
					false);
			unitID = unitID + this.servicename;
			// + "-PendingQueue";
			setResult(queueName.elementAt(0).toString(), unitID,
					"PM-00-04-001-03");

		} catch (Exception e) {
			logger.error(e);

		}
	}

	/**
	 * The maximum capacity of this JDBC pool: 1.3.6.1.4.1.140.625.190.1.15 JDBC
	 * 连接池的最大容量: 1.3.6.1.4.1.140.625.190.1.15 PM-00-04-003-02 当前数据库连接池使用比率
	 * CM-00-04-003-04配置的数据库连接池大小 配置的数据库连接池大小
	 * CM-00-04-003-04-----jdbcConnectionPoolRuntimeConnectionsTotalCount
	 * 
	 * 
	 */
	private void getjdbcConnectionPoolMaxCapacity() {
		String unitID = "10-12-11-11-11";
		String connPoolName = "";
		String connDomain = "";
		String connServerName = "";
		String hostName = "";
		String count[] = null;
		int poolNum = 1;
		int i = 0;
		int j = 0;
		try {
			if (poolNum == 1) {

				Vector vc_Max = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.55",
						false);
				count = new String[vc_Max.size()];
				for (Iterator tt = vc_Max.iterator(); tt.hasNext();) {
					count[i] = (String) tt.next();
					i++;
				}
				Vector vc_ConnPollName = walkKPIInfo(
						".1.3.6.1.4.1.140.625.190.1.15", false); // connPool
				// Name

				Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
						false); // domain
				// name
				String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
				connDomain = domain[domain.length - 2]; // get Domain

				Vector vc_ServerName = walkKPIInfo(
						".1.3.6.1.4.1.140.625.360.1.15.32", false); // server
				// name.

				connServerName = (String) vc_ServerName.elementAt(0);
				Vector vc_hostName = walkKPIInfo(
						".1.3.6.1.4.1.140.625.360.1.70", false); // host
				// name
				hostName = (String) vc_hostName.elementAt(0);
				this.hostname = hostName;

				for (Iterator connName = vc_ConnPollName.iterator(); connName
						.hasNext();) {
					String temp = (String) connName.next();
					unitID = unitID + ":" + this.ip + "-" + this.servicename
							+ "-" + connDomain + "-" + temp + "-TotalCount";

					setResult(count[j], unitID, "CM-00-04-003-04");
					unitID = "10-12-11-11-11";
					j++;
				}

			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		// System.out.println("End getjdbcConnectionPoolMaxCapacity");
	}

	/**
	 * The The current total active connections of this JDBC pool:
	 * .1.3.6.1.4.1.140.625.190.1.25 JDBC 连接池的已经激活的连接数:
	 * .1.3.6.1.4.1.140.625.190.1.25
	 */
	private void getjdbcConnectionPoolActiveConnectionsCurrentCount() {
		String unitID = "10-12-11-11-12";
		String connDomain = "";
		String connServerName = "";
		String hostName = "";
		String[] active = null;
		System.out
				.println("Begin getjdbcConnectionPoolActiveConnectionsCurrentCount");
		Vector vc_active = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.25", true);
		Vector vc_ConnPollName = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.15",
				false); // connPool
		// Name
		int k = 0;

		active = new String[vc_active.size()];
		for (Iterator activee = vc_active.iterator(); activee.hasNext();) {
			active[k] = (String) activee.next();
			k++;
		}

		int j = 0;
		Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain
		// name
		String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
		connDomain = domain[domain.length - 2]; // get Domain

		Vector vc_ServerName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.15.32",
				false); // server
		// name.

		connServerName = (String) vc_ServerName.elementAt(0);
		Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", false); // host
		// name
		hostName = (String) vc_hostName.elementAt(0);
		this.hostname = hostName;
		for (Iterator connName = vc_ConnPollName.iterator(); connName.hasNext();) {
			String temp = (String) connName.next();
			unitID = "10-12-11-12-13" + ":" + this.ip + "-" + this.servicename
					+ "-" + connDomain + "-" + temp + "-useRate";

			setResult(active[j], unitID, "PM-00-04-003-03");
			unitID = "10-12-11-11-12";
			j++;
		}
		for (Iterator d = vc_active.iterator(); d.hasNext();) {
			System.out.println("vc_active-----" + (String) d.next().toString());
		}
		// String count = (String) vc_active.elementAt(0);
		// System.out.println("ActiveConncount=" + count);
		// setResult(count, "unitID", "PM-00-04-003-03");

		System.out
				.println("End getjdbcConnectionPoolActiveConnectionsCurrentCount");
	}

	/**
	 * 1. 函数说明: The using rate of the current JDBC pool: JDBC 连接池的连接使用率=JDBC
	 * 连接池的已经激活的连接数/JDBC 连接池的最大容量*100 = (.1.3.6.1.4.1.140.625.190.1.25) *
	 * 100F/(.1.3.6.1.4.1.140.625.190.1.60) 2. JDBC
	 * 连接池的已经激活的连接数:.1.3.6.1.4.1.140.625.190.1.25 3. JDBC
	 * 连接池的最大容量:.1.3.6.1.4.1.140.625.190.1.60
	 * 
	 */
	private void getJdbcPoolUseRate(HashMap params) {
		try {

			String connPoolName = "";
			String connDomain = "";
			String connServerName = "";
			String hostName = "";
			String[] max_ = null;
			String[] active_ = null;
			System.out.println("Begin getJdbcPoolUseRate");

			/*
			 * int poolNum =
			 * Integer.parseInt(weblogicconfig.getString("JDBCPOOL.NUM.WEBLOGIC.server."+i).trim());
			 * System.out.println("poolNum="+poolNum+","+"JDBCPOOL.NUM.WEBLOGIC.server."+i);
			 */

			int poolNum = Integer
					.parseInt(((String) params.get("JDBCPOOL.NUM")).trim());
			if (poolNum == 1) {

				Vector vc_Max = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.55",
						false);

				Vector vc_ConnPollName = walkKPIInfo(
						".1.3.6.1.4.1.140.625.190.1.15", false); // connPool
				// Name

				connPoolName = (String) vc_ConnPollName.elementAt(0);
				Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
						false); // domain name
				String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
				connDomain = domain[domain.length - 2]; // get Domain
				Vector vc_ServerName = walkKPIInfo(
						".1.3.6.1.4.1.140.625.360.1.15.32", false); // server
				// name
				String[] connName = new String[vc_ConnPollName.size()];
				int m = 0;
				for (Iterator itera = vc_ConnPollName.iterator(); itera
						.hasNext();) {
					connName[m] = itera.next().toString();
					m++;

				}
				// name.
				connServerName = (String) vc_ServerName.elementAt(0);
				Vector vc_hostName = walkKPIInfo(
						".1.3.6.1.4.1.140.625.360.1.70", false); // host name
				hostName = (String) vc_hostName.elementAt(0);

				String unitID = "10-12-11-11-13:";
				max_ = new String[vc_Max.size()];
				int i = 0;
				int j = 0;

				if (vc_Max.size() > 0) {
					int Max_num = Integer.parseInt(((String) vc_Max
							.elementAt(0)).trim());// get max conn count

					Vector vc_Active = walkKPIInfo(
							".1.3.6.1.4.1.140.625.190.1.25", false);
					active_ = new String[vc_Active.size()];
					for (Iterator active = vc_Active.iterator(); active
							.hasNext();) {
						active_[i] = (String) active.next();

						System.out.println("active--" + active_[i]);
						i++;
					}

					for (Iterator max = vc_Max.iterator(); max.hasNext();) {
						max_[j] = (String) max.next();

						System.out.println("max--" + max_[j]);
						j++;
					}
					if (vc_Active.size() > 0) {
						int Active_num = Integer.parseInt(((String) vc_Active
								.elementAt(0)).trim());// get active conn count
						float userate = 0;
						if (Max_num != 0) {
							for (int k = 0, l = 0; k < max_.length; k++) {
								unitID = unitID + this.ip + "-"
										+ this.servicename + "-" + connDomain
										+ connName[k] + "-useRate";
								System.out.println("active_[k]--"
										+ Float.parseFloat(active_[k]));
								System.out.println("max_[k]]--"
										+ Float.parseFloat(max_[k]));
								userate = Float.parseFloat(active_[k]) * 100F
										/ Float.parseFloat(max_[k]);
								setResult(String.valueOf(userate), unitID,
										"PM-00-04-003-02");

								unitID = "10-12-11-11-11:";

								System.out.println("userrate=" + userate);
							}

							System.out.println("JdbcPoolUseRate=" + userate);
						}
					}
				}
			}// end of " if(poolNum ==1)": I have to configure one connection
			// pool
			// of one server for testing.

			System.out.println("End getJdbcPoolUseRate");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 执行队列的名字(一个table4个值): .1.3.6.1.4.1.140.625.361.1.15
	 * 10-12-11-10-10:-->10-12-11-11-10:
	 */
	private void collCluser() {
		String hostName = "";
		String connDomain = "";
		String flag = "true";

		// String oid =
		// ((String)hs.get("executeQueuePendingRequestCount.OID")).trim();
		try {
			Vector rc = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.80", false);
			Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
					false); // domain name
			String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
			connDomain = domain[domain.length - 2]; // get Domain
			Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70",
					false); // host name
			hostName = (String) vc_hostName.elementAt(0);

			String unitID = "10-12-11-11-10:" + this.ip + "-"
					+ this.servicename + "-"
					+ Formater.neatenunitid(connDomain) + "-"
					+ this.servicename + "-runmodel";

			String requestNum = (String) rc.elementAt(0);
			if (((String) rc.elementAt(0)).endsWith("ClusterRuntime")) {
				flag = "false";
			}
			setResult(flag, unitID, "CM-00-04-003-01");
		} catch (Exception e) {
			logger.error(e);
		}

	}

	/**
	 * @author pc103
	 * @date 2006-07-21
	 * @param oid
	 * @param bool
	 * @return vector 参数说明书: oid-----对应weblogic控制台监控的性能指标id(关键) bool----无多大用处
	 *         功能:储存各采集结果 返回类型:vector
	 * 
	 */
	public Vector walkKPIInfo(String oid, boolean bool) {
		Vector tmp_result = new Vector();
		try {
			Vector tmp_oid = new Vector();
			target.setObjectID(oid);

			target.oidList[0] = new com.adventnet.snmp.snmp2.SnmpOID(oid);// .1.3.6.1.4.1.11.2.3.1.2.2.1
			// Each
			// entry
			// contains
			// objects
			// for a
			// particular
			// file
			// system.(HP)
			int maxtry = 0;
			com.adventnet.snmp.snmp2.SnmpOID[] oidList = target
					.getSnmpOIDList();
			// System.out.println("oidList.length="+oidList.length);

			if (oidList == null) {
				System.out.println("oidList is null");
				return null;

			} else {
				SnmpOID rootoid = oidList[0];
				SnmpOID curroid = null;

				while (maxtry++ < 3000) { // limit the max getnexts to 5000

					String result1[] = target.snmpGetNextList();
					if (result1 == null) {
						target.oidList[0] = curroid;

						continue;
						// break;
					}
					if (!SnmpTarget.isInSubTree(rootoid, target.getSnmpOID()))
						break; // check first column
					// System.out.println("result1.length=" +result1.length);
					for (int i = 0; i < result1.length; i++) { // print the
						// values
						// System.out.println(target.getObjectID(i) + ": "
						// + result1[i]);
						tmp_result.add(result1[i]);
						tmp_oid.add(target.getObjectID(i));

					}

					if (result1[0].compareTo("NULL") == 0)
						break;
				}

				if (maxtry == 1) { // we did not get a valid row
					System.err
							.println("Request failed, timed out or no available data("
									+ oid + "). \n " + target.getErrorString());
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tmp_result;
	}

	/**
	 * 1. 得到OID中特有的惟一标识的那部分 2.
	 */

	String getQueueString(String str1, int i) {

		String str_unique = str1.substring(i);

		return str_unique;
	}

	/**
	 * @param weblogicip
	 * @param servername
	 * @param port
	 * @param hostname
	 * @param community
	 * @exception
	 * @express 建立与weblogic7.0的初始连接,特别注意port指的是
	 *          weblogic的snmp的port,并非weblogic所开服务监听的port
	 */
	public void initWeblogic(String weblogicip, String servername, int port,
			String hostname, String community) {
		try {
			this.ObjectIP = weblogicip;
			System.out.println("weblogicip=" + weblogicip);
			// this.KBP_ID = kbp_id;
			// String authProtocol = new String("NO_AUTH");
			// Use an SNMP target bean to perform SNMP operations
			target = new SnmpTarget();
			// target.setLoadFromCompiledMibs(true);
			target.setDebug(DEBUG);
			if(this.snmp_version.equals("1")){
				target.setSnmpVersion(SnmpTarget.VERSION1);
			}else if(this.snmp_version.equals("2")){
				target.setSnmpVersion(SnmpTarget.VERSION2C);
			}else if(this.snmp_version.equals("3")){
				target.setSnmpVersion(SnmpTarget.VERSION3);
			}
			target.setTargetHost(ObjectIP); // set the agent hostname

			// target.setTargetHost(hostname); // set the agent hostname(ip or
			// hostname):ip of HP workstation
			System.out.println("hostname=" + hostname);
			// target.setTargetHost( "SUNE450" ); // set the agent hostname:
			// solaris
			// target.setTargetHost( "iona" ); // set the agent hostname:
			// windows
			/* SUNE450 是主机的hostname. */
		/*	String weblogic_COMMUNITY = community.trim() + "@".trim()
					+ servername.trim();
			System.out.println("weblogic_COMMUNITY=" + weblogic_COMMUNITY);
			target.setCommunity(weblogic_COMMUNITY);*/

			target.setCommunity( community.trim());
			/**
			 * 关于weblogic多多服务器情况下,如何采集不同的server的值的方法,主要
			 * 就是设置COMMUNITY的值,在这个我以admin server with clustered servers的
			 * 情况来说明,domain name=mydomain2,administrtation server = myserver,
			 * managed server = server1.
			 * 1.如果取myserver的相关的OID的值,COMMUNITY="public";
			 * 2.如果取server1的相关的OID的值,COMMUNITY="public@server1";
			 * 3.如果取整个domain的所有server的相关的OID的值,COMMUNITY="public@mydomain2";
			 */
			target.setTargetPort(port);
			System.out.println("port=" + port);
			// target.setRetries( RETRIES );
			// target.setTimeout( TIMEOUT );
			// if (target.getSnmpVersion() == target.VERSION3) {
			// target.create_v3_tables();
			// }
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 释放initWeblogic(String weblogicip,String servername,int port, String
	 * hostname,String community) 申请的资源
	 */
	public void release() {
		target.releaseResources();
	}
}