From cefd1b5bf662665cdb902623c94c313cb05ee7da Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Mon, 22 Jul 2013 17:40:26 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3pom.xml=E4=B8=ADorg.json?= =?UTF-8?q?=E7=9A=84=E7=89=88=E6=9C=AC=E5=92=8Chttpclient=E7=9A=84group?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9546591..79b8363 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ build210 3.1 1.7 - 2.2 + 20090211 2.1 @@ -143,7 +143,7 @@ - apache-httpclient + commons-httpclient commons-httpclient ${httpclient.version} @@ -236,7 +236,7 @@ - apache-httpclient + commons-httpclient commons-httpclient From 2d2324df0232f0e2ee5d46aba8d2217c2b44b508 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Mon, 22 Jul 2013 18:03:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=9C=A8=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=B3=BB=E7=BB=9F=E4=B8=AD=E8=8E=B7=E5=8F=96=E5=86=85?= =?UTF-8?q?=E5=AD=98=E4=BD=BF=E7=94=A8=E7=8E=87=E6=97=B6=EF=BC=8C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=AD=A3=E7=A1=AE=E8=A7=A3=E6=9E=90=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/toolkit/java/util/io/SSHUtil.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/common/toolkit/java/util/io/SSHUtil.java b/src/main/java/common/toolkit/java/util/io/SSHUtil.java index 76dae3b..f470d5f 100644 --- a/src/main/java/common/toolkit/java/util/io/SSHUtil.java +++ b/src/main/java/common/toolkit/java/util/io/SSHUtil.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; +import java.util.List; import java.util.Map; import ch.ethz.ssh2.Connection; @@ -135,16 +136,21 @@ private static HostPerformanceEntity getHostPerformance( Connection conn ) throw // 第四行通常是这样: // Mem: 1572988k total, 1490452k used, 82536k free, 138300k // buffers - String[] memArray = line.replace( MEM_USAGE_STRING, EMPTY_STRING ).split( COMMA ); - totalMem = StringUtil.trimToEmpty( memArray[0].replace( "total", EMPTY_STRING ) ).replace( "k", EMPTY_STRING ); - freeMem = StringUtil.trimToEmpty( memArray[2].replace( "free", EMPTY_STRING ) ).replace( "k", EMPTY_STRING ); - buffersMem = StringUtil.trimToEmpty( memArray[3].replace( "buffers", EMPTY_STRING ) ).replace( "k", EMPTY_STRING ); + + // updated by hengyunabc + // 有可能是这样的: + // KiB Mem: 8085056 total, 7557820 used, 527236 free, 385016 buffers + // 所以这里的字符串处理不对,直接改为匹配数字即可。 + List list = StringUtil.findAllByRegex(line, "\\d+"); + totalMem = list.get(0); + freeMem = list.get(1); + buffersMem = list.get(2); } else if ( 5 == lineNum ) { // 第四行通常是这样: // Swap: 2096472k total, 252k used, 2096220k free, 788540k // cached - String[] memArray = line.replace( SWAP_USAGE_STRING, EMPTY_STRING ).split( COMMA ); - cachedMem = StringUtil.trimToEmpty( memArray[3].replace( "cached", EMPTY_STRING ) ).replace( "k", EMPTY_STRING ); + List list = StringUtil.findAllByRegex(line, "\\d+"); + cachedMem = list.get(3); if ( StringUtil.isBlank( totalMem, freeMem, buffersMem, cachedMem ) ) throw new Exception( "Error when get system performance of ip: " + conn.getHostname() From bdc35f96ff1cb04ea57bb2144e1bc1d8c8a82d60 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Wed, 31 Jul 2013 18:51:11 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8A=8A=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=94=B9=E4=B8=BA0.0.4-SNAPSHOT=EF=BC=8C?= =?UTF-8?q?=E9=80=82=E9=85=8Dtaokeeper=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 79b8363..0774620 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ common.toolkit common-toolkit common-toolkit - 0.0.4 + 0.0.4-SNAPSHOT jar