CollHPWithCMDByCron.java 113 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 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646
package com.sitech.ismp.coll.host;

import com.sitech.ismp.coll.CollBase;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.util.Formater;
import com.sitech.util.LockFile;
import com.sitech.util.PropertyUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class CollHPWithCMDByCron extends CollBase {

    static final String RESULT_PATH = "../result/";

    static final String SH_COLL_DISK = "getHPDisk.sh";
    static final String RESULT_DISK = "hpDiskResult";

    static final String SH_COLL_CPU = "getHPCpu.sh";
    static final String RESULT_CPU = "hpCpuResult";

    static final String SH_COLL_MEMORY = "getHPMemory.sh";
    static final String RESULT_MEMORY = "hpMemoryResult";

    static final String SH_COLL_CONFIG = "getHPConfig.sh";
    static final String RESULT_CONFIG = "hpConfigResult";

    static final String SH_COLL_FILE_SYSTEM = "getHPFileSystem.sh";
    static final String RESULT_FILE_SYSTEM = "hpFileSystemResult";

    static final String SH_COLL_USERPRONUM = "getHPUserProNum.sh";
    static final String RESULT_USER_PRONUM = "hpUserProNum";

    static final String SH_COLL_TOPPROCESS = "getHPTopProcess";
    static final String RESULT_TOPPROCESS = "hpTopProcess";

    static final String SH_COLL_ALLDISK = "getHPAllDisk.sh";
    static final String RESULT_ALLDISK = "hpAllDisk";

    static final String SH_COLL_ALLPROCESS = "getHPAllProcess.sh";
    static final String RESULT_ALLPROCESS = "hpAllProcess";

    static final String SH_COLL_SYSLOG = "getHPSyslog.sh";
    static final String RESULT_SYSLOG = "hpSyslog";

    static final String SH_COLL_CLOCK = "getHPClockInfo.sh";
    static final String RESULT_CLOCK = "hpClockInfo";

    static final String SH_COLL_FILESIZE = "getHPFileSize.sh";
    static final String RESULT_FILESIZE = "hpFileSizeResult";

    static final String SH_COLL_HARDWARE = "getHPHardware.sh";
    static final String RESULT_HARDWARE = "hpHardwareResult";

    static final String SH_COLL_FILEMOUNT = "getHPFileMount.sh";
    static final String RESULT_FILEMOUNT = "hpFileMountResult";

    static final String SH_COLL_NETLOG = "getHPNetLog.sh";
    static final String RESULT_NETLOG = "hpNetLogResult";

    static final String SH_COLL_RAIDSTATUS = "getHPRAIDStatus.sh";
    static final String RESULT_RAIDSTATUS = "hpRAIDStatusResult";

    static final String SH_COLL_CABINETRACK = "getHPCabinetRack.sh";
    static final String RESULT_CABINETRACK = "hpCabinetRackResult";

    static final String SH_COLL_PROCESS = "getHPProcessTop10.sh";
    static final String RESULT_PROCESS = "hpProcessTop10Result";

    static final String SH_COLL_KEY_PROCESS = "getHPProcess.sh";
    static final String RESULT_KEY_PROCESS = "hpProcessResult";

    static final String SH_COLL_NET = "getHPNet.sh";
    static final String RESULT_NET = "hpNetResult";

    static final String SH_COLL_FILE = "getFile.sh";
    static final String RESULT_FILE = "fileResult";

    String PRE_UNITID = "10-10-21"; // hp主机的标识

    /**
     * 内存已使用情况通过vmstat的fre字段 乘以 4k
     * PM-00-01-002-01 内存的使用率 vmstat 中的memory - free * 4k 为空闲内存,不通过本方法获取,通过SNMP获取
     * PM-00-01-002-02 内存交换请求数 vmstat 中的page - fr
     * PM-00-01-002-03 内存交换页换进率 vmstat 中的page - pi
     * PM-00-01-002-04 内存交换页换出率 vmstat 中的page - po
     * PM-00-01-002-05 内存队列数 等待内存的进程或线程数量vmstat 中的 kthr - r
     * PM-00-01-002-06 系统内存使用率 系统内存占所有物理内存的百分比 无此概念
     * PM-00-01-002-07 用户内存使用率 用户内存占所有物理内存的百分比 无此概念
     * PM-00-01-002-08 文件系统数据缓冲命中率 文件系统数据缓冲命中率 使用sar 2 2 , 平均读写命中率
     */
    public Vector<TblATO_KPIDETAIL> getMemory(HashMap<String, String> params) {
        logger.info("begin getMemory");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        
        // 执行脚本
        exec(SH_COLL_MEMORY);
        // 获得脚本执行结果
        List<String> result = getResult(RESULT_MEMORY);
        if(null == result || result.isEmpty()){
        	return collResult.KPISet;
        }
        List<List<String>> list = parseResult(result, 4);

        String deviceId = params.get("DEVICE_ID");
        if(null == deviceId || "".equals(deviceId.trim())){
            // 获取主机名称 : uname -a
            List<String> vHostName = list.get(0);
        	deviceId = split(vHostName.get(0), 1);
        }

        String memUnitId = PRE_UNITID + "-12:" + Formater.neatenunitid(deviceId) + "-memory";
        
        try {
        	// vmstat 2 10
            List<String> vmstat_result = list.get(1);
            if(null == vmstat_result || vmstat_result.size() < 1){
            	throw new Exception("\"vmstat 2 10\": null");
            }
            String vmstat_string = vmstat_result.get(vmstat_result.size() - 1);
            logger.info("vmstat 2 10:\n" + vmstat_string);

            // machinfo|grep Memory
            List<String> mem_num = list.get(2);
            logger.info("-- mem_num:" + mem_num.size());
            String memTotalInfo = mem_num.get(0);
            String memTotalSize = null;
            if (null == memTotalInfo || "".equals(memTotalInfo.trim())) {
                throw new Exception("Can't get memory total size");
            } else if (memTotalInfo.contains(":")) {
                memTotalSize = split(memTotalInfo, 1);
            } else if (memTotalInfo.contains("=")) {
                memTotalSize = split(memTotalInfo, 2);
            }

            logger.info("-- Memory total size:" + memTotalSize);
            
            double memFreeSize = Double.parseDouble(split(vmstat_string, 4)) * 4 / 1024;
            logger.info("-- Memory free size:" + memFreeSize);
            // 内存使用率
            double memUsage = 100.0 - (memFreeSize * 100.0) / Double.parseDouble(memTotalSize);

            collResult.addKPI(memUnitId, "PM-00-01-002-01", Formater.formatDecimalKpivalue(String.valueOf(memUsage)));

			String value = "";
			value = Formater.formatDecimalKpivalue(split(vmstat_string, 9));
			collResult.addKPI(memUnitId, "PM-00-01-002-02", value);

			value = Formater.formatDecimalKpivalue(split(vmstat_string, 7));
			collResult.addKPI(memUnitId, "PM-00-01-002-03", value);

			value = Formater.formatDecimalKpivalue(split(vmstat_string, 8));
			collResult.addKPI(memUnitId, "PM-00-01-002-04", value);

			value = Formater.formatDecimalKpivalue(split(vmstat_string, 0));
			collResult.addKPI(memUnitId, "PM-00-01-002-05", value);
		} catch (Exception e) {
			logger.error("Exception while getMemory!", e);
		}
        String filerate_string="";
		try {
			// sar -b 2 2 | grep Average
			List<String> filerate_result = list.get(3);
			if (null == filerate_result || filerate_result.isEmpty()) {
				throw new Exception("\"sar -b 2 2 | grep Average\": null");
			}
			 filerate_string = filerate_result
					.get(filerate_result.size() - 1);
			logger.info("sar -b 2 2 | grep Average:\n" + filerate_string);

			long r_rate = Long.parseLong(split(filerate_string, 3));
			long w_rate = Long.parseLong(split(filerate_string, 6));
			collResult.addKPI(memUnitId, "PM-00-01-002-08", Formater
					.formatDecimalKpivalue(String
							.valueOf((r_rate + w_rate) / 2)));
		} catch (Exception e) {
			logger.error("sar -b 2 2 | grep Average:\n" + filerate_string);
			logger.error("Exception while get filerate_result", e);
		}
        return collResult.getKPISet();
    }

    /**
     * PM-00-01-004-01 文件系统使用比率 文件系统已使用的空间与总空间的比值
     * PM-00-01-004-02 交换区使用百分比 交换区使用百分比
     * PM-00-01-004-03 逻辑卷(裸设备)文件系统使用率 各逻辑卷上文件系统的使用率
     * PM-00-01-004-01/03 Object=Disk PM-00-01-004-02 Object=System
     *
     * @param params
     * @return
     * @throws Exception
     */
    public Vector<TblATO_KPIDETAIL> getFileSystem(HashMap<String, String> params) {
        logger.info("begin getFileSystem");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        exec(SH_COLL_FILE_SYSTEM);
        // 获得脚本执行结果
        List<String> result = getResult(RESULT_FILE_SYSTEM);
        if(result == null || result.size() == 0){
            return collResult.KPISet;
        }
        List<List<String>> list = parseResult(result,4);

		String deviceId = params.get("DEVICE_ID");
		if (null == deviceId || "".equals(deviceId.trim())) {
			// 获取主机名称 : uname -a
			List<String> vHostName = list.get(0);
			deviceId = split(vHostName.get(0), 1);
		}
        // 得到unit_id中使用的主机名称
		deviceId = Formater.neatenunitid(deviceId);

        try{
        	// 采集各文件系统占用率
            long fsTotalSize = 0; // 文件系统总空间 兆
            long fsTotalUsed = 0; // 文件系统总空余空间
            List<String> fileSystemVTmp = list.get(1);
            if(null==fileSystemVTmp || fileSystemVTmp.size()<1){
                throw new Exception("[HP COLL] bdf : null ");
            }
            
            // bdf
            // 因为用命令取得的数据,某些行会一行变两行,因此需要将被拆分开的合为一行,原来想法
            // 直接合,但是发现会有某些行被删掉,因此造了个临时向量,把哪些有问题的行的行号记下来,
            // 先把拼好的放到fileSystemVTmp,然后通过临时向量中记录的序号,将fileSystemVTmp的对应记录删除
            List<String> fileSystemV = new ArrayList<String>();

            String vTmp1, vTmp2;
            for (int m0 = 1; m0 < fileSystemVTmp.size(); m0++) {
                String tmp = fileSystemVTmp.get(m0);

                String Vtmp1 = split(tmp, 1);
                if (!(null == Vtmp1 || Vtmp1.equals(null) || "".equals(Vtmp1) || "" == Vtmp1)) {
                    String Vtmp2 = split(tmp, 5);
                    if (!(null == Vtmp2 || Vtmp2.equals(null) || "".equals(Vtmp2) || "" == Vtmp2)) {
                        fileSystemV.add(tmp);
                    }
                } else {
                    int kkk = m0 + 1;
                    vTmp2 = fileSystemVTmp.get(kkk).trim();
                    vTmp1 = tmp + "    " + vTmp2;
                    fileSystemV.add(vTmp1);
                }
            }

            for (int i = 0; i < fileSystemV.size(); i++) {
                String fsname_info = (String) fileSystemV.get(i);
                String fsSize = split(fsname_info, 1);
                String usedSize = split(fsname_info, 2);
                String freeSize = split(fsname_info, 3);
                String fsUsage = split(fsname_info, 4);

                fsUsage = fsUsage.substring(0, fsUsage.indexOf("%"));
                String fs_name = split(fsname_info, 5);
                float free = Float.parseFloat(freeSize) / 1024;
                String fsFreeSize = Float.toString(free);

                String fsUnitId = PRE_UNITID + "-14:" + deviceId;
                if (fs_name != null && fs_name.equals("/")) {
                	fsUnitId += "-//";
                } else {
                	fsUnitId += "-" + Formater.neatenunitid(fs_name);
                }
                
                collResult.addKPI(fsUnitId, "PM-00-01-004-03", fsUsage);

                // 文件系统可用空间
                collResult.addKPI(fsUnitId, "PM-00-01-004-04", Formater.formatDecimalKpivalue(fsFreeSize));

                fsTotalSize += Long.parseLong(fsSize);
                fsTotalUsed += Long.parseLong(usedSize);
            }

            String totalUnitId = PRE_UNITID + "-10:" + deviceId + "-total";
            // PM-00-01-004-01 文件系统总占用率需要计算
            if (fsTotalSize != 0) {
                collResult.addKPI(totalUnitId,
                        "PM-00-01-004-01", Formater.formatDecimalKpivalue(String.valueOf(fsTotalUsed * 100.0 / fsTotalSize)));
            }

            // "swapinfo -atm | grep dev"
            List<String> swapV = list.get(2);
            if (swapV != null && swapV.size() > 0) {
                long swap_sum_avl = 0;
                long swap_sum_usd = 0;
                long swap_sum_free = 0;
                for (int i = 0; i < swapV.size(); i++) {
                    String swap_info = swapV.get(i);
                    String swap_avl = split(swap_info, 1);
                    String swap_usd = split(swap_info, 2);
                    String swap_free = split(swap_info, 3);
                    swap_sum_avl = swap_sum_avl + Long.parseLong(swap_avl);
                    swap_sum_usd = swap_sum_usd + Long.parseLong(swap_usd);
                    swap_sum_free = swap_sum_free + Long.parseLong(swap_free);
                }

                String swapUsage = Formater.formatDecimalKpivalue(String.valueOf(swap_sum_usd * 100.0 / swap_sum_avl));

				collResult.addKPI(totalUnitId, "PM-00-01-004-02", swapUsage);
                //交换分区大小
				collResult.addKPI(totalUnitId, "CM-00-01-001-13", Long.toString(swap_sum_avl));
                //交换分区已用大小
				collResult.addKPI(totalUnitId, "PM-00-01-004-19", Long.toString(swap_sum_usd));
                //交换分区空闲大小
				collResult.addKPI(totalUnitId, "PM-00-01-004-22", Long.toString(swap_sum_free));
            }

            // 实际打开进程数/允许打开进程数 实际使用inod数/允许使用inod数 实际打开文件数/允许打开文件数
            // sar -v 1 | tail -n 1 | sed 's/\\// /g' | awk '{printf("%0.4f\t%0.4f\t%0.4f\t%d\t%d\t%d\t%d\t%d\t%d\n", $6/$7 *100, $9/$10 *100, $12/$13 *100, $6, $7, $9, $10, $12, $13);}'
            List<String> listUserRate = list.get(3);
            if (listUserRate != null && listUserRate.size() > 0) {
                String strMsg = (String) listUserRate.get(0);

                String strProc = split(strMsg, 0);
                String strInod = split(strMsg, 1);
                String strFile = split(strMsg, 2);

                String strProc_1 = split(strMsg, 3);
                String strProc_2 = split(strMsg, 4);
                String strInod_1 = split(strMsg, 5);
                String strInod_2 = split(strMsg, 6);
                String strFile_1 = split(strMsg, 7);
                String strFile_2 = split(strMsg, 8);

				// 实际打开进程数量与可供打开数比率
				collResult.addKPI(totalUnitId, "PM-00-01-004-05", strProc);
				// 实际使用inod比率
				collResult.addKPI(totalUnitId, "PM-00-01-004-06", strInod);
				// 实际打开文件数比率
				collResult.addKPI(totalUnitId, "PM-00-01-004-07", strFile);
				// 实际打开进程数
				collResult.addKPI(totalUnitId, "PM-00-01-004-08", strProc_1);
				// 允许打开进程数
				collResult.addKPI(totalUnitId, "PM-00-01-004-09", strProc_2);
				// 实际使用inod数
				collResult.addKPI(totalUnitId, "PM-00-01-004-10", strInod_1);
				// 允许使用inod数
				collResult.addKPI(totalUnitId, "PM-00-01-004-11", strInod_2);
				// 实际打开文件数
				collResult.addKPI(totalUnitId, "PM-00-01-004-12", strFile_1);
				// 允许打开文件数
				collResult.addKPI(totalUnitId, "PM-00-01-004-13", strFile_2);
            }
        } catch (Exception e){
            logger.error("[HP COLL]Exception coll HP FileSystem ",e);
        }

        return collResult.getKPISet();
    }

    /**
     * 获取所有用户用户进程数
     *
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getUserProNum(HashMap<String, String> params) {
        logger.info("begin getUserProNum ");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();

        // 得到所有用户的列表,该用户名出现多少次,就表明ps出来有多少行,即有多少进程
        Vector<String> userV = new Vector();
//        Vector<String> processV = rpctarget.getKPISet("ps -ef | grep -v UID");

        List<String> result = null;
        List<List<String>> list = null;
        try{
            exec(SH_COLL_USERPRONUM);
            result = getResult(RESULT_USER_PRONUM);
            if(result == null || result.size() == 0){
                return collResult.KPISet;
            }
            list = parseResult(result,2);
        } catch (Exception e){
            logger.error("[HP COLL] Exception while execute "+SH_COLL_USERPRONUM,e);
        }
        List<String> processV = list.get(1);
        // 原来采用以下命令,但在jilin 10.161.1.132 hp主机上有时出现 用户名称为 _3的情况,所以弃用
        // rpctarget.getKPISet("export UNIX95=XPG4;ps -ef -o user | grep -v USER");
        for (int i = 0; i < processV.size(); i++) {
//            String processInfo = (String) processV.elementAt(i);
            String processInfo = (String) processV.get(i);
            userV.add(collResult.split(processInfo, 0));
        }
        processV = null;

        if (userV == null || userV.size() == 0) {
            return new Vector<TblATO_KPIDETAIL>();
        }

        // 计算各个用户的进程数,并保存在这个map中
        // user - user process numer
        Map user_pronum = new HashMap();

        for (int i = 0; i < userV.size(); i++) {
            String userName = ((String) userV.elementAt(i)).trim();
            int pro_number = 1;
            if (user_pronum.get(userName) == null) {
                user_pronum.put(userName, new Integer(pro_number));
            } else {
                pro_number = Integer.parseInt(user_pronum.get(userName) + "") + 1;
                user_pronum.put(userName, new Integer(pro_number));
            }
        }


        // 本方法得到的kpi值的unit_id,均以PRE_UNITID + "-10"开头,代表Total数据
        String pro_PRE_UNITID = PRE_UNITID + "-21"; // total值

        // 获取主机名称
        String deviceId = params.get("DEVICE_ID");
        if(null==deviceId || "".equals(deviceId.trim())){
            // 获取主机名称 : uname -a
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        // 得到unit_id中使用的主机名称
        String neat_host_name = Formater.neatenunitid(deviceId);

        Set users = user_pronum.keySet();
        // System.out.println("users------------"+users);
        Iterator iter = users.iterator();
        while (iter.hasNext()) {
            String username = (String) iter.next();
            // System.out.println("username------------"+username);
            collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + Formater.neatenunitid(username),
                    "PM-00-01-005-06", ((Integer) user_pronum.get(username)).toString());
            collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + Formater.neatenunitid(username),
                    "CM-00-01-005-06", Formater.neatenunitid(username));

        }

        return collResult.getKPISet();
    }

    /**
     * 17个指标中 15个ok 1 hp
     * CM-00-01-001-06(cpu频率) 待完成
     * 主机物理内存大小通过SNMP获取 其他待测试
     * 在方法的最后面增加了getAllDisk的指标采集,该方法的采集值比较多,所以放在这里了。
     *
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getConfig(HashMap<String, String> params) {
        logger.info("begin getConfig");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        
        // 执行脚本
        exec(SH_COLL_CONFIG);
        // 获得脚本执行结果
        List<String> result = getResult(RESULT_CONFIG);
        if(null == result || result.isEmpty()){
        	logger.warn("Exception while execute " + SH_COLL_CONFIG + ", result is null");
        	return collResult.KPISet;
        }
        
        List<List<String>> list = parseResult(result, 17);
        logger.info("RESULT SIZE:"+list.size());
        // 获取主机名称 : uname -a
        List<String> vHostName = list.get(0);
        logger.info("=========================uname result start=========================");
        String hostname = vHostName.get(0);
        
        String deviceId = params.get("DEVICE_ID");
        if(null == deviceId || "".equals(deviceId.trim())){
        	deviceId = split(hostname, 1);
        }
        
        String unitId = PRE_UNITID + "-10:" + Formater.neatenunitid(deviceId) + "-total";

        // 常用ip,用于告警标题
//        collResult.addKPI(unitId, "CM-00-01-001-50", params.get("IP_ADDR"));

        // 主机名称
        collResult.addKPI(unitId, "CM-00-01-001-01", split(hostname, 1));
        
        // 主机操作系统版本 
        collResult.addKPI(unitId, "CM-00-01-001-08", split(hostname, 2));
        
        // 主机类型
        collResult.addKPI(unitId, "CM-00-01-001-03", "HP");
        logger.info("=========================uname result end=========================");
        // ----cpu信息 , CM-00-01-001-04(个数)/05(型号)/06(主频)-----
		// ioscan -fnk | grep processor

        List<String> cpunumV = list.get(1);
        logger.info("=========================ioscan -fnk | grep processor start=========================");
        // CPU个数
        String cpuNum = String.valueOf(cpunumV.size());
        collResult.addKPI(unitId, "CM-00-01-001-04", cpuNum);
        logger.info("=========================ioscan -fnk | grep processor end=========================");

        try {
        	// machinfo
            List<String> cputypeV = list.get(2);
            logger.info("=========================machinfo start=========================");
            for (int j = 0; j < cputypeV.size(); j++) {
                String cpu_info = cputypeV.get(j);
                if (cpu_info.indexOf("processor model:") > -1) {
                    String cputype = split(cpu_info, 3) + " " + split(cpu_info, 4) + " " + split(cpu_info, 5) + " " + split(cpu_info, 6) + " " + split(cpu_info, 7);
                    // cpu类型
                    collResult.addKPI(unitId, "CM-00-01-001-05", cputype);
                }
                if (cpu_info.indexOf("Clock speed") > -1) {
                    String cpuHZ = split(cpu_info, 3);
                    // cpu频率 MHz
                    collResult.addKPI(unitId, "CM-00-01-001-06", cpuHZ);
                }

                // CPU info:
                //   Intel(R) Itanium 2 9100 series processor (1.6 GHz, 24 MB)
                if (cpu_info.trim().startsWith("CPU info:")) {
                    String nextLine = cputypeV.get(j + 1);
                    if (nextLine.indexOf("GHz") > 0 && nextLine.indexOf("MB") > 0) {
                        // cpu类型
                        collResult.addKPI(unitId, "CM-00-01-001-05", nextLine.trim().replace("\t", " "));
                    }
                }

                if (cpu_info.trim().startsWith("Memory") && cpu_info.indexOf("=") > 0) {
                    // B.11.23使用
                    String phyMemSize = split(cpu_info, 2);
                    // 物理内存大小
                    collResult.addKPI(unitId, "CM-00-01-001-07", phyMemSize);
                }

                if (cpu_info.trim().startsWith("Memory:")) {
                    // HP-UX B.11.31使用
                    String phyMemSize = split(cpu_info, 1);
                    // 物理内存大小
                    collResult.addKPI(unitId, "CM-00-01-001-07", phyMemSize);
                }
            }
        } catch (Exception e) {
            logger.warn("Exception while coll cpu type and cpu clock", e);
        }
        logger.info("=========================machinfo end=========================");
        // ----CM-00-01-001-09 内置盘大小--------
        // 这里得到的pe size默认认为是megadata
        // 一下两个命令得到的结果行数一致,分别表示物理设备大小,以及该大小的单位(pe size)
		// ioscan -fnkC disk | grep GST
        logger.info("=========================ioscan -fnkC disk | grep GST start=========================");
        List<String> diskVsize = list.get(3);
        float disksize_sum = 0; // 单位PE Size
        for (int i = 0; i < diskVsize.size(); i++) {
            String disksizes = (String) diskVsize.get(i);
            logger.info("disksizes("+i+")======["+disksizes+"]");
            String subds = disksizes.substring(disksizes.indexOf("HP")+3, disksizes.indexOf("GST"));
            float i_disksize = Float.parseFloat(subds.trim());
            disksize_sum = disksize_sum + i_disksize * 1024;
        }
        collResult.addKPI(unitId,
                "CM-00-01-001-09", Formater.formatDecimalKpivalue(String.valueOf(disksize_sum == 0 ? 139898 : disksize_sum)));

        logger.info("=========================ioscan -fnkC disk | grep GST end=========================");
//        // ---------------------------- 网卡配置Begin -------------------------------------------
//        // netstat -in | grep -v Mtu | grep -v 127.0.0.1 | grep -v none
//
//        logger.info("=========================netstat  lanscan start=========================");
//        List<String> netstatV = list.get(4);
//
//        // lanscan | grep -v Hardware | grep -v Path
//        List<String> lanscanV = list.get(5);
//
//        // CM-00-01-001-10 系统网络接口数 , lanscan得出的行数
//        collResult.addKPI(unitId, "CM-00-01-001-10", String.valueOf(lanscanV.size()));
//
//        Map<String, String> ips = new HashMap<String, String>();
//        long lan_ipkts_total = 0;
//        long lan_opkts_total = 0;
//        for (String netstatInfo: netstatV) {
//            String lanName = split(netstatInfo, 0);
//            String ip = split(netstatInfo, 3);
//            lan_ipkts_total = lan_ipkts_total+ Long.parseLong(split(netstatInfo, 4));
//            lan_opkts_total = lan_opkts_total+ Long.parseLong(split(netstatInfo, 6));
//            ips.put(lanName, ip);
//        }
//        //网卡总出包数
//        collResult.addKPI(unitId, "PM-00-01-001-17", String.valueOf(lan_opkts_total));
//        //网卡总入包数
//        collResult.addKPI(unitId, "PM-00-01-001-18", String.valueOf(lan_ipkts_total));
//
//        Map<String, String> phyAddrMap = new HashMap<String, String>();
//        Map<String, String> ifStateMap = new HashMap<String, String>();
//        for (String lancanInfo : lanscanV) {
//            String lanName = split(lancanInfo, 4);
//            String phyAddr = split(lancanInfo, 1);
//            String ifState = split(lancanInfo, 3);
//            phyAddrMap.put(lanName, phyAddr);
//            ifStateMap.put(lanName, ifState);
//        }
//
//        Set<String> ipskeys = ips.keySet();
//        Object[] arrObj = ipskeys.toArray();
//
//        String serviceIp = "";
//        for (String lanName : ips.keySet()) {
//            if (null != phyAddrMap.get(lanName)) {
//            	String ifUnitId = this.PRE_UNITID + "-16:" + deviceId + "-" + Formater.neatenunitid(lanName);
//                // 系统网络接口IP地址
//                collResult.addKPI(ifUnitId, "CM-00-01-001-11", ips.get(lanName));
//
//                // 系统网络接口物理地址
//                collResult.addKPI(ifUnitId, "CM-00-01-001-12", phyAddrMap.get(lanName));
//
//                // 网卡状态
//                collResult.addKPI(ifUnitId, "FM-00-01-001-03", ifStateMap.get(lanName));
//
//                serviceIp = serviceIp + "," + ips.get(lanName);
//            }
//        }
//
//        // 主机(服务)地址 CM-00-01-001-02, 将所有ip地址累加
//        if (serviceIp.length() > 0) {
//            collResult.addKPI(unitId, "CM-00-01-001-02", serviceIp.substring(1));
//        }
//        logger.info("=========================netstat  lanscan end=========================");
//        // ---------------------------- 网卡配置End -------------------------------------------
        
        // 交换分区大小: swapinfo -atm 
        List<String> vSwap = list.get(6);
        logger.info("=========================swap start=========================");
        if(null == vSwap || vSwap.isEmpty()){
        	logger.warn("\"swapinfo -atm\": null");
        }else{
        	try{
        		 String swapSize = vSwap.get(vSwap.size() - 1);
        		 logger.info("swapinfo -atm:\n" + swapSize);
                 // 交换分区大小
                 swapSize = split(swapSize, 1);
                 collResult.addKPI(unitId, "CM-00-01-001-13", swapSize);
        	}catch(Exception e){
        		logger.warn("Exception while parse \"swapinfo -atm\"!", e);
        	}
        }
        logger.info("=========================swap end=========================");
//        // 逻辑卷名称 与 逻辑卷大小
//        // vgdisplay -v |grep 'LV Name'
//        List<String> vLvName = list.get(7);
//
//        // vgdisplay -v |grep 'LV Size'
//        List<String> vLvSize = list.get(8);
//        logger.info("=========================LV start=========================");
//        if (vLvName != null && vLvSize != null
//                && vLvName.size() == vLvSize.size()) {
//            for (int i = 0; i < vLvName.size(); i++) {
//                String lvName = vLvName.get(i);
//                lvName = this.split(lvName, 2);
//
//                String lvUnitId = this.PRE_UNITID + "-17:" + deviceId + Formater.neatenunitid(lvName);
//
//                // 逻辑卷名称
//                collResult.addKPI(lvUnitId, "CM-00-01-001-14", lvName);
//
//                // 逻辑卷大小
//                String lvSize = this.split(vLvSize.get(i), 3);
//                collResult.addKPI(lvUnitId, "CM-00-01-001-15", lvSize);
//            }
//        }
//        logger.info("=========================LV end=========================");
        // ------------------------------- 文件系统信息  Begin------------------------------------------
        // bdf
        List<String> fileSystemVTmp = list.get(9);
        logger.info("=========================bdf start=========================");
        if(null == fileSystemVTmp || fileSystemVTmp.isEmpty()){
        	logger.warn("\"bdf\": null");
        }else{
        	Vector<String> fileSystemV = new Vector<String>();

            String vTmp1, vTmp2;
            for (int m0 = 1; m0 < fileSystemVTmp.size(); m0++) {
                String tmp = fileSystemVTmp.get(m0);
                if(null == tmp || "".equals(tmp.trim())){
                	continue;
                }

                String Vtmp1 = split(tmp, 1);
                if (null != Vtmp1 && !"".equals(Vtmp1.trim())) {
                    String Vtmp2 = split(tmp, 5);
                    if (null != Vtmp2 && !"".equals(Vtmp2.trim())) {
                        fileSystemV.add(tmp);
                    }
                } else {
                    int kkk = m0 + 1;
                    vTmp2 = fileSystemVTmp.get(kkk).trim();
                    vTmp1 = tmp + "    " + vTmp2;
                    fileSystemV.add(vTmp1);
                }
            }

            long fsTotalSize = 0; // 文件系统总空间,兆
            for (int i = 0; i < fileSystemV.size(); i++) {
                try {
                    String fsname_info = fileSystemV.get(i);
                    String fsSize = split(fsname_info, 1).trim();
                    String fsName = split(fsname_info, 5).trim();
                    String fsDiskName = split(fsname_info, 0).trim();
                    
                    logger.info("test oh test :" + fsName + "--" + fsSize + "----" + fsname_info);

                    String fsUnitId = this.PRE_UNITID + "-14:" + deviceId;
                    if (fsName != null && fsName.trim().equals("/")) {
                    	fsUnitId += "-" + Formater.neatenunitid("//");
                    } else {
                    	fsUnitId += "-" + Formater.neatenunitid(fsName);
                    }
                    
                    // 文件系统名称
                    collResult.addKPI(fsUnitId, "CM-00-01-001-16", fsName);

                    // 文件系统挂载磁盘
                    collResult.addKPI(fsUnitId, "CM-00-01-001-42", fsDiskName);
                    fsName = (null == fsName || "".equals(fsName) || "-".equals(fsName)) ? "0" : fsSize.trim();
                    fsTotalSize = fsTotalSize + Long.parseLong(fsSize);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            // 文件系统总大小
            collResult.addKPI(unitId, "CM-00-01-001-17", Formater.formatDecimalKpivalue(String.valueOf(fsTotalSize / 1024)));
        }
        logger.info("=========================bdf end=========================");
        // ------------------------------- 文件系统信息  End------------------------------------------
        
        
        // ------------------------------- 集群  Begin------------------------------------------
        // cluster状态
        try {
            String cluster_PRE_UNITID = this.PRE_UNITID + "-22";
            // cmviewcl -l cluster	
            List<String> clusterInfo = list.get(10);
            logger.info("=========================cluster start=========================");
            if(null == clusterInfo || clusterInfo.isEmpty()){
            	logger.warn("\"cmviewcl -l cluster\": null");
            } else {
                for (String cluster : clusterInfo) {
                	if(null == cluster || "".equals(cluster.trim()) ){
                		continue;
                	}
                	if(cluster.indexOf("CLUSTER") > -1 || cluster.indexOf("STATUS") > -1){
                		continue;
                	}
                   
                        String clusterName = collResult.split(cluster, 0);
                        String clusterState = collResult.split(cluster, 1);

                        String clustUnitId = this.PRE_UNITID + "-22:" + deviceId + "-" + Formater.neatenunitid(clusterName);
                        // 集群名称
                        collResult.addKPI(clusterName, "CM-00-01-001-18", clusterName);
                        // 集群状态
                        collResult.addKPI(clusterName, "FM-00-01-001-04", clusterState);

                }
            }
            logger.info("=========================cluster end=========================");
        } catch (Exception e) {
            logger.error("Exception while get cluster!", e);
        }

        List<String> upTime = list.get(11);
        if (null != upTime && !upTime.isEmpty()) {
            String uptime = upTime.get(0);
            collResult.addKPI(unitId, "PM-20-20-001-52", uptime);
        }
     // ------------------------------- 集群  End------------------------------------------

        try{
            logger.info("=========================VG start=========================");
            // 逻辑卷状态
            List<String> VGInfos = list.get(12);
            if(VGInfos != null && VGInfos.size() > 0){
                for(int i = 0;i < VGInfos.size();i++){
                    String VGName = split(VGInfos.get(i), 2).trim();
                    String VGState = split(VGInfos.get(i+1), 2).trim();
                    String VGUnitId = "10-10-21-33:" + deviceId + "-" + Formater.neatenunitid(VGName) ;
                    //逻辑卷名称
                    collResult.addKPI(VGUnitId, "CM-00-01-001-57", VGName);
                    //逻辑卷状态
                    collResult.addKPI(VGUnitId, "FM-00-01-001-14", VGState);
                    i++;
                }
            }
            logger.info("=========================VG end=========================");
        } catch (Exception e) {
            logger.error("Exception while get LVState!", e);
        }
        try{
            logger.info("=========================kernel start=========================");
            // 内核信息
            List<String> usageInfos = list.get(13);
            if(usageInfos != null && usageInfos.size() > 0){
                String usageInfo = usageInfos.get(usageInfos.size()-1);
                //全系统进程数使用率%
                String[] proc_usage = split(usageInfo, 3).trim().split("/");
                int proc_useRate = Integer.parseInt(proc_usage[0])*100/Integer.parseInt(proc_usage[1]);
                collResult.addKPI(unitId, "PM-00-01-005-20", Integer.toString(proc_useRate));
            }
            List<String> kernelInfos = list.get(14);
            if(kernelInfos != null && kernelInfos.size() > 0){
                //用户核心线程数使用率
                String kth_usage1 = split(kernelInfos.get(0), 1).trim();
                String kth_usage2 = split(kernelInfos.get(0), 3).trim();
                int croProc_useRate = Integer.parseInt(kth_usage1)*100/Integer.parseInt(kth_usage2);
                collResult.addKPI(unitId, "PM-00-01-005-18", Integer.toString(croProc_useRate));
                //用户进程数使用率
                String uprc_usage1 = split(kernelInfos.get(1), 1).trim();
                String uprc_usage2 = split(kernelInfos.get(1), 3).trim();
                int uproc_useRate = Integer.parseInt(uprc_usage1)*100/Integer.parseInt(uprc_usage2);
                collResult.addKPI(unitId, "PM-00-01-005-19", Integer.toString(uproc_useRate));
            }
            logger.info("=========================kernel end=========================");
        } catch (Exception e) {
        logger.error("Exception while get kernel information!", e);
        }
        try{
            List<String> syslogStatus = list.get(15);
            if(syslogStatus != null && syslogStatus.size() > 0){
                // syslog状态
                collResult.addKPI(unitId, "FM-00-01-001-17", "true");
            }else {
                collResult.addKPI(unitId, "FM-00-01-001-17", "false");
            }
        }catch (Exception e){
            logger.error("Exception while getsyslog", e);
        }
        logger.info("=========================machineSerialNum start=========================");
        try{
            //主机序列号
            List<String> machineSerialNum = list.get(16);
            if(machineSerialNum !=null && machineSerialNum.size()>0){
                collResult.addKPI(unitId,"CM-01-03-001-08",split(machineSerialNum.get(0),3));
            }
            logger.info("=========================machineSerialNum end=========================");
        }catch (Exception e){
            logger.error("Exception while get machineSerialNum", e);
        }

        return collResult.getKPISet();
    }// end getConfig

    /**
     * 网卡状态放在这个方法里面了
     *
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getCpu(HashMap<String, String> params) {
        logger.info("begin getCpu");
        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<List<String>> list = null;
        List<String> result = null;
        try{
			exec(SH_COLL_CPU);
			// 获得脚本执行结果
			result = getResult(RESULT_CPU);
			if (result == null || result.size() == 0) {
				return collResult.KPISet;
			}
			list = parseResult(result, 3);
        } catch (Exception e){
            logger.error("[HP Coll] Exception while execute " + SH_COLL_CPU,e);
        }

        try{
            String deviceId = params.get("DEVICE_ID");
			if (null == deviceId || "".equals(deviceId.trim())) {
				// 获取主机名称 : uname -a
				List<String> vHostName = list.get(0);
				deviceId = split(vHostName.get(0), 1);
			}

            // 得到unit_id中使用的主机名称
            deviceId = Formater.neatenunitid(deviceId);

            String cpuUnitId = PRE_UNITID + "-11:" + deviceId + "-cpu"; // total值
            String value = ""; // 临时变量

            // vmstat 2 10
            List<String> cpuout = list.get(1);
            if(null==cpuout || cpuout.size()<1){
                throw new Exception("[HP COLL] vmstat 2 10 : null");
            }

            String cpurun = cpuout.get(cpuout.size() - 1);

            // CPU时间:空闲百分比
            collResult.addKPI(cpuUnitId,
                    "PM-00-01-001-01", Formater.formatDecimalKpivalue(collResult.split(cpurun, 17)));

            // CPU时间:系统百分比
            collResult.addKPI(cpuUnitId,
                    "PM-00-01-001-02", Formater.formatDecimalKpivalue(collResult.split(cpurun, 16)));

            // CPU时间:用户百分比
            collResult.addKPI(cpuUnitId,
                    "PM-00-01-001-03", Formater.formatDecimalKpivalue(collResult.split(cpurun, 15)));
            
            // CPU运行队列中进程个数
            collResult.addKPI(cpuUnitId,
                    "PM-00-01-001-06", Formater.formatDecimalKpivalue(collResult.split(cpurun, 0)));
            // CPU阻塞队列中进程个数
            collResult.addKPI(cpuUnitId,
                    "PM-00-01-001-11", Formater.formatDecimalKpivalue(collResult.split(cpurun, 1)));

            // cpu利用率, 调用后扩的方法
            value = this.getCPU_Rate(cpuout);
            collResult.addKPI(cpuUnitId, "PM-00-01-001-05", value);

            // CPU时间:等待百分比
            // sar -u 2 10
            List<String> sar_cpuout = list.get(2);
			if (null == sar_cpuout || sar_cpuout.size() < 1) {
				logger.warn("[HP COLL] sar -u 2 10 : null");
			} else {
				String sar_cpurun = sar_cpuout.get(sar_cpuout.size() - 1);
				value = split(sar_cpurun, 3);
				collResult.addKPI(cpuUnitId, "PM-00-01-001-04",
						Formater.formatDecimalKpivalue(value));
			}
        } catch (Exception e){
            logger.error("[HP COLL] Exception while coll HP CPU ",e);
        }

        return collResult.getKPISet();
    }
    
	private String getCPU_Rate(List<String> cpuout) {
		double cpuRate = 0;
		int j=0;
		for (int i = cpuout.size() - 1; i >= 2 && j <= 20; i--) {//不要读取头两行title
			String cpurun = cpuout.get(i);
			cpuRate += 100 - Integer.parseInt(split(cpurun, 17));
			j++;
		}
		
		//cpuRate = cpuRate / 20;如果使用vmstat 2 10命令,那么cpuout只有12行结果,除数应该是10,而不是20
        cpuRate = cpuRate / j;
		return Formater.formatDecimalKpivalue(Double.toString(cpuRate));
	}

    public Vector<TblATO_KPIDETAIL> getDisk(HashMap<String, String> params) {
        logger.info("begin getActiveDisk");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();

        // 本方法得到的kpi值的unit_id,均以PRE_UNITID + "-13"开头,代表disk数据
        String disk_PRE_UNITID = PRE_UNITID + "-13";

        String value = "";// 临时变量

        // 从出现Average的这行开始,每一行表示一个磁盘的数据
//		Vector diskV = rpctarget.getKPISet("sar -d 5 5");
        exec(SH_COLL_DISK);

        try {
            // 获得脚本执行结果
            List<String> result = getResult(RESULT_DISK);
            if (result == null || result.size() == 0) {
                return collResult.KPISet;
            }
            List<List<String>> list = parseResult(result, 2);

            // 获取主机名称
//            String host_name = this.getHostName();
            String deviceId = params.get("DEVICE_ID");
            if(null==deviceId || "".equals(deviceId.trim())){
                // 获取主机名称 : uname -a
                List<String> vHostName = list.get(0);
                deviceId = split(vHostName.get(0), 1);
            }
            // 得到unit_id中使用的主机名称
            String neat_host_name = Formater.neatenunitid(deviceId);

            List<String> diskV = list.get(1);
            
            Set<String> sarDiskSet = new HashSet<String>(); // 保存所有sar命令能取到的io设备名称
            for (int i = 0; i < diskV.size(); i++) {
                String disk_value = diskV.get(i);

                if (disk_value.indexOf("Average") < 0){
                    continue;
                }

                String disk_name = split(disk_value, 1);
                sarDiskSet.add(disk_name);

                String neat_disk_name = Formater.neatenunitid(disk_name);

                collResult.addKPI(PRE_UNITID + "-13" + ":" + neat_host_name + "-"
                        + Formater.neatenunitid(disk_name), "CM-00-01-001-20", disk_name);

                // 磁盘物理IO操作速率
                value = split(disk_value, 5);
                collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                        + neat_disk_name, "PM-00-01-003-01", Formater.formatDecimalKpivalue(value));

                // 等待磁盘系统进程线程数
                value = split(disk_value, 3);
                collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                        + neat_disk_name, "PM-00-01-003-02", Formater.formatDecimalKpivalue(value));

                // 磁盘忙的百分比
                value = split(disk_value, 2);
                collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                        + neat_disk_name, "PM-00-01-003-03", Formater.formatDecimalKpivalue(value));

                // 每秒读请求
                value = split(disk_value, 4);
                collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                        + neat_disk_name, "PM-00-01-003-04", Formater.formatDecimalKpivalue(value));

                // 每秒写请求
                value = split(disk_value, 4);
                collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                        + neat_disk_name, "PM-00-01-003-05", Formater.formatDecimalKpivalue(value));
            }
        } catch (Exception e) {
            logger.info("[HP COLL] Exception while getActiveDisk!");
        }

        collResult.displayKPI();
        logger.info("[HP COLL] End getActiveDisk!");
        return collResult.getKPISet();

    }


    /**
     * 采集所有主机磁盘状态,读写指标 对于当前采集周期非活动的状态为CLAIMED的磁盘,其指标设定默认值 0
     * <p/>
     * 每秒磁盘读写请求 PM-00-01-003-04/05现在得到的值为 r+w
     * <p/>
     * 在规范磁盘性能指标基础上,增加了FM指标,内置盘状态
     *
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getAllDisk(HashMap<String, String> params) {
        logger.info("begin getAllDisk");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();

        List<String> result = null;
        List<List<String>> list = null;
        try{
            exec(SH_COLL_ALLDISK);
            result = getResult(RESULT_ALLDISK);
            if(result == null || result.size() == 0){
                return collResult.KPISet;
            }
            list = parseResult(result,2);
        } catch (Exception e){
            logger.error("[HP Coll] Exception while execute "+SH_COLL_ALLDISK,e);
        }

        // 本方法得到的kpi值的unit_id,均以PRE_UNITID + "-13"开头,代表disk数据
        String disk_PRE_UNITID = PRE_UNITID + "-13";

        // 获取主机名称
//        String host_name = this.getHostName();
        String deviceId = params.get("DEVICE_ID");
        if(null==deviceId || "".equals(deviceId.trim())){
            // 获取主机名称 : uname -a
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        // 得到unit_id中使用的主机名称
        String neat_host_name = Formater.neatenunitid(deviceId);

        // 增加采集时间指标
        String pattern = "yyyy-MM-dd-HH-mm-ss";
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
        collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "",
                "CM-00-01-001-22", dateFormat.format(new java.util.Date()));

        String value = "";// 临时变量

        // 内置盘状态
//        Vector diskState = rpctarget.getKPISet("ioscan -fnkC disk | grep -v 'Description' | grep -v '==' ");
        List<String> diskState = list.get(0);
        Vector diskStateV = this.transMSG(diskState);
        HashMap disk_stateMap = new HashMap();// 用于存储磁盘名称与磁盘状态。用于后面sar命令中没有得到的磁盘指标附值,hp主机sar命令只采活动io设备
        // 输出格式

        for (int i = 0; i < diskStateV.size(); i = i + 2) {

            String diskInfo1 = (String) diskStateV.elementAt(i); // "disk 0
            // 10/0/14/0.0.0
            // sdisk
            // CLAIMED
            // DEVICE
            // TEAC
            // CD-532E-B"
            String diskInfo2 = (String) diskStateV.elementAt(i + 1); // "/dev/dsk/c0t0d0
            // /dev/rdsk/c0t0d0"

            String disk_state = split(diskInfo1, 4);

            String disk_nameInfo = split(diskInfo2, 0); // /dev/dsk/c0t0d0
            String disk_name = disk_nameInfo;
            // 只取 / 后面的名称
            if (disk_nameInfo.indexOf('/') > -1) {
                disk_name = disk_nameInfo.substring(disk_nameInfo
                        .lastIndexOf('/') + 1, disk_nameInfo.length());
            }

            disk_stateMap.put(disk_name, disk_state);
            collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                    + Formater.neatenunitid(disk_name), "FM-00-01-001-02",
                    disk_state);
        }

        // 从出现Average的这行开始,每一行表示一个磁盘的数据
//        Vector diskV = rpctarget.getKPISet("sar -d 5 5");
        List<String> diskV = list.get(1);
        Set sarDiskSet = new HashSet(); // 保存所有sar命令能取到的io设备名称
        for (int i = 0; i < diskV.size(); i++) {
//            String disk_value = (String) diskV.elementAt(i);
            String disk_value = (String) diskV.get(i);
            if (disk_value.indexOf("Average") < 0)
                continue;

            String disk_name = split(disk_value, 1);
            sarDiskSet.add(disk_name);

            String neat_disk_name = Formater.neatenunitid(disk_name);

            // 磁盘物理IO操作速率
            value = split(disk_value, 5);
            collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                    + neat_disk_name, "PM-00-01-003-01", Formater
                    .formatDecimalKpivalue(value));

            // 等待磁盘系统进程线程数
            value = split(disk_value, 3);
            collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                    + neat_disk_name, "PM-00-01-003-02", Formater
                    .formatDecimalKpivalue(value));

            // 磁盘忙的百分比
            value = split(disk_value, 2);
            collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                    + neat_disk_name, "PM-00-01-003-03", Formater
                    .formatDecimalKpivalue(value));

            // 每秒读请求
            value = split(disk_value, 4);
            collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                    + neat_disk_name, "PM-00-01-003-04", Formater
                    .formatDecimalKpivalue(value));

            // 每秒写请求
            value = split(disk_value, 4);
            collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name + "-"
                    + neat_disk_name, "PM-00-01-003-05", Formater
                    .formatDecimalKpivalue(value));

        }

        // 给sar命令没有取到的磁盘设备,该设备为CLAIMED状态的情况 附初始值
        Set allDiskSet = disk_stateMap.keySet();
        Iterator iter = allDiskSet.iterator();
        while (iter.hasNext()) {
            String disk_name = (String) iter.next();
            if (sarDiskSet.contains(disk_name)) {
                continue;
            } else {
                if (disk_stateMap.get(disk_name).equals("CLAIMED")) {
                    String neat_disk_name = Formater.neatenunitid(disk_name);
                    // 磁盘物理IO操作速率
                    collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name
                            + "-" + neat_disk_name, "PM-00-01-003-01", "0");
                    // 等待磁盘系统进程线程数
                    collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name
                            + "-" + neat_disk_name, "PM-00-01-003-02", "0");
                    // 磁盘忙的百分比
                    collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name
                            + "-" + neat_disk_name, "PM-00-01-003-03", "0");
                    // 每秒读请求
                    collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name
                            + "-" + neat_disk_name, "PM-00-01-003-04", "0");
                    // 每秒写请求
                    collResult.addKPI(disk_PRE_UNITID + ":" + neat_host_name
                            + "-" + neat_disk_name, "PM-00-01-003-05", "0");
                }

            }
        }

        return collResult.getKPISet();
    }

    private Vector transMSG(List vec) {
        Vector vector = new Vector();
        int size = vec.size();
        String tmp = "";

        for (int i = 0; i < size; i++) {
//            String msg_1 = (String) vec.elementAt(i);
            String msg_1 = (String) vec.get(i);
            if (msg_1.indexOf("/dev/dsk") != -1
                    && tmp.indexOf("/dev/dsk") != -1) {
                continue;
            }
            vector.addElement(msg_1);
            tmp = msg_1;
        }
        return vector;
    }

    public Vector<TblATO_KPIDETAIL> getAllProcess(HashMap<String, String> params) {
        logger.info("[HP COLL]begin getAllProcess");

        String pro_PRE_UNITID = PRE_UNITID + "-15"; // total值
        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;
        try{
            exec(SH_COLL_ALLPROCESS);
            // 获得脚本执行结果
            result = getResult(RESULT_ALLPROCESS);
            if(result == null || result.size() == 0){
                return collResult.KPISet;
            }
            list = parseResult(result,2);
        } catch (Exception e){
            logger.error("[HP COLL] Exception while execute "+SH_COLL_ALLPROCESS,e);
        }
        String deviceId = params.get("DEVICE_ID");
        if(null==deviceId || "".equals(deviceId.trim())){
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        // 得到unit_id中使用的主机名称
        String neat_host_name = Formater.neatenunitid(deviceId);

        String unit_process = "export UNIX95=XPG4;ps -ef -o pcpu,state,sz,pid,ruser,stime,args | grep -v '%CPU'";

	
	/*	String unit_process = "ps -ef -o pcpu,state,sz,pid,ruser,stime,args | grep \""
			+ process_name + "\" | grep -v grep | grep -v '%CPU'";
	
	*/
        logger.info("process_name_cmd=" + unit_process);
//        Vector proV = rpctarget.getKPISet(unit_process);
        List<String> proV = list.get(1);
        for (int i = 0; i < proV.size(); i++) {
//            String pro_info = (String) proV.elementAt(i);
            String pro_info = (String) proV.get(i);
            String pcpu = split(pro_info, 0); // 占用cpu时间
            String state = split(pro_info, 1);
            if (state.equals("R")) {
                state = "Running";
            } else if (state.equals("S")) {
                state = "Sleeping";
            } else if (state.equals("0")) {
                state = "Nonexistent";
            } else if (state.equals("W")) {
                state = "Waiting";
            } else if (state.equals("I")) {
                state = "Intermediate";
            } else if (state.equals("Z")) {
                state = "Terminated";
            } else if (state.equals("T")) {
                state = "Stopped";
            } else if (state.equals("X")) {
                state = "Growing";
            }
            String vsz = split(pro_info, 2);
            String pid = split(pro_info, 3);
            String puser = split(pro_info, 4);

            String pstime = split(pro_info, 5);
            pstime = pstime.indexOf(":") > -1 ? pstime : pstime + split(pro_info, 6); // 把那种月份+天的时间加上
            int pos_command = pstime.indexOf(":") > 0 ? 6 : 7; // 有冒号就是第6位,没有就是第7位
            String command = split(pro_info, pos_command);
            String full_command = pro_info.substring(pro_info.indexOf(command), pro_info.length());

            collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + i,
                    "TM-00-01-005-01", Formater.formatDecimalKpivalue(pcpu));
            collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + i,
                    "TM-00-01-005-02", state);
            collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + i,
                    "TM-00-01-005-03", full_command);
            collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + i,
                    "TM-00-01-005-04", pstime);
            collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + i,
                    "TM-00-01-005-05", Formater.formatDecimalKpivalue(vsz));
			/*collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + i,
					"TM-00-01-005-07", ""+i);*/
            collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + i,
                    "TM-00-01-005-08", pid);
            collResult.addKPI(pro_PRE_UNITID + ":" + neat_host_name + "-" + i,
                    "TM-00-01-005-09", puser);

        }
        return collResult.getKPISet();
    }

    // 采集Syslog
    public Vector<TblATO_KPIDETAIL> getSyslog(HashMap<String, String> params) {
        logger.info("begin getSyslog ");
        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        String host_ip = (String) params.get("IP_ADDR");
        String data_path = (String) params.get("bin_home");
        String now_filename = "now_" + host_ip + ".dat";
        String tmp_filename = "tmp_" + host_ip + ".dat";
        String diff_filename = "diff_" + host_ip + ".dat";
        List<String> result = null;
        List<List<String>> list = null;
        try {

            String syslogcmd = "grep -E 'EMS|err' /var/adm/syslog/syslog.log | sed -n \"1,1000p\"";
            exec(SH_COLL_SYSLOG);
            result = getResult(RESULT_SYSLOG);
            if(result == null || result.size() == 0){
                return collResult.KPISet;
            }
            list = parseResult(result,2);
//            Vector syslogV = rpctarget.getKPISet(syslogcmd);
            List<String> syslogV = list.get(1);
            String now = this.getVetorString(syslogV);

            File now_file = new File(data_path + now_filename);// 最新日志信息
            File tmp_file = new File(data_path + tmp_filename);// 上周期日志信息
            File diff_file = new File(data_path + diff_filename);// 增量日志
            PrintWriter write_now = new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream(now_file), "GB2312"));
            PrintWriter write_tmp = new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream(tmp_file, true), "GB2312"));
            PrintWriter write_diff = new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream(diff_file), "GB2312"));
            String path = now_file.getAbsolutePath();
            logger.info("Current path is " + path);
            // 日志解析
            if (tmp_file.exists() && tmp_file.length() > 0) {// 非第一次采集
                write_now.write(now);
                write_now.flush();
                write_now.close();
                // 读取上周期日志文件(tmp)
                FileReader tmp_reader = new FileReader(tmp_file);
                BufferedReader tmp = new BufferedReader(tmp_reader);
                String line;
                String tmp_file_string = "";
                while ((line = tmp.readLine()) != null) {
                    tmp_file_string += line + "\n";
                }
                tmp.close();
                tmp_reader.close();
                // 读取本周期日志文件(now),生成差异文件(diff)
                FileReader now_reader = new FileReader(now_file);
                BufferedReader br = new BufferedReader(now_reader);
                while ((line = br.readLine()) != null) {
                    if (tmp_file_string.indexOf(line) == -1)
                        write_diff.write(line);
                    else
                        continue;
                }
                br.close();
                now_reader.close();
                write_diff.flush();
                write_diff.close();
                write_tmp = new PrintWriter(new OutputStreamWriter(
                        new FileOutputStream(tmp_file), "GB2312"));
                write_tmp.write(now);
                write_tmp.flush();
                write_tmp.close();
            } else {// 第一次采集
                write_tmp.write(now);
                write_tmp.flush();
                write_tmp.close();
                write_diff.write(now);
                write_diff.flush();
                write_diff.close();
            }
            // 生成指标
            FileReader diff_reader = new FileReader(diff_file);
            BufferedReader diff = new BufferedReader(diff_reader);
            String line1;
            // 获取主机名称
            String deviceId = params.get("DEVICE_ID");
            if(null==deviceId || "".equals(deviceId.trim())){
                List<String> vHostName = list.get(0);
                deviceId = split(vHostName.get(0), 1);
            }
            String host_name = deviceId;
            // 得到unit_id中使用的主机名称
            String neat_host_name = Formater.neatenunitid(host_name);
            int j = 0;
            //限制为10条
            while ((line1 = diff.readLine()) != null && j < 10) {
			/*	String value1 = "err";
				String value2 = (line1.split("Value:"))[1];
				String[] value3_m = ((line1.split(":"))[2]).split(" ");
				String value3 = value3_m[2] + value3_m[3];
				String[] value4_m = line1.split(" ");
				String value4 = value4_m[0] + value4_m[1] + value4_m[2];*/
                String unitid = "10-10-21-20:" + neat_host_name + "-syslog-"
                        + j;
                collResult.addKPI(unitid, "FM-00-01-900-04", line1);
                collResult.addKPI(unitid, "CM-00-01-900-03", "err");
                j++;
            }
            diff.close();
            diff_reader.close();
        } catch (Exception e) {
            e.getMessage();
            e.printStackTrace();
        } finally {

        }
        return collResult.getKPISet();
    }

    /**
     * 新增时钟同步信息KPI信息
     * PM-00-01-006-01	远程服务器名称
     * PM-00-01-006-03	远程服务器级别
     * PM-00-01-006-04	请求间隔
     * PM-00-01-006-05	同步频率
     * PM-00-01-006-07	循环时间
     * PM-00-01-006-08	时间偏移量
     * PM-00-01-006-09	时间精确度
     */
    public Vector<TblATO_KPIDETAIL> getClockInfo(HashMap<String, String> params) {

        logger.info("[HP COLL]begin getClockInfo");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;
        try{
            exec(SH_COLL_CLOCK);
            // 获得脚本执行结果
            result = getResult(RESULT_CLOCK);
            if(result == null || result.size() == 0){
                return collResult.KPISet;
            }
            // 分隔每个命令的执行结果
            list = parseResult(result, 1);
        } catch (Exception e){
            logger.error("[HP COLL] Exception while execute "+SH_COLL_CLOCK,e);
        }

        // 本方法得到的kpi值的unit_id,均以PRE_UNITID + "-24"开头
        String ntpq_PRE_UNITID = PRE_UNITID + "-24";

        // 获取主机名称
        String deviceId = params.get("DEVICE_ID");
        if(null==deviceId || "".equals(deviceId.trim())){
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        // 得到unit_id中使用的主机名称
        String neat_host_name = Formater.neatenunitid(deviceId);

        // 增加采集时间指标
        String pattern = "yyyy-MM-dd-HH-mm-ss";
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);

//        Vector ntpqV = rpctarget.getKPISet("/usr/sbin/ntpq -p ");
        List<String> ntpqV = list.get(0);
        String remoteName, remoteST, lastWhen, poll, delay, offset, jitter;
        if (ntpqV != null && ntpqV.size() > 0) {
            for (int i = 2; i < ntpqV.size(); i++) {
//                logger.info("into getClockInfo" + (String) ntpqV.elementAt(i));
                logger.info("into getClockInfo" + (String) ntpqV.get(i));
//                String strTmp = (String) ntpqV.elementAt(i);
                String strTmp = (String) ntpqV.get(i);
                remoteName = split(strTmp, 0);        //远程服务器名
                remoteST = split(strTmp, 2);        //服务器级别
                lastWhen = split(strTmp, 4);        //请求间隔
                poll = split(strTmp, 5);            //同步频率
                delay = split(strTmp, 7);            //循环时间
                offset = split(strTmp, 8);            //时间偏移量
                jitter = split(strTmp, 9);            //时间精确度
                logger.info("into my getClockInfo" + remoteName + "--" + remoteST + "--" + lastWhen + "--" + poll + "--" + delay + "--" + offset + "--" + jitter);

                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-ntpq" + i,
                        "PM-00-01-006-01", remoteName);
                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-ntpq" + i,
                        "PM-00-01-006-03", remoteST);
                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-ntpq" + i,
                        "PM-00-01-006-05", lastWhen);
                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-ntpq" + i,
                        "PM-00-01-006-06", poll);
                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-ntpq" + i,
                        "PM-00-01-006-08", delay);
                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-ntpq" + i,
                        "PM-00-01-006-09", offset);
                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-ntpq" + i,
                        "PM-00-01-006-10", jitter);
                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-ntpq" + i,
                        "CM-00-01-001-99", dateFormat.format(new java.util.Date()));
            }
        }
        return collResult.getKPISet();
    }

    /**
     * 采集指定路径文件大小信息
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getFileSize(HashMap<String, String> params) {
        logger.info("[HP COLL]begin getFileSize");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;
        try{
            exec(SH_COLL_FILESIZE);
            // 获得脚本执行结果
            result = getResult(RESULT_FILESIZE);
            if(result == null || result.size() == 0){
                return collResult.KPISet;
            }
            // 分隔每个命令的执行结果
            list = parseResult(result, 2);
        } catch (Exception e){
            logger.error("[HP COLL] Exception while execute "+SH_COLL_FILESIZE,e);
        }
        try{
            // 本方法得到的kpi值的unit_id,均以PRE_UNITID + "-27"开头
            String ntpq_PRE_UNITID = PRE_UNITID + "-27";

            // 获取主机名称
            String deviceId = params.get("DEVICE_ID");
            if(null==deviceId || "".equals(deviceId.trim())){
                List<String> vHostName = list.get(0);
                deviceId = split(vHostName.get(0), 1);
            }
            // 得到unit_id中使用的主机名称
            String neat_host_name = Formater.neatenunitid(deviceId);

            List<String> fileSizes = list.get(1);
            String now = this.getVetorString(fileSizes);
            String data_path = "../filechange";
            String last_filename = "last_" + deviceId + "-fileSize.dat";

            //目录不存在则创建
            File f = new File(data_path);
            if(!f.exists()){
                f.mkdir();
            }

            File last_file = new File(data_path+"/" + last_filename);// 最近日志信息

            String path = last_file.getAbsolutePath();
            logger.info("Current path is " + path);
            // 日志解析
            if (last_file.exists() && last_file.length() > 0) {// 非第一次采集
                // 读取上次日志文件(last)
                FileReader last_reader = new FileReader(last_file);
                BufferedReader last = new BufferedReader(last_reader);
                String line;
                while ((line = last.readLine()) != null) {
                    String fileSize, filePath;
                    if (fileSizes != null && fileSizes.size() > 0) {
                        for (int i = 0; i < fileSizes.size(); i++) {
                            logger.info("into getFileSize:" + (String) fileSizes.get(i));
                            String strTmp = (String) fileSizes.get(i);
                            double tempSize = Double.parseDouble(split(strTmp, 0));
                            fileSize = BigDecimal.valueOf(tempSize).divide(BigDecimal.valueOf(1024),2, RoundingMode.HALF_UP).toString();
                            filePath = split(strTmp, 1);
                            if(filePath.equals(split(line,1))){
                                logger.info("into my getFileSize:" + fileSize + "--" + filePath);
                                //关键路径
                                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-" + filePath,
                                        "CM-20-21-027-01", filePath);
                                //关键路径大小
                                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-" + filePath,
                                        "PM-20-21-027-01", fileSize);
                                //关键路径大小变动比率
                                collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-" + filePath, "PM-00-01-004-15",
                                        BigDecimal.valueOf(tempSize-Double.parseDouble(split(line,0))).multiply(BigDecimal.valueOf(100)).divide
                                                (BigDecimal.valueOf(Double.parseDouble(split(line,0))),
                                                1, RoundingMode.HALF_UP).toString());
                            }
                        }
                    }
                }
                last.close();
                last_reader.close();
            } else {// 第一次采集
                String fileSize, filePath;
                if (fileSizes != null && fileSizes.size() > 0) {
                    for (int i = 0; i < fileSizes.size(); i++) {
                        logger.info("into getFileSize:" + (String) fileSizes.get(i));
                        String strTmp = (String) fileSizes.get(i);
                        double tempSize = Double.parseDouble(split(strTmp, 0));
                        fileSize = BigDecimal.valueOf(tempSize).divide(BigDecimal.valueOf(1024),2, RoundingMode.HALF_UP).toString();
                        filePath = split(strTmp, 1);
                        logger.info("into my getFileSize:" + fileSize + "--" + filePath);
                        //关键路径
                        collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-" + filePath,
                                "CM-20-21-027-01", filePath);
                        //关键路径大小
                        collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-" + filePath,
                                "PM-20-21-027-01", fileSize);
                    }
                }
            }

            //生成指标后,将最新信息写入记录文件
            PrintWriter write_last = new PrintWriter(new OutputStreamWriter(new FileOutputStream(last_file), "GB2312"));
            write_last.write(now);
            write_last.flush();
            write_last.close();
        } catch (Exception e) {
            e.getMessage();
            e.printStackTrace();
            logger.error("[HP COLL] Exception while execute "+SH_COLL_FILESIZE,e);
        } finally {
        }
        return collResult.getKPISet();
    }

    /**
     * 采集硬件信息
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getHardware(HashMap<String, String> params) {
        logger.info("[HP COLL]begin getHardware");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;
        try{
            //脚本指令需root权限,由crontab执行
//            exec(SH_COLL_HARDWARE);
            // 获得脚本执行结果
            result = getResult(RESULT_HARDWARE);
            if(result == null || result.size() == 0){
                return collResult.KPISet;
            }
            // 分隔每个命令的执行结果
            list = parseResult(result, 7);

            // 本方法得到的kpi值的unit_id,均以PRE_UNITID + "-28"开头
            String ntpq_PRE_UNITID = PRE_UNITID + "-28";

            // 获取主机名称
            String deviceId = params.get("DEVICE_ID");
            if(null==deviceId || "".equals(deviceId.trim())){
                List<String> vHostName = list.get(0);
                deviceId = split(vHostName.get(0), 1);
            }
            // 得到unit_id中使用的主机名称
            String neat_host_name = Formater.neatenunitid(deviceId);

            logger.info(list);
            List<String> cpuInfo = list.get(1);
            String cpuNUM = cpuInfo.isEmpty()? "0":Integer.toString(cpuInfo.size()-2);
            collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name+"-hardware",
                    "FM-00-01-028-01", cpuNUM);

            List<String> memoryInfo = list.get(2);
            String memorySize = memoryInfo.isEmpty()? "fail":split(memoryInfo.get(0),1);
            collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name+"-hardware",
                    "FM-00-01-028-02", memorySize);

            List<String> diskInfo = list.get(3);
            String diskNUM = diskInfo.isEmpty()? "0":Integer.toString(diskInfo.size() - 2);
            collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name+"-hardware",
                    "FM-00-01-028-03", diskNUM);

            List<String> lanInfo = list.get(4);
            String lanNUM = lanInfo.isEmpty()? "0":Integer.toString(lanInfo.size() - 2);
            collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name+"-hardware",
                    "FM-00-01-028-04", lanNUM);

            List<String> fcInfo = list.get(5);
            String fcNUM = fcInfo.isEmpty()? "0":Integer.toString(fcInfo.size()-2);
            collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name+"-hardware",
                    "FM-00-01-028-05", fcNUM);

            List<String> mpInfo = list.get(6);
            String mpLineNUM = mpInfo.isEmpty()? "0":Integer.toString(mpInfo.size());
            collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name+"-hardware",
                    "FM-00-01-028-06", mpLineNUM);
        } catch (Exception e){
            logger.error("[HP COLL] Exception while execute "+SH_COLL_HARDWARE,e);
        }
        return collResult.getKPISet();
    }

    /**
     * 采集mount点下文件信息
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getFileMount(HashMap<String, String> params) {
        logger.info("[HP COLL]begin getFileMount");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;

//        exec(SH_COLL_FILEMOUNT);
        // 获得脚本执行结果
        result = getResult(RESULT_FILEMOUNT);
        if(result == null || result.size() == 0){
            return collResult.KPISet;
        }
        // 分隔每个命令的执行结果
        list = parseResult(result, 2);


        // 获取主机名称
        String deviceId = params.get("DEVICE_ID");
        if(null==deviceId || "".equals(deviceId.trim())){
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        // 得到unit_id中使用的主机名称
        String neat_host_name = Formater.neatenunitid(deviceId);

        try {
            //得到挂载点 UnitId
            String mountUnitId = PRE_UNITID + "-29:" +  neat_host_name + "-";
            String dir = "../filechange";
            String path = "../filechange/mountSize.properties";
            Hashtable<String , String> ht = new Hashtable<String , String>();
            //目录不存在则创建
            File f = new File(dir);
            if(!f.exists()){
                f.mkdir();
            }
            //如果没有文件则创建
            PropertyUtils.createPropertiesFile(path, new Hashtable<String, String>());
            Properties pro =  PropertyUtils.getProperties(path);
            //得到锁文件
            LockFile file = new LockFile(path);
            ReentrantReadWriteLock lock = file.getLock();
            //如果该文件已经加锁则等待
            while(true){
                if(lock.isWriteLocked()){
                    Thread.sleep(1000);
                }else{
                    lock.writeLock().lock();
                    break;
                }
            }

            //mount点下是否有隐藏文件
            List<String> mountInfo = list.get(1);
            if (mountInfo != null && mountInfo.size() > 0) {
                for (int i = 0; i < mountInfo.size(); i++) {
                    logger.info("into getFileMount-mount on:" + (String) mountInfo.get(i));
                    //mount点
                    String fileMount =split((String) mountInfo.get(i), 0);
                    ///dev/vg00/lvol3 mount点下文件挂载数
                    String fileMountNUM_ff =split((String) mountInfo.get(i+1), 0);
                    //mount点下文件挂载数
                    String fileMountNUM_bdf =split((String) mountInfo.get(i+2), 0);
                    //mount点下占用空间大小
                    String mountSize =split((String) mountInfo.get(i+3), 0);
                    //mount点名称
                    collResult.addKPI(mountUnitId+fileMount,
                            "CM-20-21-029-01", fileMount);
                    ///dev/vg00/lvol3 mount点下文件挂载数(ff获取)
                    collResult.addKPI(mountUnitId+fileMount,
                            "PM-20-21-029-01", fileMountNUM_ff);
                    //mount点下文件挂载数(bdf获取)
                    collResult.addKPI(mountUnitId+fileMount,
                            "PM-20-21-029-02", fileMountNUM_bdf);

                    checkMountSize(collResult, mountUnitId, path, pro, ht, fileMount, mountSize);
                    i=i+3;
                }
            }
            PropertyUtils.setValueAndStore(path, ht);
            lock.writeLock().unlock();
        } catch (Exception e){
            logger.error("[HP COLL] Exception while execute getFileMount",e);
        }

        return collResult.getKPISet();
    }

    /**
     * 网络连接性故障信息
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getNetLog(HashMap<String, String> params) {
        logger.info("begin getNetLog ");
        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;
        try {

            exec(SH_COLL_NETLOG);
            result = getResult(RESULT_NETLOG);
            if(result == null || result.size() == 0){
                return collResult.KPISet;
            }
            list = parseResult(result,2);

            // 获取主机名称
            String deviceId = params.get("DEVICE_ID");
            if(null==deviceId || "".equals(deviceId.trim())){
                List<String> vHostName = list.get(0);
                deviceId = split(vHostName.get(0), 1);
            }

            List<String> netlogV = list.get(1);
            String now = this.getVetorString(netlogV);
            String data_path = "../filechange";
            String now_filename = "now_" + deviceId + "-netlog.dat";
            String tmp_filename = "tmp_" + deviceId + "-netlog.dat";
            String diff_filename = "diff_" + deviceId + "-netlog.dat";

            //目录不存在则创建
            File f = new File(data_path);
            if(!f.exists()){
                f.mkdir();
            }

            File now_file = new File(data_path+"/" + now_filename);// 最新日志信息
            File tmp_file = new File(data_path+"/" + tmp_filename);// 上次日志信息
            File diff_file = new File(data_path+"/" + diff_filename);// 增量日志
            PrintWriter write_now = new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream(now_file), "GB2312"));
            PrintWriter write_tmp = new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream(tmp_file, true), "GB2312"));
            PrintWriter write_diff = new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream(diff_file), "GB2312"));
            String path = now_file.getAbsolutePath();
            logger.info("Current path is " + path);
            // 日志解析
            if (tmp_file.exists() && tmp_file.length() > 0) {// 非第一次采集
                write_now.write(now);
                write_now.flush();
                write_now.close();
                // 读取上次日志文件(tmp)
                FileReader tmp_reader = new FileReader(tmp_file);
                BufferedReader tmp = new BufferedReader(tmp_reader);
                String line;
                String tmp_file_string = "";
                while ((line = tmp.readLine()) != null) {
                    tmp_file_string += line + "\n";
                }
                tmp.close();
                tmp_reader.close();
                // 读取本次日志文件(now),生成差异文件(diff)
                FileReader now_reader = new FileReader(now_file);
                BufferedReader br = new BufferedReader(now_reader);
                while ((line = br.readLine()) != null) {
                    if (tmp_file_string.indexOf(line) == -1)
                        write_diff.write(line);
                    else
                        continue;
                }
                br.close();
                now_reader.close();
                write_diff.flush();
                write_diff.close();
                write_tmp = new PrintWriter(new OutputStreamWriter(
                        new FileOutputStream(tmp_file), "GB2312"));
                write_tmp.write(now);
                write_tmp.flush();
                write_tmp.close();
            } else {// 第一次采集
                write_tmp.write(now);
                write_tmp.flush();
                write_tmp.close();
                write_diff.write(now);
                write_diff.flush();
                write_diff.close();
            }
            // 生成指标
            FileReader diff_reader = new FileReader(diff_file);
            BufferedReader diff = new BufferedReader(diff_reader);
            String host_name = deviceId;
            // 得到unit_id中使用的主机名称
            String neat_host_name = Formater.neatenunitid(host_name);
            int j = 0;
            String tempDiff = "";
            String tempLine = "";
            //限制为10条
            while ((tempLine = diff.readLine()) != null && j < 10) {
//                tempDiff =tempDiff+ tempLine+ "\r\n";
                j++;

            }
            //配置告警kpi-网络连接性故障
            if (j>0){
                collResult.addKPI("10-10-21-28:" + neat_host_name, "FM-00-01-028-06","true");
//                collResult.addKPI("10-10-21-69:" + neat_host_name+ "-netLogDiff", "FM-00-01-028-07", tempDiff);
            }else{
                collResult.addKPI("10-10-21-28:" + neat_host_name, "FM-00-01-028-06","false");
            }

            diff.close();
            diff_reader.close();
        } catch (Exception e) {
            e.getMessage();
            e.printStackTrace();
        } finally {

        }
        return collResult.getKPISet();
    }

    /**
     * 内置RAID状态检查(适用于配置了SAS RAID控制卡的主机)
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getRAIDStatus(HashMap<String, String> params) {
        logger.info("[HP COLL]begin getRAIDStatus");

        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;

//        exec(SH_COLL_RAIDSTATUS);
        // 获得脚本执行结果
        result = getResult(RESULT_RAIDSTATUS);
        if(result == null || result.size() == 0){
            return collResult.KPISet;
        }
        // 分隔每个命令的执行结果
        list = parseResult(result, 3);


        // 获取主机名称
        String deviceId = params.get("DEVICE_ID");
        if(null==deviceId || "".equals(deviceId.trim())){
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        // 得到unit_id中使用的主机名称
        String neat_host_name = Formater.neatenunitid(deviceId);
        // 本方法得到的kpi值的unit_id,均以PRE_UNITID + "-28"开头
        String ntpq_PRE_UNITID = PRE_UNITID + "-28";
        try{
            List<String> sasmgrInfo = list.get(1);
            int sasmgrFailedNUM = 0;
            if (sasmgrInfo != null && sasmgrInfo.size() > 0) {
                for (int i = 0; i < sasmgrInfo.size(); i++) {
                    if(StringUtils.contains((String) sasmgrInfo.get(i),"failed")){
                        sasmgrFailedNUM++;
                        logger.info("into sasmgr get_info -D" + (String) sasmgrInfo.get(i));
                    }
                }
            }
            //sasmgr检查错误数
            collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-sasmgrInfo",
                    "FM-00-01-028-08", Integer.toString(sasmgrFailedNUM));
        } catch (Exception e){
            logger.error("[HP COLL] Exception while execute getSasmgrInfo",e);
        }
        try{
            List<String> sautilInfo = list.get(2);
            int sautilFailedNUM = 0;
            if (sautilInfo != null && sautilInfo.size() > 0) {
                for (int i = 0; i < sautilInfo.size(); i++) {
                    if(StringUtils.contains((String) sautilInfo.get(i),"failed")){
                        sautilFailedNUM++;
                        logger.info("into getSautilInfo:" + (String) sautilInfo.get(i));
                    }
                }
            }
            //sautil检查错误数
            collResult.addKPI(ntpq_PRE_UNITID + ":" + neat_host_name + "-sautilInfo",
                    "FM-00-01-028-09", Integer.toString(sautilFailedNUM));
        } catch (Exception e){
            logger.error("[HP COLL] Exception while execute getSautilInfo",e);
        }

        return collResult.getKPISet();
    }


    public Vector getProcessTop10Cpu(HashMap params) {
        logger.info("begin getProcessTop10Cpu");
        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;

        exec(SH_COLL_PROCESS);
        // 获得脚本执行结果
        result = getResult(RESULT_PROCESS);
        if(result == null || result.size() == 0){
            return collResult.KPISet;
        }
        // 分隔每个命令的执行结果
        list = parseResult(result, 2);
        // 获取主机名称
        String deviceId = (String)params.get("DEVICE_ID");
        if(null==deviceId || "".equals(deviceId.trim())){
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        // 得到unit_id中使用的主机名称
        String neat_host_name = Formater.neatenunitid(deviceId);
        try {
            //占用CPU前十进程
            String pro_PRE_UNITID = PRE_UNITID + "-32:" + neat_host_name;
            List<String> processInfos = list.get(1);
            if (processInfos == null || processInfos.equals("") || processInfos.equals("null")) {
                //
            } else {
                //拆出进程信息
                String tempLine = "CPU TTY  PID USERNAME PRI NI   SIZE    RES STATE    TIME %WCPU  %CPU COMMAND";
                int processLine = 0;
                for (int i = 0;i< processInfos.size();i++) {
                    if(processInfos.get(i).equals(tempLine)){
                        processLine = i+1;
                    }
                }
                processInfos = processInfos.subList(processLine,processInfos.size());
                //解析结果
                int k = 1;
                for(String processInfo : processInfos){
                    String processPid = split(processInfo, 2);
                    String processUser = split(processInfo, 3);
                    String processMem = split(processInfo, 7);
                    String processState = split(processInfo, 8);
                    String processCpu = split(processInfo, 10);
                    String unitId = pro_PRE_UNITID + "-" + k++;
                    // 进程用户
                    collResult.addKPI(unitId, "CM-00-01-005-06", processUser);
                    // 进程PID
                    collResult.addKPI(unitId, "CM-00-01-005-01", processPid);
                    // 进程占用CPU百分比
                    collResult.addKPI(unitId, "PM-00-01-005-10", processCpu);
                    // 进程占用MEM
                    collResult.addKPI(unitId, "PM-00-01-005-14", processMem);
                    // 进程状态
                    collResult.addKPI(unitId, "PM-00-01-005-02", processState);
                }
            }
        } catch (Exception e) {
            logger.error("getProcessTop10Cpu has error", e);
        }
        logger.info("end getProcessTop10Cpu");
        return collResult.getKPISet();
    }

    public Vector getProcessByKey(HashMap<String, String> params) {
        logger.info("begin getProcessByKey");
        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;
        String keywords = params.get("KEYWORDS");
        String[] keywordsList = keywords.split("#");

        exec(SH_COLL_KEY_PROCESS);
        // 获得脚本执行结果
        result = getResult(RESULT_KEY_PROCESS);
        if(result == null || result.size() == 0){
            return collResult.KPISet;
        }
        // 分隔每个命令的执行结果
        list = parseResult(result, 3);
        // 获取主机名称
        String deviceId = (String)params.get("DEVICE_ID");
        if(null==deviceId || "".equals(deviceId.trim())){
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        // 得到unit_id中使用的主机名称
        String neat_host_name = Formater.neatenunitid(deviceId);
        try {
            String pro_PRE_UNITID = PRE_UNITID + "-25:" + neat_host_name;
            List<String> processInfos = list.get(1);
            List<String> memInfo = list.get(2);
            BigDecimal menTotal = BigDecimal.valueOf(Double.valueOf(split(memInfo.get(0),1)));
            int i = 1;
            for (String processInfo : processInfos) {
                for(String key : keywordsList){
                    if(StringUtils.contains(processInfo,key)){
                        String processUser = split(processInfo, 4);
                        String processPid = split(processInfo, 3);
                        String processCpu = split(processInfo, 0);
                        String processCmd = split(processInfo, 7);
                        processCmd = processCmd+StringUtils.substringAfter(processInfo, processCmd);
                        String memSize = split(processInfo, 2);
                        BigDecimal processMem = BigDecimal.valueOf(Double.valueOf(memSize)*400).divide(menTotal.multiply(BigDecimal.valueOf(1024)),2,RoundingMode.HALF_UP);
                        System.out.println(processUser + "#@#" + processPid + "#@#" + processCpu + "#@#" + processMem.toString());
                        String unitId = pro_PRE_UNITID + "-" + i++;
                        // 进程用户
                        collResult.addKPI(unitId, "CM-00-01-005-06", processUser);
                        // 进程ID
                        collResult.addKPI(unitId, "CM-00-01-005-01", processPid);
                        // 进程占用CPU百分比
                        collResult.addKPI(unitId, "PM-00-01-005-10", processCpu);
                        // 进程占用MEM百分比
                        collResult.addKPI(unitId, "PM-00-01-005-11", processMem.toString());
                        // 进程指令行
                        collResult.addKPI(unitId, "CM-00-01-005-08", processCmd);
                        // 更新时间
                        collResult.addKPI(unitId, "CM-00-03-002-10", Formater.datetimeToString(new Date()));
                    }
                }
            }
        } catch (Exception e) {
            logger.error("getProcessTop10Cpu has error", e);
        }
        logger.info("end getProcessTop10Cpu");
        return collResult.getKPISet();
    }
    /**
     * 网络信息
     * @param params
     * @return
     */
    public Vector<TblATO_KPIDETAIL> getNet(HashMap<String, String> params) {
        logger.info("[HP COLL]begin getNet");
        // 保存采集结果,并返回值
        CollBase collResult = new CollBase();
        List<String> result = null;
        List<List<String>> list = null;

        exec(SH_COLL_NET);
        // 获得脚本执行结果
        result = getResult(RESULT_NET);
        if(result == null || result.size() == 0){
            return collResult.KPISet;
        }
        // 分隔每个命令的执行结果
        list = parseResult(result, 4);


        // 获取主机名称
        String deviceId = params.get("DEVICE_ID");
        if(null==deviceId || "".equals(deviceId.trim())){
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        // 得到unit_id中使用的主机名称
        String neat_host_name = Formater.neatenunitid(deviceId);
        String unitId = PRE_UNITID + "-10:"+neat_host_name+"-total";
        try{
            List<String> netResult = list.get(1);
            int fin_wait_number =0;
            int wait_number =0;
            int established_number =0;
            for(String tempNet : netResult){
                if(tempNet.contains("FIN")){
                    fin_wait_number++;
                }else if(tempNet.contains("WAIT")){
                    wait_number++;
                }else if(tempNet.contains("ESTABLISHED")){
                    established_number++;
                }
            }
            // 失效网络数
            collResult.addKPI(unitId, "PM-00-01-006-11", Integer.toString(fin_wait_number));
            // 等待网络数
            collResult.addKPI(unitId, "PM-00-01-006-12",Integer.toString(wait_number));
            // 连接网络数
            collResult.addKPI(unitId, "PM-00-01-006-13",Integer.toString(established_number));
        } catch (Exception e){
            logger.error("[HP COLL] Exception while execute getNet",e);
        }

        // ---------------------------- 网卡配置Begin -------------------------------------------
        // netstat -in | grep -v Mtu | grep -v 127.0.0.1 | grep -v none

        logger.info("=========================netstat  lanscan start=========================");
        List<String> netstatV = list.get(2);

        // lanscan | grep -v Hardware | grep -v Path
        List<String> lanscanV = list.get(3);

        // CM-00-01-001-10 系统网络接口数 , lanscan得出的行数
        collResult.addKPI(unitId, "CM-00-01-001-10", String.valueOf(lanscanV.size()));

        Map<String, String> ips = new HashMap<String, String>();
        long lan_ipkts_total = 0;
        long lan_opkts_total = 0;
        for (String netstatInfo: netstatV) {
            String lanName = split(netstatInfo, 0);
            String ip = split(netstatInfo, 3);
            lan_ipkts_total = lan_ipkts_total+ Long.parseLong(split(netstatInfo, 4));
            lan_opkts_total = lan_opkts_total+ Long.parseLong(split(netstatInfo, 6));
            ips.put(lanName, ip);
        }
        //网卡总出包数
        collResult.addKPI(unitId, "PM-00-01-001-17", String.valueOf(lan_opkts_total));
        //网卡总入包数
        collResult.addKPI(unitId, "PM-00-01-001-18", String.valueOf(lan_ipkts_total));

        Map<String, String> phyAddrMap = new HashMap<String, String>();
        Map<String, String> ifStateMap = new HashMap<String, String>();
        for (String lancanInfo : lanscanV) {
            String lanName = split(lancanInfo, 4);
            String phyAddr = split(lancanInfo, 1);
            String ifState = split(lancanInfo, 3);
            phyAddrMap.put(lanName, phyAddr);
            ifStateMap.put(lanName, ifState);
        }

        Set<String> ipskeys = ips.keySet();
        Object[] arrObj = ipskeys.toArray();

        String serviceIp = "";
        for (String lanName : ips.keySet()) {
            if (null != phyAddrMap.get(lanName)) {
                String ifUnitId = this.PRE_UNITID + "-16:" + deviceId + "-" + Formater.neatenunitid(lanName);
                // 系统网络接口IP地址
                collResult.addKPI(ifUnitId, "CM-00-01-001-11", ips.get(lanName));

                // 系统网络接口物理地址
                collResult.addKPI(ifUnitId, "CM-00-01-001-12", phyAddrMap.get(lanName));

                // 网卡状态
                collResult.addKPI(ifUnitId, "FM-00-01-001-03", ifStateMap.get(lanName));

                serviceIp = serviceIp + "," + ips.get(lanName);
            }
        }

        // 主机(服务)地址 CM-00-01-001-02, 将所有ip地址累加
        if (serviceIp.length() > 0) {
            collResult.addKPI(unitId, "CM-00-01-001-02", serviceIp.substring(1));
        }

        logger.info("=========================netstat  lanscan end=========================");
        // ---------------------------- 网卡配置End -------------------------------------------

        return collResult.getKPISet();
    }
    public Vector<TblATO_KPIDETAIL> getFileChange(HashMap<String, String> params) {
        logger.info("Begin getFileChange...");
        logger.info(params.toString());
        CollBase collResult = new CollBase();
        // 执行脚本
        exec(SH_COLL_FILE);
        // 获得脚本执行结果
        List<String> result = getResult(RESULT_FILE);
        if(null == result || result.isEmpty()){
            return collResult.KPISet;
        }
        List<List<String>> list = parseResult(result);
        String deviceId = params.get("DEVICE_ID");
        String UNIT_ID = params.get("KBP_CLASS");
        if(null == deviceId || "".equals(deviceId.trim())){
            // 获取主机名称 : uname -a
            List<String> vHostName = list.get(0);
            deviceId = split(vHostName.get(0), 1);
        }
        //kctune 系统参数变动监控
        try{
            List<String> netlogV = list.get(1);
            String host_name = deviceId;
            // 得到unit_id中使用的主机名称
            String neat_host_name = Formater.neatenunitid(host_name);
            //文件名称
            collResult.addKPI(UNIT_ID + "-20:" + neat_host_name+"-kctune", "CM-10-10-020-01", "kctune");
            Boolean isChange = checkFileChange(netlogV,"kctune",deviceId);
            //变动部分有结果,则生成告警指标
            collResult.addKPI(UNIT_ID + "-20:" + neat_host_name+"-kctune", "FM-10-10-020-01",isChange.toString());

        } catch (Exception e) {
            e.getMessage();
            e.printStackTrace();
        } finally {

        }
        try {
            //得到filechange UnitId
            String filechangeUnitId = UNIT_ID + "-20:" +  deviceId + "-";

            /**
             * 分析传入的文件绝对路径参数
             * 如果传入的参数中是路径则采集该路径下所有的文件
             * 如果传入的参数中包含文件名则采集该文件
             */
            for(int n=2;n <list.size();n++){
                List<String> paths = list.get(n);
                if(paths.size()<2) continue;//如果某条指令结果不正常,跳过;
                String p = paths.get(0);
                //文件名称
                collResult.addKPI(filechangeUnitId+p, "CM-10-10-020-01", p);
                Boolean isChange = checkFileChange(paths,p,deviceId);
                //变动部分有结果,则生成告警指标
                collResult.addKPI(filechangeUnitId+ p, "FM-10-10-020-01",isChange.toString());
            }
        }catch (Exception e) {
            logger.error("Exception while get fileChange!",e);
        }
        logger.info("END COLL fileChange ");
        return collResult.getKPISet();
    }

    private Boolean checkFileChange(List result,String fileName,String deviceId){
        Boolean isChange = false;
        try{
            String now = this.getVetorString(result);
            String data_path = "../filechange";
            fileName = StringUtils.replace(fileName,"/","-");
            String now_filename = "now_" + deviceId + "-"+fileName+".dat";
            String tmp_filename = "tmp_" + deviceId + "-"+fileName+".dat";
            String diff_filename = "diff_" + deviceId + "-"+fileName+".dat";

            //目录不存在则创建
            File f = new File(data_path);
            if(!f.exists()){
                f.mkdir();
            }

            File now_file = new File(data_path+"/" + now_filename);// 最新日志信息
            File tmp_file = new File(data_path+"/" + tmp_filename);// 上次日志信息
            File diff_file = new File(data_path+"/" + diff_filename);// 增量日志
            PrintWriter write_now = new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream(now_file), "GB2312"));
            PrintWriter write_tmp = new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream(tmp_file, true), "GB2312"));
            PrintWriter write_diff = new PrintWriter(new OutputStreamWriter(
                    new FileOutputStream(diff_file), "GB2312"));
            String path = now_file.getAbsolutePath();
            logger.info("Current path is " + path);
            // 日志解析
            if (tmp_file.exists() && tmp_file.length() > 0) {// 非第一次采集
                write_now.write(now);
                write_now.flush();
                write_now.close();
                // 读取上次日志文件(tmp)
                FileReader tmp_reader = new FileReader(tmp_file);
                BufferedReader tmp = new BufferedReader(tmp_reader);
                String line;
                String tmp_file_string = "";
                while ((line = tmp.readLine()) != null) {
                    tmp_file_string += line + "\n";
                }
                tmp.close();
                tmp_reader.close();
                // 读取本次日志文件(now),生成差异文件(diff)
                FileReader now_reader = new FileReader(now_file);
                BufferedReader br = new BufferedReader(now_reader);
                while ((line = br.readLine()) != null) {
                    if (tmp_file_string.indexOf(line) == -1)
                        write_diff.write(line);
                    else
                        continue;
                }
                br.close();
                now_reader.close();
                write_diff.flush();
                write_diff.close();
                write_tmp = new PrintWriter(new OutputStreamWriter(
                        new FileOutputStream(tmp_file), "GB2312"));
                write_tmp.write(now);
                write_tmp.flush();
                write_tmp.close();

                // 生成指标
                FileReader diff_reader = new FileReader(diff_file);
                BufferedReader diff = new BufferedReader(diff_reader);
                //变动部分有结果,则生成告警指标
                if (diff.readLine() != null) {
                    isChange =true;
                }
                diff.close();
                diff_reader.close();
            } else {// 第一次采集
                write_tmp.write(now);
                write_tmp.flush();
                write_tmp.close();
                write_diff.write(now);
                write_diff.flush();
                write_diff.close();
            }
        }catch (Exception e) {
            logger.error("Exception while get fileChange!",e);
        }finally {

            return isChange;
        }
    }

    public String getVetorString(List v) {
        StringBuffer sb = new StringBuffer();
        if (v != null && v.size() > 0) {
            for (int i = 0; i < v.size(); i++) {
                String s = (String) v.get(i);
                if (s != null && i < v.size()) {
                    sb.append(s + "\n");
                }
            }
        }
        return sb.toString();
    }


    /**
     * 通知执行脚本
     * 通知方式:写一个文件(文件名为采集脚本名称,如:getCpu.sh、getMem.sh)到notice目录,
     * contab会定时执行脚本扫描该目录,得到文件名,并执行脚本
     *
     * @throws
     * @since Ver 1.1
     */
    private void exec(String shellName) {
        String noticePath = "../notice/ibm/";
        String noticeFileName = noticePath + shellName;
        PrintWriter kpiFileStream = null;
        try {
            kpiFileStream = new PrintWriter(new FileWriter(Formater.replaceSpace(noticeFileName), false), true);
            kpiFileStream.println(shellName);
        } catch (IOException e) {
            logger.error("[HP COLL] Exception while exec(" + shellName + ")", e);
        } finally {
            if (kpiFileStream != null) {
                kpiFileStream.flush();
                kpiFileStream.close();
            }
        }
    }


    /**
     * 获得脚本执行结果
     *
     * @throws
     * @since Ver 1.1
     */
    private List<String> getResult(String resultFileName) {
        try {
            Thread.sleep(20 * 1000L);
        } catch (InterruptedException e) {
            logger.warn("[HP COLL] InterruptedException.");
        }

        StringBuffer sb = new StringBuffer();
        // 超时时间:2分钟
        long timeout = 3 * 60 * 1000L;
        List<String> result = new ArrayList<String>();
        long beginTime = new Date().getTime();
        File file = new File(RESULT_PATH);
        while (true) {
            if (new Date().getTime() - beginTime > timeout) {
                // 超时退出
                logger.warn("[HP COLL] Timeout, exit.");
                break;
            }

            File[] filelist = file.listFiles();
            if (filelist == null || filelist.length == 0) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    logger.error("[HP COLL] InterruptedException", e);
                }
                continue;
            }

            File resultFile = null;
            // 根据文件名找到采集文件
            for (int i = 0; i < filelist.length; i++) {
                if (filelist[i].getName().startsWith(resultFileName)) {
                    resultFile = filelist[i];
                    break;
                }
            }

            if (resultFile != null) {
                BufferedReader br = null;
                try {
                    br = new BufferedReader(new FileReader(resultFile));
                    String line = "";
                    while ((line = br.readLine()) != null) {
                        result.add(line);
                        sb.append(line + "\n");
                    }
                    break;
                } catch (Exception e) {
                    logger.error("[HP COLL] Exception while readFile:" + resultFileName, e);
                } finally {
                    if (br != null) {
                        try {
                            br.close();
                        } catch (IOException e) {
                            logger.error("[HP COLL] IOException:", e);
                        }
                    }
                    logger.info("[HP COLL] Delete coll result file : " + resultFile.getName());
                    logger.info(RESULT_PATH + ":\n" + sb.toString());
                    resultFile.delete();
                }
            }
        }// end while

        return result;
    }

    /**
     * 解析每个命令的执行结果
     *
     * @throws
     * @since Ver 1.1
     */
    private List<List<String>> parseResult(List<String> result) {
        //计算结果有多少个分割线分割的集合
        int num =1;
        for (String line : result) {
            if (line.trim().equals(SPLIT_LINE) || line.trim().endsWith(SPLIT_LINE)){
                num++;
            }
        }

        List<List<String>> list = new ArrayList<List<String>>();
        for (int i = 0; i < num; i++) {
            list.add(new ArrayList<String>());
        }

        int i = 0;
        for (String line : result) {
            if (line.trim().equals(SPLIT_LINE)) {
                i++;
                continue;
            }else if(line.trim().endsWith(SPLIT_LINE)){
                line = line.replace(SPLIT_LINE,"");
                list.get(i).add(line);
                i++;
            }else{
                list.get(i).add(line);
            }
        }
        return list;
    }

    /**
     * 解析每个命令的执行结果
     *
     * @throws
     * @since Ver 1.1
     */
    private List<List<String>> parseResult(List<String> result, int num) {
        List<List<String>> list = new ArrayList<List<String>>();
        for (int i = 0; i < num; i++) {
            list.add(new ArrayList<String>());
        }

        int i = 0;
        for (String line : result) {
            if (line.trim().equals(SPLIT_LINE)) {
                i++;
                continue;
            }else if(line.trim().endsWith(SPLIT_LINE)){
                line = line.replace(SPLIT_LINE,"");
                list.get(i).add(line);
                i++;
            }else{
                list.get(i).add(line);
            }
        }
        return list;
    }

    /**
     * 挂载点占用空间变动验证并记录告警和空间大小kpi
     * @param collResult
     * @param mountUnitId
     * @param path
     * @param pro
     * @param ht
     * @param fileMount
     * @param mountSize
     */
    private void checkMountSize(CollBase collResult, String mountUnitId,
                               String path, Properties pro, Hashtable<String, String> ht,
                               String fileMount, String mountSize) {
        //mount点占用空间
        collResult.addKPI(mountUnitId+fileMount,"PM-20-21-029-03", mountSize);
        String oldsize="";
        boolean sizekey = pro.containsKey(mountUnitId+fileMount+"[PM-20-21-029-03]");
        if(sizekey){
            //获得上次采集数据
            oldsize=pro.getProperty(mountUnitId+fileMount+"[PM-20-21-029-03]");
            //对比上次采集结果创建文件变更kpi
            if(!mountSize.equals(oldsize)){
                collResult.addKPI(mountUnitId+fileMount, "FM-20-21-029-01", "true");
            }else{
                collResult.addKPI(mountUnitId+fileMount, "FM-20-21-029-01", "false");
            }

        }
        if(!sizekey){
            ht.put(mountUnitId+fileMount+"[PM-20-21-029-03]", mountSize);
        }else{
            PropertyUtils.updateValue(path, mountUnitId+fileMount+"[PM-20-21-029-03]", mountSize);
        }
    }

    public static void main(String[] args) {

//        System.out.println(BigDecimal.valueOf(912).divide(BigDecimal.valueOf(1024),2, RoundingMode.HALF_UP));
//        System.out.println(StringUtils.substringAfterLast("aababcc","b"));
//        System.out.println(StringUtils.substringAfter("aababcc","b"));
//        System.out.println(StringUtils.substringBefore("aababcc","b"));
//        System.out.println(StringUtils.substringBeforeLast("aababcc","b"));
        HashMap<String, String > params = new HashMap<String, String>();
        params.put("bin_home", "/yfbnms/agent/masteragent/cron_temp/");
        params.put("IP_ADDR", "172.21.0.117");
        params.put("KEYWORDS", "masteragent#WebLogic");
        CollHPWithCMDByCron coll = new CollHPWithCMDByCron();
        coll.getConfig(params);
        Vector<TblATO_KPIDETAIL> result = coll.getConfig(params);
        //Vector<TblATO_KPIDETAIL> result = coll.getCpu(params);
        for (int i = 0; i < result.size(); i++) {
            TblATO_KPIDETAIL record = (TblATO_KPIDETAIL) result.get(i);
            System.out.println(record.UNIT_ID + "\t" + record.KPI_ID + "\t" + record.KPI_VALUE);
        }
//        List<String> result = coll.getResult(RESULT_CONFIG);
//        List<List<String>> list = coll.parseResult(result, 12);
//        coll.getConfig(params);
    }

}