CollSUNWithCMD.java 21.5 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
package com.sitech.ismp.coll.centercoll;

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

import org.apache.log4j.Logger;

import com.sitech.ismp.coll.CollBase;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.util.DES3;
import com.sitech.util.Formater;
import com.sitech.util.Ping;
import com.sitech.util.upload.RomoteController;
import com.sitech.util.upload.SSHThread;
import com.sitech.util.upload.TelnetThread;

/**
 * @author zang
 * @author mao 修改日期:2009-1-17
 *         修改原因:与IBM、IP主机采集指标度量单位保持一致,将交换区大小指标CM-00-01-001-13的值/1024,单位升级到M
 * 
 *         不支持多线程调用
 */
public class CollSUNWithCMD extends CollBase {
	private String UNIT_ID = "10-10-22";

	String neat_host_name = "";
	
	String ip_addr = "";
	
	String value = null;

	String lang = null;

	String hostname = "";

	TblATO_KPIDETAIL record = null;

	boolean isConnect = false;

	/**
	 * @return 采集时间
	 */
	private String getCollTime(){
		try{
			return Formater.datetimeToString(new Date());
		}catch (Exception e) {
			logger.error("Exception while getCollTime()", e);
		}
		return null;
	}

	public Vector<TblATO_KPIDETAIL> getConfig(HashMap<String, String> params) {
		logger.info("Begin getConfig...");
		CollBase collResult = new CollBase();

		try {
			init(params);
			if(!tt.isAuthorized()){
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", tt.getError());
				return collResult.KPISet;
			}else{
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", "UP");
			}
			
			String totalUnitId = UNIT_ID + "-10:" +  neat_host_name + "-total";

			// 常用IP
			collResult.addKPI(totalUnitId, "CM-00-01-001-02", params.get("IP_ADDR"));

			try {
				Vector<String> vMemory = tt.getResultAsVector("/etc/prtconf -v | grep Memory");
				String memorySize = split(vMemory.get(0), 2);
				collResult.addKPI(totalUnitId, "CM-00-01-001-07", memorySize);
			} catch (Exception e) {
				logger.error("Exception while get memory size!",e);
			}
			
			// CPU个数
			collResult.addKPI(totalUnitId, "CM-00-01-001-04", getCpuNum());
			// CPU型号				
			collResult.addKPI(totalUnitId, "CM-00-01-001-05", getCpuType());
			// CPU主频				
			collResult.addKPI(totalUnitId, "CM-00-01-001-06", getCpuFrequency());
			// 单条内存大小 CM-00-01-001-45
			collResult.addKPI(totalUnitId, "CM-00-01-001-45", getMemoryType());
			
			// 交换分区大小				
			collResult.addKPI(totalUnitId, "CM-00-01-001-13", getSwapSize());

			try {
				Vector<String> lancard_num = tt
						.getResultAsVector("/usr/sbin/ifconfig -a |awk '{print $1}' |grep :");

				String lancard = String.valueOf(lancard_num.size() - 1);

				// KPI: CM-00-01-001-10 系统网络接口数
				collResult.addKPI(totalUnitId, "CM-00-01-001-10", lancard);

				for (int i = 0; i < lancard_num.size(); i++) {
					String temp = (String) lancard_num.elementAt(i);
					if (temp != null && temp.length() >= 2
							&& temp.substring(0, 2).equals("lo"))
						lancard_num.remove(temp);
				}
			} catch (Exception e) {
				logger.error("Exception while get lancard!", e);
			}

			try {
				Vector<String> getOS = tt.getResultAsVector("uname -a");

				//zhangdj-add
				//主机操作系统类型
				String host_type = "uname -s";
				Vector<String> vc_type = tt.getResultAsVector(host_type);
				host_type = split((String) vc_type.elementAt(0), 0);
				collResult.addKPI(totalUnitId, 
						"CM-00-01-001-010", 
						host_type);
				//主机型号
				String host_model = "uname  -i";
				Vector<String> vc_model = tt.getResultAsVector(host_model);
				host_model = split((String) vc_model.elementAt(0), 0);
				// 主机型号
				collResult.addKPI(totalUnitId, "CM-00-01-001-011", host_model);
				//主机名
				collResult.addKPI(totalUnitId, "CM-00-01-001-01", this.hostname);

				// 主机版本
				collResult.addKPI(totalUnitId, "CM-00-01-001-08", split((String) getOS
						.elementAt(0), 2));
			} catch (Exception e) {
				logger.error(e);
			}
			
			try {
				// id 使用 -14
				String fs_PRE_UNITID = this.UNIT_ID + "-14";
				// 16 CM-00-01-001-16 文件系统名称 文件系统的标识 1天 字符串型
				// 17 CM-00-01-001-17 文件系统的总空间 主机文件系统总的可用量 1天 数值型
				// 文件系统名称 ,并 计算文件系统总空间
				Vector<String> fileSystem = tt.getResultAsVector("df -k");
				long fs_sum = 0; // 文件系统总空间,兆
				for (int i = 1; i < fileSystem.size(); i++) {
					try {
						String fs_info = (String) fileSystem.elementAt(i);
						String fs_name = collResult.split(fs_info, 5);
						if (fs_name != null && fs_name.trim().equals("/")) {
							collResult.addKPI(fs_PRE_UNITID + ":"
									+ neat_host_name + "-"
									+ Formater.neatenunitid("//"),
									"CM-00-01-001-16", fs_name);
						} else {
							collResult.addKPI(fs_PRE_UNITID + ":"
									+ neat_host_name + "-"
									+ Formater.neatenunitid(fs_name),
									"CM-00-01-001-16", fs_name);
						}

						String fs_size = collResult.split(fs_info, 1);

						fs_size = (fs_size == null
								|| fs_size.trim().length() == 0 || fs_size
								.trim().equals("-")) ? "0" : fs_size.trim();
						long lfs_size = Long.parseLong(fs_size);
						fs_sum = fs_sum + lfs_size;

					} catch (Exception e) {
						logger.error(e);
					}
				}// end for
				collResult.addKPI(totalUnitId, "CM-00-01-001-17", String
						.valueOf(fs_sum / 1024));

			} catch (Exception e) {
				logger.error(e);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} catch (Error er) {
			logger.error(er);
		} finally {
			release();
		}
		logger.info("END COLL CONFIG ");
		return collResult.getKPISet();
	}

	private String getSwapSize() {
		String swapSize = "-";
		try {
			Vector<String> vSwap = tt.getResultAsVector("/etc/swap -s | awk '{print $11}'");
			swapSize = vSwap.get(0).trim();
			
			if(swapSize.endsWith("k")){
				swapSize = swapSize.substring(0,swapSize.length()-1);
			}
			
			// 单位单位统一为M
			swapSize = String.valueOf(Double.parseDouble(swapSize) / 1024);
			
			swapSize = Formater.formatDecimalKpivalue(swapSize);

		} catch (Exception e) {
			logger.error("Exception while getConfig", e);
		}
		
		return swapSize;
	}

	private String getCpuType() {
		try {
//			Vector<String> vCpu = tt
//					.getResultAsVector("/usr/sbin/prtdiag -v |awk -F 'NR==10 {print $1}'|awk '{print $5}'");
			Vector<String> vCpu = tt.getResultAsVector("/usr/sbin/prtdiag -v");
			
			for (int i = 0; i < vCpu.size(); i++) {
				String line = vCpu.get(i);
				if (line.indexOf("CPU ID Frequency") >= 0
						&& (i + 2) < vCpu.size()) {
					return split(vCpu.get(i + 2), 3).trim();
				} else if (line.indexOf("Brd  CPU  MHz") >= 0
						&& (i + 2) < vCpu.size()) {
					return split(vCpu.get(i + 2), 4).trim();
				}
			}
		} catch (Exception e) {
			logger.error("Exception while getCpuType", e);
		}
		return "-";
	}

	private String getCpuFrequency() {
		try {
			Vector<String> vCpu = tt
					.getResultAsVector("LANG=C;LC_ALL=C;LC_COLLATE=C;LC_CTYPE=C;LC_MESSAGES=C;L"
							+ "C_MONETARY=C;LC_NUMERIC=C;export LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES "
							+ "LC_MONETARY LC_NUMERIC;/usr/sbin/psrinfo -v|grep MHz|awk '{print $6}'|sort -u");

			return vCpu.get(0).trim();
		} catch (Exception e) {
			logger.error("Exception while getCpuFrequency", e);
			return "-";
		}
	}

	private String getCpuNum() {
		try{
			Vector<String> cpuNum = tt.getResultAsVector("/usr/sbin/psrinfo -p");
			return cpuNum.get(0).trim();
		}catch (Exception e) {
			logger.error("Exception while getCpuNum", e);
			return "-";
		}		
	}

	private String getMemoryType() {
		try {
			Vector<String> vMemory = tt.getResultAsVector("/usr/sbin/prtdiag -v | grep MB | grep -v CPU | head -1 | awk -F\" \" '{ print $4 }'");
			return vMemory.get(0).trim();
		} catch (Exception e) {
			logger.error("Exception while getMemoryType", e);
			return "-";
		}
	}

	public Vector<TblATO_KPIDETAIL> getCpu(HashMap<String, String> params) {
		logger.info("Begin getCpu...");
		CollBase collResult = new CollBase();
		try {
			init(params);
			
			if(!tt.isAuthorized()){
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", tt.getError());
				return collResult.KPISet;
			}else{
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", "UP");
			}

			String unitId = UNIT_ID + "-11:" + neat_host_name + "-cpu";

			Vector<String> vmstatResult = tt.getResultAsVector("vmstat 2 2");
			String vmstat_string = vmstatResult.get(vmstatResult.size() - 1);

			Vector<String> cpuout = tt.getResultAsVector("sar -u 1 3");
			String cpurun = (String) cpuout.elementAt(cpuout.size() - 1);

			// PM-00-01-001-06 CPU运行队列中进程个数
			collResult.addKPI(unitId, "PM-00-01-001-06",
					split(vmstat_string, 0));

			// PM-00-01-001-03 CPU时间:用户百分比(用户任务所占用CPU时间量占CPU时间总量的百分比)
			collResult.addKPI(unitId, "PM-00-01-001-03", split(cpurun, 1));

			// PM-00-01-001-02 CPU时间:系统百分比(CPU在系统相关任务上所用的时间量并报告它所占CPU时间总量的百分比值)
			collResult.addKPI(unitId, "PM-00-01-001-02", split(cpurun, 2));

			// PM-00-01-001-04 CPU时间:等待百分比
			// CPU等待(包括I/O等待,swap等待和进程输入输出等待)所占用CPU时间量占CPU时间总量的百分比。
			collResult.addKPI(unitId, "PM-00-01-001-04", split(cpurun, 3));

			// PM-00-01-001-01 CPU时间:空闲百分比 CPU空闲时间量占CPU时间总量的百分比的值
			String cpuFree = split(cpurun, 4);
			collResult.addKPI(unitId, "PM-00-01-001-01", cpuFree);

			// PM-00-01-001-05 CPU使用率 用户CPU时间百分比和系统CPU时间百分比之和的平均值。
			String cpuUsage = String.valueOf(100 - Integer.parseInt(cpuFree));
			collResult.addKPI(unitId, "PM-00-01-001-05", cpuUsage);
		} catch (Exception e) {
			logger.error("Exception while getCpu().", e);
		} finally {
			release();
		}
		

		
		logger.info("End getCpu!!!");
		return collResult.getKPISet();
	}
	
	/**
	 * 得到主机名
	 */
	private String getHostName() {
		Vector<String> host = tt.getResultAsVector("uname -a");
		String host_name = (String) host.elementAt(0);
		host_name = split(host_name, 1);
		return host_name;
	}

	public Vector<TblATO_KPIDETAIL> getMemory(HashMap<String, String> params) {
		logger.info("Begin getMemory...");
		CollBase collResult = new CollBase();
		try {
			init(params);
			
			if(!tt.isAuthorized()){
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", tt.getError());
				return collResult.KPISet;
			}else{
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", "UP");
			}
			
			String unintId = UNIT_ID + "-12:" + neat_host_name + "-memory";

			try {
				Vector<String> vmstatResult = tt.getResultAsVector("vmstat 2 2");
				String vmstat_string = vmstatResult.get(vmstatResult.size() - 1);

				// PM-00-01-002-02 内存交换请求数 Page request(包括page in&out)操作的数量
				value = split(vmstat_string, 9);				
				collResult.addKPI(unintId, "PM-00-01-002-02", value);

				// PM-00-01-002-03 内存交换页换进率 内存交换页换进速率
				value = split(vmstat_string, 7);				
				collResult.addKPI(unintId, "PM-00-01-002-03", value);
				
				// PM-00-01-002-04 内存交换页换出率 内存交换页换出速率
				value = split(vmstat_string, 8);				
				collResult.addKPI(unintId, "PM-00-01-002-04", value);

				// PM-00-01-002-05 内存队列数 等待内存的进程或线程数量
				value = split(vmstat_string, 0);				
				collResult.addKPI(unintId, "PM-00-01-002-05", value);

				// PM-00-01-002-01 内存的使用率 主机内存的使用量与内存总量的比值
				Vector<String> memoryTotalSize = tt
						.getResultAsVector("/etc/prtconf -v | grep Memory");

				String memorySize = memoryTotalSize.elementAt(0);
				memorySize = split(memorySize, 2);
				
				System.out.println("-- memory total size:"+memorySize);
				
				 // 空余内存(单位:M)
				int free_mem = Integer.parseInt(split(vmstat_string, 4)) / 1024;
				// 总内存 单位:M
				int total_mem = Integer.parseInt(memorySize); 

				String memUsage = String.valueOf(100.0 - (free_mem * 100.0) / total_mem);
				memUsage = Formater.formatDecimalKpivalue(memUsage);
				collResult.addKPI(unintId, "PM-00-01-002-01", memUsage);
			} catch (Exception e) {
				logger.error("Exception while getMemory", e);
			}
			
			try {
				Vector<String> filerate_result = tt.getResultAsVector("sar -b 2 2");
				String filerate_string = (String) filerate_result
						.elementAt(filerate_result.size() - 1);
				int r_rate = Integer.parseInt(split(filerate_string, 2));
				int w_rate = Integer.parseInt(split(filerate_string, 5));

				value = String.valueOf((r_rate + w_rate) / 2);
				// PM-00-01-002-08 文件系统数据缓冲命中率
				collResult.addKPI(unintId, "PM-00-01-002-08", value);
			} catch (Exception e) {
				logger.error("Exception while getMemory", e);
			}
		} catch (Exception e) {
			logger.error("Exception while getMemory", e);
		} finally {
			release();
		}
		logger.info("End getMemory!!!");
		return collResult.getKPISet();
	}

	public Vector<TblATO_KPIDETAIL> getDisk(HashMap<String, String> params) {
		logger.info("Begin getDisk...");
		// 保存采集结果,并返回值
		CollBase collResult = new CollBase();
		try {
			init(params);
			
			if(!tt.isAuthorized()){
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", tt.getError());
				return collResult.KPISet;
			}else{
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", "UP");
			}
			
			String preUnitId = UNIT_ID + "-13:" + neat_host_name;

			Vector<String> vResult = tt.getResultAsVector("sar -d 1 2");

			int iPos = -1;
			for (int i = 0; i < vResult.size(); i++) {
				String line = vResult.get(i);

				String neat_disk_name = "";
				String busy = "";
				String avque = "";
				String rws = "";
				String blks = "";

				if (iPos == -1) {
					iPos = line.indexOf("Average");
					neat_disk_name = split(line, 1);
					busy = split(line, 2);
					avque = split(line, 3);
					rws = split(line, 4);
					blks = split(line, 5);
				} else if (iPos >= 0) {
					neat_disk_name = split(line, 0);
					busy = split(line, 1);
					avque = split(line, 2);
					rws = split(line, 3);
					blks = split(line, 4);
				}
				
				if (iPos >= 0) {
					// 磁盘名称
					collResult.addKPI(preUnitId + "-" + neat_disk_name,
							"CM-00-01-001-20", neat_disk_name);

					// 磁盘忙的百分比
					collResult.addKPI(preUnitId + "-" + neat_disk_name,
							"PM-00-01-003-03", busy);

					// 等待磁盘系统进程线程数
					collResult.addKPI(preUnitId + "-" + neat_disk_name,
							"PM-00-01-003-02", avque);

					// 每秒读请求
					collResult.addKPI(preUnitId + "-" + neat_disk_name,
							"PM-00-01-003-04", rws);

					// 每秒写请求
					collResult.addKPI(preUnitId + "-" + neat_disk_name,
							"PM-00-01-003-05", rws);

					// 磁盘物理IO操作速率
					collResult.addKPI(preUnitId + "-" + neat_disk_name,
							"PM-00-01-003-01", blks);
				}
			}
		} catch (Exception e) {
			logger.error("Exception while getDisk()", e);
		} finally {
			release();
		}
		logger.info("End getDisk!!!");
		return collResult.getKPISet();
	}

	/**
	 * 采集文件系统指标
	 */
	public Vector<TblATO_KPIDETAIL> getFileSystem(HashMap<String,String> params) {
		logger.info("Begin getFileSystem...");
		// 保存采集结果,并返回值
		CollBase collResult = new CollBase();
		try {
			init(params);
			
			if(!tt.isAuthorized()){
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", tt.getError());
				return collResult.KPISet;
			}else{
				String totalUnitId = this.UNIT_ID + "-10:" + neat_host_name + "-total";
//				collResult.addKPI(totalUnitId, "FM-00-01-001-01", "UP");
			}
			
			String totalUnitId = UNIT_ID + "-10:" + neat_host_name + "-total";

			try {
				if (this.lang != null && lang.indexOf("zh") != -1) {
					Vector<String> swap_u = tt.getResultAsVector("/etc/swap -s| awk '{print $9}'");
					String swap_size = (String) swap_u.elementAt(0);
					String[] swap = swap_size.split(",");
					swap[1] = swap[1].trim();
					swap[0] = swap[0].trim();
					int swapsize = Integer.parseInt(swap[1].substring(0, swap[1].length() - 1));
					int swapused = Integer.parseInt(swap[0].substring(0, swap[0].length() - 1));
					value = String.valueOf((int)((swapused * 100) / swapsize)); // PM-00-01-004-02
					// 交换区使用百分比
					collResult.addKPI(totalUnitId, "PM-00-01-004-02", value);
				} else {
					Vector<String> swap_s = tt.getResultAsVector("/etc/swap -s| awk '{print $11}'");
					if (swap_s != null && swap_s.size() > 0) {
						String swap_size = (String) swap_s.elementAt(0);
						Vector<String> swap_u = tt.getResultAsVector("/etc/swap -s| awk '{print $9}'");

						String swap_used = (String) swap_u.elementAt(0);
						int swapsize = Integer.parseInt(swap_size.substring(0,
								swap_size.length() - 1));
						int swapused = Integer.parseInt(swap_used.substring(0,
								swap_used.length() - 1));
						value = String.valueOf((swapused * 100) / swapsize);

						// PM-00-01-004-02 交换区使用百分比 交换区使用百分比
						collResult.addKPI(totalUnitId, "PM-00-01-004-02", value);
					}
				}

			} catch (Exception e) {
				logger.error("Exception while getFileSystem", e);
			}

			String preUnitId = UNIT_ID + "-14" + ":" + neat_host_name;
			try {
				// 1 PM-00-01-004-01 文件系统使用比率 文件系统已使用的空间与总空间的比值
				// 3 PM-00-01-004-03 逻辑卷(裸设备)文件系统使用率 各逻辑卷上文件系统的使用率

				// 采集各文件系统占用率
				long fs_sum = 0; // 文件系统总空间
				long fs_sum_free = 0; // 文件系统总已空余空间
				Vector<String> filesystemV = tt.getResultAsVector("df -k | awk '{print $1\" \"$2\" \"$3\" \"$4\" \"$5\" \"$6}'| grep -v \"Filesystem kbytes\"");
				if (filesystemV != null && filesystemV.size() > 0) {
					for (String line : filesystemV) {
						if (line.indexOf("Permission") >= 0) {
							continue;
						}
						// 文件系统名称
						String fs_name = split(line, 5);
						// 文件系统使用率
						String usedPercent = split(line, 4);
						// 文件系统大小
						String fs_size = split(line, 1);
						// 文件系统剩余大小
						String fs_free = split(line, 3);

						fs_size = fs_size.equals("-") ? "0" : fs_size;
						fs_free = fs_free.equals("-") ? "0" : fs_free;
						
						fs_sum = fs_sum + Long.parseLong(fs_size);
						fs_sum_free = fs_sum_free + Long.parseLong(fs_free);

						String neat_fs_name = Formater.neatenunitid(fs_name);
						String fsUnitId;
						if (neat_fs_name != null && neat_fs_name.equals("/")) {
							fsUnitId = preUnitId + "-//";
						} else {
							fsUnitId = preUnitId + "-" + neat_fs_name;
						}
						
						// 去除百分号,如果是/proc, 直接设定为0
						if (usedPercent.length() > 1) {
							if (usedPercent.trim().equals("-")) {
								usedPercent = "0";
							} else {
								usedPercent = usedPercent.substring(0,
										usedPercent.length() - 1);
							}
						}
						
						// 文件系统使用率
						collResult.addKPI(fsUnitId, "PM-00-01-004-03", usedPercent);
						// 文件系统可用空间
						collResult.addKPI(fsUnitId, "PM-00-01-004-04", fs_free);
						// 文件系统所属磁盘
						collResult.addKPI(fsUnitId, "PM-00-01-004-14", split(line, 0));
					}
				}// 获取文件系统使用率完毕

				// PM-00-01-004-01 文件系统总占用率需要计算
				if (fs_sum != 0) {
					collResult.addKPI(totalUnitId, "PM-00-01-004-01", String.valueOf((int)(100 - fs_sum_free * 100.0 / fs_sum)));
				}

			} catch (Exception e) {
				logger.error("Exception while getFileSystem.", e);
			}

		} catch (Exception e) {
			logger.error("Exception while getFileSystem.", e);
		} finally {
			release();
		}
		logger.info("End getFileSystem!! ");
		
		return collResult.getKPISet();
	}

	/**
	 * 采集初始化
	 */
	public void init(HashMap<String, String> params) {
		String hostip = (String) params.get("IP_ADDR");
		String username = (String) params.get("USERNAME");
		String password = (String) params.get("PASSWORD");
		password = DES3.decrypt(password);
		String protol = (String) params.get("PROTOCOL");
		this.hostname = (String) params.get("HOSTNAME");
		String specPrompt = params.get("SPEC_PROMPT");

		this.ip_addr = hostip;

		if (protol != null && protol.equals("telnet")) {
			if(specPrompt!=null && !specPrompt.trim().equals("")){
				tt = new TelnetThread(hostip, 23, username, password, specPrompt);
			}else{
				tt = new TelnetThread(hostip, 23, username, password);
			}
		} else {
			tt = new SSHThread(hostip, 22, username, password);
		}
		
		try {
			tt.initial();
			isConnect = true;

			tt.getResultAsVector("LANG=C;export LANG");
			
			Vector<String> vLang = tt.getResultAsVector("echo $LANG");
			if (vLang == null || vLang.size() == 0) {
				logger.warn("can't get host LANG information");
			} else {
				this.lang = vLang.get(0);
			}
			
			neat_host_name = Formater.neatenunitid(hostname);
		} catch (Exception e) {
			logger.error("Can't connect to host:"+ hostip, e);
			isConnect = false;
		}
	}

}