CollHost20100625.java 32.9 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
package com.sitech.ismp.coll.tivoli;

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

import org.apache.log4j.Logger;

import com.sitech.util.Formater;

/**
 * 该类只采集 规范中的 ibm提供采集方法的 主机相关指标
 * 
 * @author winnerbao
 * 
 */
public class CollHost20100625 {

	private boolean debug = false;

	private SoapClient soapClient = null;

	private String pre_unitid = "";

	private Logger logger = Logger.getLogger("COLL");

	/**
	 * 
	 * @param pre_unit
	 *            对于aix , pre_unit="10-10-20" 对于hp-ux , pre_unit="10-10-21"
	 *            对于solaris , pre_unit="10-10-22"
	 */
	public CollHost20100625(String pre_unit) {
		this.pre_unitid = pre_unit;

		// 
		String url = SoapParam.getString("SOAP_URL");
		soapClient = new SoapClient(url);
	}

	public Vector getPMMemory_Ten_Minute(java.util.HashMap params)
			throws Exception {
		String host_name = (String) params.get("HOST_NAME");
		String neat_host_name = Formater.neatenunitid(host_name);
		String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
		com.sitech.ismp.coll.CollBase collResult = new com.sitech.ismp.coll.CollBase();
		String Used_Real_Mem_Pct = "";
		try {

			// 采集PM-00-01-002-01/02/03/04/08/05
			// object=System
			String soap_memory_System = CollHostSoapHelper
					.getSoap_memory_System(soap_host_name); // soap消息
			String soap_memory_System_res = soapClient
					.getSoapStringResponse(soap_memory_System);
			List system_results1 = CollHostXmlHelper
					.parseSoapResponse(soap_memory_System_res);
			if (system_results1 == null || system_results1.size() < 1) {
				System.out
						.println("@tivoli , no System info got by tivoli in collMemory : "
								+ new Date());
			} else {
				// 该结果中,肯定只有一条记录,这是由tivoli机制所保证的
				Map system_map = (Map) system_results1.get(0);
				String Free_Memory = (String) system_map.get("Free_Memory");
				String Total_Real_Memory = (String) system_map
						.get("Total_Real_Memory");
				// double memory_use_rate = 100*( 1-
				// Double.parseDouble(Free_Memory)/Double.parseDouble(Total_Real_Memory));
				logger.info("Memorykpi:Free_Memory=" + Free_Memory
						+ ",Total_Real_Memory= " + Total_Real_Memory);
				double memory_use_rate = 100 - 100 * (Double
						.parseDouble(Free_Memory) / Double
						.parseDouble(Total_Real_Memory));
				String Page_Ins = (String) system_map.get("Page_Ins");
				String Page_Outs = (String) system_map.get("Page_Outs");
				double page_in_and_out = Double.parseDouble(Page_Ins)
						+ Double.parseDouble(Page_Outs);

				String Processes_in_Run_Queue = (String) system_map
						.get("Processes_in_Run_Queue");

				String Logical_Block_Reads = (String) system_map
						.get("Logical_Block_Reads");
				String Logical_Block_Writes = (String) system_map
						.get("Logical_Block_Writes");
				String Block_Reads = (String) system_map.get("Block_Reads");
				String Block_Writes = (String) system_map.get("Block_Writes");
				double lread = Double.parseDouble(Logical_Block_Reads);
				double lwrite = Double.parseDouble(Logical_Block_Writes);
				double bread = Double.parseDouble(Block_Reads);
				double bwrite = Double.parseDouble(Block_Writes);

				double hit_rate = 0;
				if ((lread + lwrite) == 0) {
					hit_rate = 0;
				} else {
					// hit_rate = 100*( (lread - bread)+ (lwrite - bwrite)*1.0 /
					// (lread+lwrite));
					hit_rate = 100 * ((lread - bread) * 1.0 / lread);
					logger
							.info("Memorykpi:lread=" + lread + ",bread= "
									+ bread);
				}
				logger.info("Used_Real_Mem_Pct == " + Used_Real_Mem_Pct
						+ " ****");
				collResult.addKPI(pre_unitid + "-12:" + neat_host_name
						+ "-memory", "PM-00-01-002-01", getByScale(String
						.valueOf(memory_use_rate)));
				collResult.addKPI(pre_unitid + "-12:" + neat_host_name
						+ "-memory", "PM-00-01-002-02", String
						.valueOf(page_in_and_out));
				collResult.addKPI(pre_unitid + "-12:" + neat_host_name
						+ "-memory", "PM-00-01-002-03", Page_Ins);
				collResult.addKPI(pre_unitid + "-12:" + neat_host_name
						+ "-memory", "PM-00-01-002-04", Page_Outs);
				collResult.addKPI(pre_unitid + "-12:" + neat_host_name
						+ "-memory", "PM-00-01-002-05", Processes_in_Run_Queue);
				collResult.addKPI(pre_unitid + "-12:" + neat_host_name
						+ "-memory", "PM-00-01-002-08", String
						.valueOf(hit_rate));
			}

		} catch (Exception e) {
			logger.error("collhost memory error");
			e.printStackTrace();

		}

		return collResult.getKPISet();
	}

	public Vector getPerformance_Ten_Minute(java.util.HashMap params)
			throws Exception {
		String host_name = (String) params.get("HOST_NAME");
		String neat_host_name = Formater.neatenunitid(host_name);
		String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
		com.sitech.ismp.coll.CollBase collResult = new com.sitech.ismp.coll.CollBase();
		String Used_Real_Mem_Pct = "";
		try {
			// 采集PM-00-01-01-01/02/03/04/05
			// object=SMP_CPU
			System.out.println(new Date());
			String soap_cpu_SMPCPU = CollHostSoapHelper
					.getSoap_cpu_SMPCPU(soap_host_name); // soap消息
			String soap_cpu_SMPCPU_res = soapClient
					.getSoapStringResponse(soap_cpu_SMPCPU);
			System.out.println(new Date());
			if (debug)
				System.out.println(new Date() + soap_cpu_SMPCPU_res);

			List cpu_results = CollHostXmlHelper
					.parseSoapResponse(soap_cpu_SMPCPU_res);
			Map cpu_aggregate = null;
			// 得到 CPU_ID=aggregate 的那个 aggregate
			for (int i = 0; i < cpu_results.size(); i++) {
				Map cpu = (Map) cpu_results.get(i);
				String cpu_id = (String) cpu.get("CPU_ID");
				if (cpu_id.equals("aggregate")) {
					cpu_aggregate = cpu;
					break;
				}
			}
			if (cpu_aggregate == null) {
				System.out
						.println("@tivoli , no cpu info got by tivoli in collCpu "
								+ new Date());
			} else {
				collResult.addKPI(
						pre_unitid + "-11:" + neat_host_name + "-cpu",
						"PM-00-01-001-01", (String) cpu_aggregate
								.get("Idle_CPU"));
				collResult.addKPI(
						pre_unitid + "-11:" + neat_host_name + "-cpu",
						"PM-00-01-001-02", (String) cpu_aggregate
								.get("System_CPU"));
				collResult.addKPI(
						pre_unitid + "-11:" + neat_host_name + "-cpu",
						"PM-00-01-001-03", (String) cpu_aggregate
								.get("User_CPU"));
				collResult.addKPI(
						pre_unitid + "-11:" + neat_host_name + "-cpu",
						"PM-00-01-001-04", (String) cpu_aggregate
								.get("Wait_IO"));
				collResult.addKPI(
						pre_unitid + "-11:" + neat_host_name + "-cpu",
						"PM-00-01-001-05", (String) cpu_aggregate
								.get("CPU_Busy"));
			}

		} catch (Exception e) {
			logger.error("collhost cpu error");
			e.printStackTrace();
		}

		return collResult.getKPISet();
	}

	public Vector getPMFileSys_Fifteen_Minute(java.util.HashMap params)
			throws Exception {
		String host_name = (String) params.get("HOST_NAME");
		String ua_host_name = UaHostHelper.getUaHostName(host_name);
		String neat_host_name = Formater.neatenunitid(host_name);
		String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
		com.sitech.ismp.coll.CollBase collResult = new com.sitech.ismp.coll.CollBase();
		try {
			// 得到soap请求
			String soap_filesystem_Disk = CollHostSoapHelper
					.getSoap_filesystem_Disk(soap_host_name); // soap消息
			// 发送soap请求,并返回结果
			String soap_filesystem_Disk_res = soapClient
					.getSoapStringResponse(soap_filesystem_Disk);
			// 分析返回结果,得到list
			List disk_results = CollHostXmlHelper
					.parseSoapResponse(soap_filesystem_Disk_res);

			// 获取每个文件系统的kpi值,顺便计算总的文件系统大小和总的已使用文件系统大小
			long total_filesystem = 0;
			long used_filesystem = 0;
			if (disk_results == null || disk_results.size() < 1) {
				System.out
						.println("@tivoli , no System info got by tivoli in disk : "
								+ new Date());
			} else {
				for (int i = 0; i < disk_results.size(); i++) {
					Map diskMap = (Map) disk_results.get(i);
					String Mount_Point = (String) diskMap.get("Mount_Point");
					String Space_Used_Percent = (String) diskMap
							.get("Space_Used_Percent");
					String Size = (String) diskMap.get("Size");
					String Space_Used = (String) diskMap.get("Space_Used");

					if (Mount_Point == null || "".equals(Mount_Point.trim())) {
						continue;
					}
					String neatMount_Point = Formater.neatenunitid(Mount_Point);
					collResult.addKPI(pre_unitid + "-14:" + neat_host_name
							+ "-" + neatMount_Point, "PM-00-01-004-03",
							Space_Used_Percent);
					// collResult.addKPI(pre_unitid+"-14:"+neat_host_name+"-"+neatMount_Point,"PM-00-01-004-01",Space_Used_Percent);
					// collResult.addKPI(pre_unitid + "-14:" + neat_host_name
					// + "-" + neatMount_Point, "CM-00-01-001-16",
					// neatMount_Point);

					/*
					 * total_filesystem = total_filesystem +
					 * Long.parseLong(Size); used_filesystem = used_filesystem +
					 * Long.parseLong(Space_Used); // PM-00-01-004-01
					 * 文件系统总占用率需要计算 if (total_filesystem > 0) {
					 * collResult.addKPI(pre_unitid + "-10:" + neat_host_name +
					 * "-total", "PM-00-01-004-01",
					 * getByScale(String.valueOf(used_filesystem * 100.0 /
					 * total_filesystem))); } else {
					 * collResult.addKPI(pre_unitid + "-10:" + neat_host_name +
					 * "-total", "PM-00-01-004-01", String.valueOf(0)); }
					 */
				}
			}

		} catch (Exception e) {
			logger.error("collhost total error == " + host_name);
			e.printStackTrace();
		}
		return collResult.getKPISet();
	}

	public Vector getPerformance_Fifteen_Minute(
			java.util.HashMap params) throws Exception {
		String host_name = (String) params.get("HOST_NAME");
		String ua_host_name = UaHostHelper.getUaHostName(host_name);
		String neat_host_name = Formater.neatenunitid(host_name);
		String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
		com.sitech.ismp.coll.CollBase collResult = new com.sitech.ismp.coll.CollBase();

		try {
			// PM-00-01-004-02 Object=System 改用UNIX_Memory
			// String soap_filesystem_System =
			// CollHostSoapHelper.getSoap_filesystem_System(soap_host_name);
			// //soap消息
			String soap_filesystem_System = CollHostSoapHelper
					.getSoap_Unix_Memory(soap_host_name); // soap消息
			String soap_filesystem_System_res = soapClient
					.getSoapStringResponse(soap_filesystem_System);
			List system_results = CollHostXmlHelper
					.parseSoapResponse(soap_filesystem_System_res);
			if (system_results == null || system_results.size() < 1) {

				String soap_file_System = CollHostSoapHelper
						.getSoap_filesystem_System(soap_host_name); // soap消息
				String soap_file_System_res = soapClient
						.getSoapStringResponse(soap_file_System);
				List system_results1 = CollHostXmlHelper
						.parseSoapResponse(soap_file_System_res);
				if (system_results1 == null || system_results1.size() < 1) {
					System.out
							.println("@tivoli , no System info got by tivoli in collMemory : "
									+ new Date());
				} else {
					logger.info("getSoap_filesystem_System ==== ");
					// 该结果中,肯定只有一条记录,这是由tivoli机制所保证的
					Map system_map = (Map) system_results1.get(0);
					String Swap_Space_Free = (String) system_map
							.get("Swap_Space_Free");
					String Total_Virtual_Memory = (String) system_map
							.get("Total_Virtual_Memory");
					String Total_Real_Memory = (String) system_map
							.get("Total_Real_Memory");
					double swap_use_rate = 100D * (1.0D - (Double
							.parseDouble(Swap_Space_Free) * 1024D)
							/ (Double.parseDouble(Total_Virtual_Memory) - Double
									.parseDouble(Total_Real_Memory)));
					logger.info(pre_unitid
							+ "-10:"
							+ neat_host_name
							+ "-total"
							+ " PM-00-01-004-02 "
							+ Formater.formatDecimalKpivalue(String
									.valueOf(swap_use_rate)));
					collResult.addKPI(pre_unitid + "-10:" + neat_host_name
							+ "-total", "PM-00-01-004-02", Formater
							.formatDecimalKpivalue(String
									.valueOf(swap_use_rate)));

				}
			} else {
				// 该结果中,肯定只有一条记录,这是由tivoli机制所保证的
				Map system_map = (Map) system_results.get(0);

				/*
				 * String Total_Swap_Space_MB = (String) system_map
				 * .get("Total_Swap_Space_MB");
				 */
				String Used_Swap_Space_Pct = (String) system_map
						.get("Used_Swap_Space_Pct");
				/*
				 * String Total_Real_Mem_MB = (String) system_map
				 * .get("Total_Real_Mem_MB"); String Used_Real_Mem_Pct =
				 * (String) system_map .get("Used_Real_Mem_Pct");
				 */
				// System.out.println("Swap_Space_Free:"+Swap_Space_Free);
				// System.out.println("Total_Virtual_Memory:"+Total_Virtual_Memory);
				// System.out.println("Total_Real_Memory:"+Total_Real_Memory);
				// double swap_use_rate = 100*(1 -
				// Double.parseDouble(Swap_Space_Free)*1024/(Double.parseDouble(Total_Virtual_Memory)-Double.parseDouble(Total_Real_Memory)));
				collResult.addKPI(pre_unitid + "-10:" + neat_host_name
						+ "-total", "PM-00-01-004-02", Formater
						.formatDecimalKpivalue(String
								.valueOf(Used_Swap_Space_Pct)));

			}

		} catch (Exception e) {
			logger.error("collhost total error1");
			e.printStackTrace();
		}

		try {
			// PM-00-01-005-01/02/03/04/05
			// Object=Process
			String soap_process_Process = CollHostSoapHelper
					.getSoap_process_Process(soap_host_name); // soap消息
			String soap_process_Process_res = soapClient
					.getSoapStringResponse(soap_process_Process);
			List process_results = CollHostXmlHelper.parseSoapResponse(
					soap_process_Process_res, "UTF-8");

			// 获取每个进程相关值
			if (process_results == null || process_results.size() < 1) {
				logger
						.info("@tivoli , no System info got by tivoli in Process = "
								+ soap_host_name);
				System.out
						.println("@tivoli , no System info got by tivoli in Process : "
								+ new Date());
			} else {
				for (int i = 0; i < process_results.size(); i++) {
					Map processMap = (Map) process_results.get(i);

					/*
					 * String CPU_Utilization = (String) processMap
					 * .get("CPU_Utilization");
					 */
					// CPU_Utilization = CPU_Utilization.replaceAll("'","''");
					String Execution_State = (String) processMap
							.get("Execution_State");
					// String Command = (String)processMap.get("Command") ;
					// //此属性返回没参数,可能造成进程名称一致的情况
					String Command = (String) processMap.get("Process_Command"); // 此属性返回100个字以内的参数
					Command = Command.replaceAll("'", "''");

					/*
					 * String timevalue = (String) processMap.get("StartTime");
					 * 
					 * String year = timevalue.substring(1, 3); year = "20" +
					 * year; String month = timevalue.substring(3, 5); String
					 * day = timevalue.substring(5, 7); String hour =
					 * timevalue.substring(7, 9); String min =
					 * timevalue.substring(9, 11); String sec =
					 * timevalue.substring(11, 13); String StartTime = year +
					 * "-" + month + "-" + day + " " + hour + ":" + min + ":" +
					 * sec;
					 * 
					 * String Size = (String) processMap.get("Size");
					 */

					/*
					 * collResult .addKPI(pre_unitid + "-15:" + neat_host_name +
					 * "-" + Command, "PM-00-01-005-01", CPU_Utilization);
					 */
					collResult
							.addKPI(pre_unitid + "-15:" + neat_host_name + "-"
									+ Command, "PM-00-01-005-02",
									Execution_State);
					/*
					 * collResult.addKPI(pre_unitid + "-15:" + neat_host_name +
					 * "-" + Command, "PM-00-01-005-03", Command);
					 * collResult.addKPI(pre_unitid + "-15:" + neat_host_name +
					 * "-" + Command, "PM-00-01-005-04", StartTime);
					 * collResult.addKPI(pre_unitid + "-15:" + neat_host_name +
					 * "-" + Command, "PM-00-01-005-05", Size);
					 */

				}
			}
		} catch (Exception e) {
			logger.error("collhost total-15 error1");
			e.printStackTrace();
		}
		try {
			// PM-00-01-005-06
			String Soap_System_Situations_Unix_Os = CollHostSoapHelper
					.getSoap_System_Situations_Unix_Os(ua_host_name);
			String Soap_System_Situations_Unix_Os_res = soapClient
					.getSoapStringResponse(Soap_System_Situations_Unix_Os);
			List Unix_Os_result = CollHostXmlHelper
					.parseSoapResponse(Soap_System_Situations_Unix_Os_res);
			if (Unix_Os_result == null || Unix_Os_result.size() == 0) {
				collResult.addKPI(pre_unitid + "-10:" + neat_host_name
						+ "-total", "FM-00-01-900-03", "DOWN");
			} else {
				collResult.addKPI(pre_unitid + "-10:" + neat_host_name
						+ "-total", "FM-00-01-900-03", "UP");
				/*
				 * for (int i = 0; i < Unix_Os_result.size(); i++) { // UserName //
				 * ProcessNumber Map rowMap = (Map) Unix_Os_result.get(i);
				 * String username = (String) rowMap.get("UserName"); String
				 * processnumber = (String) rowMap.get("ProcessNumber");
				 * collResult.addKPI(pre_unitid + "-18:" + neat_host_name + "-" +
				 * username, "PM-00-01-005-06", processnumber);
				 * collResult.addKPI(pre_unitid + "-18:" + neat_host_name + "-" +
				 * username, "CM-00-01-900-03", username); }
				 */
			}
		} catch (Exception e) {
			logger.error("collhost total-10 error1");
			e.printStackTrace();
		}

		return collResult.getKPISet();
	}

	public Vector getPerformance_One_Hour(java.util.HashMap params)
			throws Exception {

		String host_name = (String) params.get("HOST_NAME");
		String neat_host_name = Formater.neatenunitid(host_name);
		String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
		com.sitech.ismp.coll.CollBase collResult = new com.sitech.ismp.coll.CollBase();
		try {
			// 采集PM-00-01-003-01
			// object=Disk_Performance
			String soap_disk_DiskPerformance = CollHostSoapHelper
					.getSoap_disk_DiskPerformance(soap_host_name); // soap消息
			String soap_disk_DiskPerformance_res = soapClient
					.getSoapStringResponse(soap_disk_DiskPerformance);
			List diskp_results = CollHostXmlHelper
					.parseSoapResponse(soap_disk_DiskPerformance_res);
			if (diskp_results == null || diskp_results.size() < 1) {
				System.out.println("@tivoli , no Disk Perf info got by tivoli"
						+ new Date());
			} else {
				// 该结果中,肯定只有一条记录,这是由tivoli机制所保证的
				for (int i = 0; i < diskp_results.size(); i++) {
					Map diskper_map = (Map) diskp_results.get(i);
					String Transfer_Rate = (String) diskper_map
							.get("Transfer_Rate");
					String Disk_Name_U = (String) diskper_map
							.get("Disk_Name_U");
					String neat_disk_name_u = Formater
							.neatenunitid(Disk_Name_U);

					collResult.addKPI(pre_unitid + "-13:" + neat_host_name
							+ "-" + neat_disk_name_u, "PM-00-01-003-01",
							Transfer_Rate);
					// collResult.addKPI(pre_unitid+"-13:"+neat_host_name+"-"+neat_disk_name_u,"CM-00-01-900-01",neat_disk_name_u);
					// 磁盘名称
					collResult.addKPI(pre_unitid + "-13:" + neat_host_name
							+ "-" + neat_disk_name_u, "CM-00-01-001-20",
							neat_disk_name_u);

					String Avg_Queue = (String) diskper_map.get("Avg_Queue");
					String Avg_Wait = (String) diskper_map.get("Avg_Wait");
					// String Avg_Serv = (String)diskper_map.get("Avg_Serv");
					// String Percent_Disk_Read_Time =
					// (String)diskper_map.get("Percent_Disk_Read_Time");
					// String Percent_Disk_Write_Time =
					// (String)diskper_map.get("Percent_Disk_Write_Time");
					String Disk_Reads_Sec = (String) diskper_map
							.get("Disk_Reads_Sec");
					String Disk_Writes_Sec = (String) diskper_map
							.get("Disk_Writes_Sec");
					// String Disk_Read_Bytes_Sec =
					// (String)diskper_map.get("Disk_Read_Bytes_Sec");
					// String Disk_Write_Bytes_Sec =
					// (String)diskper_map.get("Disk_Write_Bytes_Sec");
					String Busy_Percent = (String) diskper_map
							.get("Busy_Percent");

					collResult.addKPI(pre_unitid + "-13:" + neat_host_name
							+ "-" + neat_disk_name_u, "PM-00-01-003-03",
							Busy_Percent);
					collResult.addKPI(pre_unitid + "-13:" + neat_host_name
							+ "-" + neat_disk_name_u, "PM-00-01-003-04",
							Disk_Reads_Sec);
					collResult.addKPI(pre_unitid + "-13:" + neat_host_name
							+ "-" + neat_disk_name_u, "PM-00-01-003-05",
							Disk_Writes_Sec);
					collResult.addKPI(pre_unitid + "-13:" + neat_host_name
							+ "-" + neat_disk_name_u, "PM-00-01-003-06",
							Avg_Wait);
					collResult.addKPI(pre_unitid + "-13:" + neat_host_name
							+ "-" + neat_disk_name_u, "PM-00-01-003-07",
							Avg_Queue);
				}
			}
		} catch (Exception e) {
			logger.error("collhost getPerformance_One_Hour error1");
			e.printStackTrace();
		}

		try {
			/*
			 * PM-00-01-003-03 磁盘忙的百分比 磁盘读写的时间占用总时间的百分比 OOSTAT00
			 * OOSTATOOSTAT00.BusyPercent PM-00-01-003-04 每秒磁盘读请求 每秒磁盘读请求字节数
			 * OOSTAT00 OOSTATOOSTAT00.Kr_Per_Second PM-00-01-003-05 每秒磁盘写请求
			 * 每秒磁盘写请求字节数 OOSTAT00 OOSTATOOSTAT00.Kw_Per_Second
			 */
			/*
			 * String soap_OOSTAT =
			 * CollHostSoapHelper.getSoap_OOSTATOOSTAT00(host_name); String
			 * soap_OOSTAT_res = soapClient.getSoapStringResponse(soap_OOSTAT);
			 * List OOSTAT_results =
			 * CollHostXmlHelper.parseSoapResponse(soap_OOSTAT_res); for(int
			 * i=0;i<OOSTAT_results.size();i++) { Map resultMap =
			 * (Map)OOSTAT_results.get(i); String Device =
			 * (String)resultMap.get("Device"); String BusyPercent =
			 * (String)resultMap.get("BusyPercent"); String Kr_Per_Second =
			 * (String)resultMap.get("Kr_Per_Second"); String Kw_Per_Second =
			 * (String)resultMap.get("Kw_Per_Second"); String neat_device =
			 * Formater.neatenunitid(Device);
			 * 
			 * collResult.addKPI(pre_unitid+"-13:"+neat_host_name+"-"+neat_device,"PM-00-01-003-03",BusyPercent);
			 * collResult.addKPI(pre_unitid+"-13:"+neat_host_name+"-"+neat_device,"PM-00-01-003-04",Kr_Per_Second);
			 * collResult.addKPI(pre_unitid+"-13:"+neat_host_name+"-"+neat_device,"PM-00-01-003-05",Kw_Per_Second);
			 * collResult.addKPI(pre_unitid+"-13:"+neat_host_name+"-"+neat_device,"CM-00-01-900-01",neat_device); }
			 */
		} catch (Exception e) {
			logger.error("collhost getPerformance_One_Hour error");
			e.printStackTrace();
		}

		return collResult.getKPISet();
	}

	public Vector getConfiguration_One_Day(java.util.HashMap params)
			throws Exception {
		String host_name = (String) params.get("HOST_NAME");
		String ua_host_name = UaHostHelper.getUaHostName(host_name);
		String neat_host_name = Formater.neatenunitid(host_name);
		String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
		com.sitech.ismp.coll.CollBase collResult = new com.sitech.ismp.coll.CollBase();

		collResult.addKPI(this.pre_unitid + "-10" + ":" + neat_host_name
				+ "-total", "CM-00-01-001-50", (String) params.get("IP_ADDR"));

		try {
			// CM-00-01-001-13 系统交换区大小 总的SWAP区大小(MB)
			/*
			 * String Soap_OOAINFOSWAPINFO00 =
			 * CollHostSoapHelper.getSoap_OOAINFOSWAPINFO00(ua_host_name);
			 * String Soap_OOAINFOSWAPINFO00_res =
			 * soapClient.getSoapStringResponse(Soap_OOAINFOSWAPINFO00); List
			 * Soap_OOAINFOSWAPINFO00_result =
			 * CollHostXmlHelper.parseSoapResponse(Soap_OOAINFOSWAPINFO00_res);
			 * if(Soap_OOAINFOSWAPINFO00_result==null||Soap_OOAINFOSWAPINFO00_result.size()==0) {
			 * System.out.println("cannot get soap from
			 * getSoap_OOAINFOSWAPINFO00" + new Date().toString()); } else { int
			 * intTotalSwap = 0; Map rowMap =
			 * (Map)Soap_OOAINFOSWAPINFO00_result.get(0); String TotalSwap =
			 * (String)rowMap.get("TotalSwap"); intTotalSwap =
			 * Integer.parseInt(TotalSwap)/1024;
			 * collResult.addKPI(pre_unitid+"-10:"+neat_host_name+"-total","CM-00-01-001-13",String.valueOf(intTotalSwap)); }
			 */
			// Object = UNIX_Memory
			String soap_filesystem_System = CollHostSoapHelper
					.getSoap_Unix_Memory(soap_host_name); // soap消息
			String soap_filesystem_System_res = soapClient
					.getSoapStringResponse(soap_filesystem_System);
			List system_results = CollHostXmlHelper
					.parseSoapResponse(soap_filesystem_System_res);
			if (system_results == null || system_results.size() < 1) {
				System.out
						.println("@tivoli , no Unix_Memory info got by tivoli in collFileSystem"
								+ new Date());
			} else {
				// 该结果中,肯定只有一条记录,这是由tivoli机制所保证的
				Map system_map = (Map) system_results.get(0);

				String Total_Swap_Space_MB = (String) system_map
						.get("Total_Swap_Space_MB");
				/*
				 * String Used_Swap_Space_Pct = (String) system_map
				 * .get("Used_Swap_Space_Pct"); String Total_Real_Mem_MB =
				 * (String) system_map .get("Total_Real_Mem_MB"); String
				 * Used_Real_Mem_Pct = (String) system_map
				 * .get("Used_Real_Mem_Pct");
				 */

				collResult.addKPI(pre_unitid + "-10:" + neat_host_name
						+ "-total", "CM-00-01-001-13", Total_Swap_Space_MB);
			}

		} catch (Exception e) {
			logger.error("collhost getConfiguration_One_Day error");
			e.printStackTrace();
		}

		return collResult.getKPISet();
	}

	public Vector getFailure(java.util.HashMap params)
			throws Exception {
		String host_name = (String) params.get("HOST_NAME");
		String neat_host_name = Formater.neatenunitid(host_name);
		String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
		com.sitech.ismp.coll.CollBase collResult = new com.sitech.ismp.coll.CollBase();
		int count1 = 0;
		int count2 = 0;

		String status3 = "DOWN";
		try {

			String bnms1_status = CollHostSoapHelper
					.getSoap_PINGSERVERSPINGSTATS00_From_bnms1(host_name);
			String bnms2_status = CollHostSoapHelper
					.getSoap_PINGSERVERSPINGSTATS00_From_bnms2(host_name);
			String bnms3_status = CollHostSoapHelper
					.getSoap_PINGSERVERSPINGSTATS00_From_bnms3(host_name);
			System.out.println(new Date());
			String bnms1_status_res = soapClient
					.getSoapStringResponse(bnms1_status);
			String bnms2_status_res = soapClient
					.getSoapStringResponse(bnms2_status);
			String bnms3_status_res = soapClient
					.getSoapStringResponse(bnms3_status);
			List bnms1_status_result31 = CollHostXmlHelper
					.parseSoapResponse(bnms1_status_res);
			List bnms2_status_result32 = CollHostXmlHelper
					.parseSoapResponse(bnms2_status_res);
			List bnms3_status_result33 = CollHostXmlHelper
					.parseSoapResponse(bnms3_status_res);
			System.out.println(new Date());
			if (bnms1_status_result31 == null
					|| bnms1_status_result31.size() == 0) {
				collResult.addKPI(pre_unitid + "-10:" + "bnas1" + "-total",
						"FM-00-01-900-01", "PING " + host_name
								+ " NULL RESPONSE");
				count1++;
			} else {
				Map statusMap = (Map) bnms1_status_result31.get(0);
				status3 = ((String) statusMap.get("Status")).toUpperCase();
				if (status3.equalsIgnoreCase("DOWN")) {
					count2++;
				}

			}

			if (bnms2_status_result32 == null
					|| bnms2_status_result32.size() == 0) {
				collResult.addKPI(pre_unitid + "-10:" + "bnas2" + "-total",
						"FM-00-01-900-01", "PING " + host_name
								+ " NULL RESPONSE");
				count1++;

			} else {
				Map statusMap = (Map) bnms2_status_result32.get(0);
				status3 = ((String) statusMap.get("Status")).toUpperCase();
				if (status3.equalsIgnoreCase("DOWN")) {
					count2++;
				}
			}

			if (bnms3_status_result33 == null
					|| bnms3_status_result33.size() == 0) {
				collResult.addKPI(pre_unitid + "-10:" + "bnas3" + "-total",
						"FM-00-01-900-01", "PING " + host_name
								+ " NULL RESPONSE");
				count1++;
			} else {
				Map statusMap = (Map) bnms3_status_result33.get(0);
				status3 = ((String) statusMap.get("Status")).toUpperCase();
				if (status3.equalsIgnoreCase("DOWN")) {
					count2++;
				}
			}

			if (count1 < 3) {
				if (count2 == (3 - count1)) {
					// down
					collResult.addKPI(pre_unitid + "-10:" + neat_host_name
							+ "-total", "FM-00-01-001-01", "DOWN");
				} else {
					// up
					collResult.addKPI(pre_unitid + "-10:" + neat_host_name
							+ "-total", "FM-00-01-001-01", "UP");
				}
			} else {
				collResult.addKPI(pre_unitid + "-10:" + neat_host_name
						+ "-total", "FM-00-01-001-01", "UP");
			}

		} catch (Exception e) {
			logger.error("collhost getFailure error");
			e.printStackTrace();
		}

		/*
		 * String soap_cpu_Network =
		 * CollHostSoapHelper.getSoap_cpu_Network(soap_host_name); String
		 * soap_cpu_Network_res =
		 * soapClient.getSoapStringResponse(soap_cpu_Network); List
		 * Network_results =
		 * CollHostXmlHelper.parseSoapResponse(soap_cpu_Network_res); String
		 * Interface_Status_result="DOWN";
		 * if(Network_results==null||Network_results.size()==0) {
		 * collResult.addKPI(pre_unitid + "-10:" + neat_host_name +
		 * "-total","FM-00-01-900-01","DOWN"); collResult.addKPI(pre_unitid +
		 * "-10:" + neat_host_name + "-total","FM-00-01-001-01","UP"); } else {
		 * collResult.addKPI(pre_unitid + "-10:" + neat_host_name +
		 * "-total","FM-00-01-900-01","UP"); for(int i=0;i<Network_results.size();i++) {
		 * Map networkMap=(Map)Network_results.get(i); String Interface_Status =
		 * (String)networkMap.get("Interface_Status"); Interface_Status =
		 * Interface_Status.toUpperCase();
		 * //如果有一个interface_status为up整体状态视为up,所有为down整体状态视为down
		 * if(Interface_Status.equalsIgnoreCase("UP")) {
		 * Interface_Status_result="UP"; break; } } collResult.addKPI(pre_unitid +
		 * "-10:" + neat_host_name +
		 * "-total","FM-00-01-001-01",Interface_Status_result); }
		 */

		try {
			String soap_network_Network = CollHostSoapHelper
					.getSoap_network_Network(soap_host_name); // soap消息
			String soap_network_Network_res = soapClient
					.getSoapStringResponse(soap_network_Network);
			List network_results = CollHostXmlHelper
					.parseSoapResponse(soap_network_Network_res);

			// 获取每个网卡的信息
			for (int i = 0; i < network_results.size(); i++) {
				Map networkMap = (Map) network_results.get(i);
				String Network_Interface_Name = (String) networkMap
						.get("Network_Interface_Name");
				String Interface_Status = (String) networkMap
						.get("Interface_Status");

				if ("Aggregate".equals(Network_Interface_Name)) {
					continue;
				}
				collResult.addKPI(pre_unitid + "-16:" + neat_host_name + "-"
						+ Network_Interface_Name, "FM-00-01-001-03",
						Interface_Status);
				collResult.addKPI(pre_unitid + "-16:" + neat_host_name + "-"
						+ Network_Interface_Name, "CM-00-01-900-02",
						Network_Interface_Name);

			}

			if (HaHostHelper.isHaHost(host_name)) {
				String ha_host_name = HaHostHelper.getHaHostName(host_name);
				String Soap_HACMPCLUSTER = CollHostSoapHelper
						.getSoap_HACMPCLUSTER00(ha_host_name);
				String Soap_HACMPCLUSTER_res = soapClient
						.getSoapStringResponse(Soap_HACMPCLUSTER);
				List HACMPCLUSTER_result = CollHostXmlHelper
						.parseSoapResponse(Soap_HACMPCLUSTER_res);
				if (HACMPCLUSTER_result == null
						|| HACMPCLUSTER_result.size() == 0) {
					System.out
							.println("@tivoli error, no getSoap_HACMPCLUSTER00 info got by tivoli in CollHost "
									+ new Date());
				} else {
					for (int i = 0; i < HACMPCLUSTER_result.size(); i++) {
						Map resultMap = (Map) HACMPCLUSTER_result.get(i);
						String clusterState = (String) resultMap
								.get("clusterState");
						clusterState = clusterState.toUpperCase();
						collResult.addKPI(pre_unitid + "-10:" + neat_host_name
								+ "-total", "FM-00-01-001-04", clusterState);
					}
				}
			} else {
				collResult.addKPI(pre_unitid + "-10:" + neat_host_name
						+ "-total", "FM-00-01-001-04", "UNKNOW");
			}

		} catch (Exception e) {
			logger.error("collhost getFailure error1");
			e.printStackTrace();
		}
		try {
			String Soap_process_Execution = CollHostSoapHelper
					.getSoap_process_Execution(soap_host_name);
			String Soap_process_Execution_res = soapClient
					.getSoapStringResponse(Soap_process_Execution);
			List Execution_result = CollHostXmlHelper
					.parseSoapResponse(Soap_process_Execution_res);
			for (int i = 0; i < Execution_result.size(); i++) {
				Map ExecutionMap = (Map) Execution_result.get(i);
				String Execution_State = (String) ExecutionMap
						.get("Execution_State");
				String Command = (String) ExecutionMap.get("Command");
				collResult.addKPI(pre_unitid + "-15:" + neat_host_name + "-"
						+ Command, "FM-00-01-001-05", Execution_State);
			}
		} catch (Exception e) {
			logger.error("collhost getFailure error3");
			e.printStackTrace();
		}

		return collResult.getKPISet();
	}

	/**
	 * 
	 * 得到指定精度的double类型数值 精度设定为4
	 * 
	 * @param double_vlaue
	 * @return
	 */
	private String getByScale(String double_value) {
		int scale = 4;
		return Formater.getByScale(double_value, 2);
	}

	public static void main(String[] args) throws Exception {
		CollHost20100625 aix = new CollHost20100625("10-10-20");
		java.util.HashMap params = new java.util.HashMap();
		params.put("HOST_NAME", "DBServer01");

		Vector v = new Vector();

		// v.addAll(aix.getConfiguration_One_Day(params));
		v.addAll(aix.getPMMemory_Ten_Minute(params));
		v.addAll(aix.getPerformance_Ten_Minute(params));
		// v.addAll(aix.getPerformance_Fifteen_Minute(params));
		// v.addAll(aix.getPerformance_One_Hour(params));
		// v.addAll(aix.getPerformance_Ten_Minute(params));
		// String temp[][] = CheckKPIHelper.Check_AIX_HOST_KPI(v);
		// for(int i=0;i<temp.length;i++)
		// {
		// System.out.println("KPI_ID : " + temp[i][0] + "---" + temp[i][1]);
		// }
		String filename = "test1.xls";
		CheckKPIHelper.Write_KPIValue2File(v, filename);
	}

}