Skip to content

Commit

Permalink
initial move
Browse files Browse the repository at this point in the history
  • Loading branch information
nemonster committed Jan 11, 2016
2 parents 6c1fdfe + 9008d83 commit 4637321
Show file tree
Hide file tree
Showing 35 changed files with 2,563 additions and 21 deletions.
36 changes: 15 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
## Support Diagnostics Utility
The support diagnostic utility is a Java executable that will interrogate the node on the the host it is running on to obtain data and statistics on the running cluster. There are a number of changes from the previous script based version:

* No runtime requirements or dependencies other than a recent JRE
* OS specific versions are not required.
* The application can be run from any directory on the machine. It does not require installation to a specific location, and the only requirement is that the user has read access to the Elasticsearch artifacts, write access to the chosen output directory, an## Support Diagnostics Utility
The support diagnostic utility is a Java executable that will interrogate the node on the the host it is running on to obtain data and statistics on the running cluster. There are a number of changes from the previous script based version:

* No runtime requirements or dependencies other than a recent JRE
* OS specific versions are not required.
* The application can be run from any directory on the machine. It does not require installation to a specific location, and the only requirement is that the user has read access to the Elasticsearch artifacts, write access to the chosen output directory, and sufficient disk space for the generated archive.
Expand All @@ -14,31 +9,31 @@ The support diagnostic utility is a Java executable that will interrogate the no

## Run Requirements
* JRE - Oracle or OpenJDK, 1.7 or 1.8
* `JAVA_HOME` environment variable should point to the Java installation directory. If `JAVA_HOME` is not found, the utility will attempt to locate a distribution but if errors occur it may be necessary to set this manually.
* JAVA_HOME environment variable should point to the Java installation directory. If JAVA_HOME is not found, the utility will attempt to locate a distribution but if errors occur it may be necessary to set this manually.
* Account running the utility must have read access to the Elasticsearch files and write access to the output location.
* Linux, Windows, and Mac OSX are supported.
>>>>>>> distribution

## Installation And Usage Instructions
* Unzip the `support-diagnostics-<version>-dist.zip` into the directory from which you intend to run the application.
* Unzip the support-diagnostics-<version>-dist.zip into the directory from which you intend to run the application.
* Switch to the diagnostics distribution directory.
* Run the application via the `diagnostics.sh` or `diagnostics.bat` script. The host name or IP address used by the HTTP connector of the node is required.
* If you omit the `--host` parameter you will be presented with a list of network interfaces to choose from. You'll also be required to enter a port, even if you are running on the default. If the selections do not specify a listening interface the utility will fail and you will need to run it again.
* Executing the application with `--?` or `--help` will display the help command output.
* Run the application via the diagnostics.sh or diagnostics.bat script. The host name or IP address used by the HTTP connector of the node is required.
* If you omit the --host parameter you will be presented with a list of network interfaces to choose from. You'll also be required to enter a port, even if you are running on the default. If the selections do not specify a listening interface the utility will fail and you will need to run it again.
* Executing the application with --? or --help will display the help command output.
* Supplied arguments are not required to be in any particular order.

## Simple Examples
* `./diagnostics.sh --host 192.168.137.1`
* `./diagnostics.sh --host 192.168.137.1 --port 9201`
* ./diagnostics.sh --host 192.168.137.1
* ./diagnostics.sh --host 192.168.137.1 -port 9201

## Using Shield Authentication
* `./diagnostics.sh --host 192.168.137.1 -u <your username> -p`
* `./diagnostics.sh --host 192.168.137.1 --user <your username> -p`
* `./diagnostics.sh --host 192.168.137.1 --user <your username> --password`
* Do **not** specify a password on the command line, only the flag. You will be prompted for the password and it will be hidden.
* ./diagnostics.sh --host 192.168.137.1 -u <your username> -p
* ./diagnostics.sh --host 192.168.137.1 --user <your username> -p
* ./diagnostics.sh --host 192.168.137.1 --user <your username> --password

* Do not specify a password on the command line, only the flag. You will be prompted for the password and it will be hidden.

## Using Shield Authentication And SSL
* `./diagnostics.sh --host 192.168.137.1 -u <your username> -p -s`
## Using Shield Authentication And SSL
* ./diagnostics.sh --host 192.168.137.1 -u <your username> -p -s

### Help command content
``````
Expand All @@ -54,7 +49,7 @@ The support diagnostic utility is a Java executable that will interrogate the no
--port, --listen
HTTP or HTTPS listening port.
Default: 9200
-o, --out, --output, --outputDir
-o, --out, --output, --outputDir
Fully qualified path to output directory or c for current working
directory.
Default: current working directory
Expand All @@ -68,4 +63,3 @@ The support diagnostic utility is a Java executable that will interrogate the no
-i --interval
Elapsed time in seconds between diangostic runs when in repeating mode. Minimum value is 30.
Binary file added dist/support-diagnostics-1.7-dist.zip
Binary file not shown.
179 changes: 179 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.elasticsearch</groupId>
<artifactId>support-diagnostics</artifactId>
<version>2.0.1</version>
<packaging>jar</packaging>
<name>Support Diagnostics Utilities</name>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.3</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.1.6.RELEASE</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.7</version>
</dependency>

<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.35</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.15</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.10</version>
</dependency>


</dependencies>

<build>
<!--<finalName>support-diagnostics</finalName>-->
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.*</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<verbose>true</verbose>
<fork>true</fork>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>
true
</addDefaultImplementationEntries>
<addClasspath>false</addClasspath>
</manifest>
<manifestEntries>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-installed</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<!-- Configures the used assembly descriptor -->
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
19 changes: 19 additions & 0 deletions scripts/diagnostics.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off
setlocal

set JAVA_EXEC=java
if not defined JAVA_HOME (
set JAVA_EXEC=java
echo No Java Home was found. Using current path. If execution fails please install Java and make sure it is in the search path or exposed via the JAVA_HOME environment variable.
) else (
echo JAVA_HOME found, using %JAVA_HOME%
set JAVA_EXEC=%JAVA_HOME%\bin\java
)

if not defined DIAG_JAVA_OPTIONS (
set DIAG_JAVA_OPTIONS=-Xmx512m
)

"%JAVA_EXEC%" %DIAG JAVA_OPTIONS% -cp .\;.\lib\* com.elastic.support.diagnostics.DiagnosticApp %*

endlocal
21 changes: 21 additions & 0 deletions scripts/diagnostics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=`which java`
fi

echo "Using ${JAVA} as Java Runtime"

if [ ! -x "$JAVA" ]; then
echo "Could not find any executable java binary. Please install java in your PATH and/or set JAVA_HOME"
exit 1
fi

[[ ${DIAG_DEBUG} != "" ]] && export DIAG_DEBUG_OPTS=" -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=y"

[[ ${DIAG_JAVA_OPTS} == "" ]] && export DIAG_JAVA_OPTS="-Xms256m -Xmx2000m"

echo "Using ${DIAG_JAVA_OPTS} ${DIAG_DEBUG_OPTS} for options."
"$JAVA" $DIAG_JAVA_OPTS ${DIAG_DEBUG_OPTS} -cp .:./lib/* com.elastic.support.diagnostics.DiagnosticApp "$@"
51 changes: 51 additions & 0 deletions src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<assembly>
<id>dist</id>
<!-- Specifies that our binary distribution is a zip package -->
<formats>
<format>zip</format>
</formats>

<fileSets>

<fileSet>
<directory>${project.basedir}/scripts</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>*</include>
</includes>
</fileSet>

<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>readme.md</include>
</includes>
</fileSet>

<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>*</include>
</includes>
</fileSet>

<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>./lib</outputDirectory>
<includes>
<include>support-diagnostics-*.jar</include>
</includes>
</fileSet>

<fileSet>
<directory>${project.build.directory}/lib</directory>
<outputDirectory>./lib</outputDirectory>
<includes>
<include>*</include>
</includes>
</fileSet>

</fileSets>
</assembly>
37 changes: 37 additions & 0 deletions src/main/java/com/elastic/support/SystemProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.elastic.support;


import java.text.SimpleDateFormat;
import java.util.Date;

public class SystemProperties {


public static final String osName = System.getProperty("os.name");

public static final String pathSeparator = System.getProperty("path.separator");

public static final String fileSeparator = System.getProperty("file.separator");

public static final String lineSeparator = System.getProperty("line.separator");

public static final String userDir = System.getProperty("user.dir");

public static final String userHome = System.getProperty("user.home");

private static final String UTC_DATE_FORMAT = "MM/dd/yyyy KK:mm:ss a Z";

private static final String FILE_DATE_FORMAT = "yyyyMMdd-KKmmssa";

public static String getUtcDateString(){
Date curDate = new Date();
SimpleDateFormat format = new SimpleDateFormat(UTC_DATE_FORMAT);
return format.format(curDate);
}

public static String getFileDateString(){
Date curDate = new Date();
SimpleDateFormat format = new SimpleDateFormat(FILE_DATE_FORMAT);
return format.format(curDate);
}
}
Loading

0 comments on commit 4637321

Please sign in to comment.