KYLIN-1614 Add linux transparent hugepage and vm swappiness into diagnosis tool 
for performance tunning


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/ccf7f0c6
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/ccf7f0c6
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/ccf7f0c6

Branch: refs/heads/yang-m1
Commit: ccf7f0c62230fd88de0123b8263a2094e05f467a
Parents: c3d8c07
Author: lidongsjtu <lid...@apache.org>
Authored: Fri Apr 22 17:01:44 2016 +0800
Committer: lidongsjtu <lid...@apache.org>
Committed: Fri Apr 22 17:07:38 2016 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/tool/DiagnosisInfoCLI.java | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/ccf7f0c6/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java
----------------------------------------------------------------------
diff --git a/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java 
b/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java
index b467ee8..a8eda53 100644
--- a/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java
+++ b/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java
@@ -37,6 +37,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Lists;
+import com.google.common.io.Files;
 
 public class DiagnosisInfoCLI extends AbstractApplication {
     private static final Logger logger = 
LoggerFactory.getLogger(DiagnosisInfoCLI.class);
@@ -61,6 +62,9 @@ public class DiagnosisInfoCLI extends AbstractApplication {
     @SuppressWarnings("static-access")
     private static final Option OPTION_INCLUDE_HBASE = 
OptionBuilder.withArgName("includeHBase").hasArg().isRequired(false).withDescription("Specify
 whether to include hbase files to extract. Default 
true.").create("includeHBase");
 
+    @SuppressWarnings("static-access")
+    private static final Option OPTION_INCLUDE_LINUX = 
OptionBuilder.withArgName("includeLinux").hasArg().isRequired(false).withDescription("Specify
 whether to include os and linux kernel info to extract. Default 
true.").create("includeLinux");
+
     private CubeMetaExtractor cubeMetaExtractor;
     private HBaseUsageExtractor hBaseUsageExtractor;
     private Options options;
@@ -115,6 +119,7 @@ public class DiagnosisInfoCLI extends AbstractApplication {
         boolean compress = optionsHelper.hasOption(OPTION_COMPRESS) ? 
Boolean.valueOf(optionsHelper.getOptionValue(OPTION_COMPRESS)) : false;
         boolean includeConf = optionsHelper.hasOption(OPTION_INCLUDE_CONF) ? 
Boolean.valueOf(optionsHelper.getOptionValue(OPTION_INCLUDE_CONF)) : true;
         boolean includeHBase = optionsHelper.hasOption(OPTION_INCLUDE_HBASE) ? 
Boolean.valueOf(optionsHelper.getOptionValue(OPTION_INCLUDE_HBASE)) : true;
+        boolean includeLinux = optionsHelper.hasOption(OPTION_INCLUDE_LINUX) ? 
Boolean.valueOf(optionsHelper.getOptionValue(OPTION_INCLUDE_LINUX)) : true;
 
         // export HBase
         if (includeHBase) {
@@ -160,6 +165,29 @@ public class DiagnosisInfoCLI extends AbstractApplication {
             }
         }
 
+        // export os conf - linux
+        if (includeLinux) {
+            File linuxDir = new File(exportDir, "linux");
+            FileUtils.forceMkdir(linuxDir);
+            File transparentHugepageCompactionDir = new File(linuxDir, 
"transparent_hugepage");
+            FileUtils.forceMkdir(transparentHugepageCompactionDir);
+            File vmSwappinessDir = new File(linuxDir, "vm.swappiness");
+            FileUtils.forceMkdir(vmSwappinessDir);
+            try {
+                String transparentHugepageCompactionPath = 
"/sys/kernel/mm/transparent_hugepage/defrag";
+                Files.copy(new File(transparentHugepageCompactionPath), new 
File(transparentHugepageCompactionDir, "defrag"));
+            } catch (Exception e) {
+                logger.warn("Error in export transparent hugepage compaction 
status.", e);
+            }
+
+            try {
+                String vmSwapinessPath = "/proc/sys/vm/swappiness";
+                Files.copy(new File(vmSwapinessPath), new 
File(vmSwappinessDir, "swappiness"));
+            } catch (Exception e) {
+                logger.warn("Error in export vm swapiness.", e);
+            }
+        }
+
         // export commit id
         try {
             FileUtils.copyFileToDirectory(new File(KylinConfig.getKylinHome(), 
"commit_SHA1"), exportDir);

Reply via email to