Skip to content

Commit

Permalink
Diagnostics tool
Browse files Browse the repository at this point in the history
  • Loading branch information
arunans23 committed Feb 28, 2024
1 parent db5ae72 commit 9c14f70
Show file tree
Hide file tree
Showing 7 changed files with 846 additions and 0 deletions.
25 changes: 25 additions & 0 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
</dependency>
<dependency>
<groupId>com.github.mwiede</groupId>
<artifactId>jsch</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.diagnostics</groupId>
<artifactId>runtime-diagnostics</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand All @@ -132,6 +148,15 @@
<overWrite>true</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.wso2.diagnostics</groupId>
<artifactId>runtime-diagnostics</artifactId>
<version>${diagnostics.tool.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>target</outputDirectory>
<destFileName>diagnostics-tool</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
Expand Down
34 changes: 34 additions & 0 deletions distribution/src/assembly/bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,25 @@
</excludes>
</fileSet>

<fileSet>
<directory>target/diagnostics-tool</directory>
<outputDirectory>wso2mi-${pom.version}/diagnostics-tool</outputDirectory>
<excludes>
<exclude>bin/diagnostics</exclude>
<exclude>lib/**</exclude>
</excludes>
</fileSet>

<fileSet>
<directory>src/scripts/</directory>
<outputDirectory>${pom.artifactId}-${pom.version}/diagnostics-tool/bin
</outputDirectory>
<includes>
<include>**/diagnostics.sh</include>
</includes>
<fileMode>755</fileMode>
</fileSet>

<fileSet>
<directory>src/conf</directory>
<outputDirectory>wso2mi-${pom.version}/bin</outputDirectory>
Expand Down Expand Up @@ -501,6 +520,17 @@
<outputDirectory>${pom.artifactId}-${pom.version}/wso2/lib</outputDirectory>
<fileMode>644</fileMode>
</file>

<!-- Diagnostic tool files -->
<!-- <file>-->
<!-- <source>-->
<!-- ../p2-profile/target/wso2carbon-core-${carbon.kernel.version}/lib/org.wso2.ciphertool-${cipher.tool.version}.jar-->
<!-- </source>-->
<!-- <outputDirectory>${pom.artifactId}-${pom.version}/wso2/lib</outputDirectory>-->
<!-- <fileMode>644</fileMode>-->
<!-- </file>-->


<file>
<source>src/conf/synapse-handlers.xml</source>
<outputDirectory>wso2mi-${pom.version}/conf</outputDirectory>
Expand Down Expand Up @@ -644,6 +674,10 @@
<include>org.apache.logging.log4j:log4j-jcl:jar</include>
<include>org.slf4j:slf4j-simple:jar</include>
<include>com.lmax:disruptor:jar</include>
<include>org.apache.commons:commons-math3:jar</include>
<include>commons-net:commons-net</include>
<include>com.github.mwiede:jsch</include>
<include>org.wso2.diagnostics:runtime-diagnostics:jar</include>
<!--
javax jms-api need to be in class path for axis2
( needs javax.jms.JMSException )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Server Configurations
[server_configuration]
deployment_toml_path = "../conf/deployment.toml"
logs_directory = "../repository/logs"
updates_config_path = "../updates/config.json"
diagnostic_log_file_path = "logs/diagnostics.log"
carbon_log_file_path = "../repository/logs/wso2error.log"
process_id_path = "../wso2carbon.pid"
server_name = "WSO2 Micro Integrator"
server_version = "4.3.0"


## Action Executor Configurations

# Example
#[[action_executor_configuration]]
#executor = "ActionExecutor"

[[action_executor_configuration]]
executor = "MemoryDumper"

[[action_executor_configuration]]
executor = "ThreadDumper"
count = "5"
delay = "2000"

[[action_executor_configuration]]
executor = "OpenFileFinder"

[[action_executor_configuration]]
executor = "Netstat"

[[action_executor_configuration]]
executor = "ServerInfo"

[[action_executor_configuration]]
executor = "MetricsSnapshot"

# Watcher Configurations
[cpu_watcher]
enabled = "true"
threshold = "20"
retry_count = "2"
interval = "5"
action_executors = "ThreadDumper,MetricsSnapshot,ServerInfo"

[memory_watcher]
enabled = "true"
threshold = "30"
retry_count = "2"
interval = "5"
action_executors = "ThreadDumper,MetricsSnapshot,ServerInfo"


[log_watcher]
enabled = "true"

# Traffic Analyzer Configurations
[traffic_analyzer]
last_second_requests_enabled = "false"
last_second_requests_windows_size = "300"
last_second_requests_delay = "60"
last_second_requests_interval = "1"
last_fifteen_seconds_requests_enabled = "true"
last_fifteen_seconds_requests_window_size = "100"
last_fifteen_seconds_requests_delay = "4"
last_fifteen_seconds_requests_interval = "15"
last_minutes_requests_enabled = "true"
last_minutes_requests_window_size = "100"
last_minutes_requests_delay = "1"
last_minutes_requests_interval = "60"
notify_interval = "60"

# Output data zip configurations

[zip_file_configuration]
output_directory = "data"
max_count = "50"

## FTP Uploader configurations
#[ftp_uploader]
#enabled = "true"
#host = "ftp.example.com"
#port = "21"
#username = "username"
#password = "password"
#directory = "diagnostics"

## SFTP Uploader configurations
#[sftp_uploader]
#enabled = "true"
#host = "sftp.example.com"
#port = "22"
#username = "username"
#password = "password"
#directory = "diagnostics"
#known_hosts_path = "/home/user/.ssh/known_hosts"
#strict_host_key_checking = "yes" # or "no"

# Error regex patterns and diagnosis

# Example
#[[log_pattern]]
#regex = "(.*)Timeout(.*)"
#executors = "MetricsSnapshot,Netstat,OpenFileFinder,ServerInfo"
#reload_time = "30"

[[log_pattern]]
regex = "(.*)org.apache.synapse.transport.passthru(.*)"
executors = "MetricsSnapshot,Netstat,OpenFileFinder,ThreadDumper,ServerInfo"
reload_time = "30"

[[log_pattern]]
regex = "(.*)org.apache.synapse(.*)"
executors = "ServerInfo"
reload_time = "10"
134 changes: 134 additions & 0 deletions distribution/src/scripts/diagnostics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/sh
# diagnostics.sh
# ----------------------------------------------------------------------------
# Copyright 2024 WSO2, LLC. http://www.wso2.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ]; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
fi
done

PRGDIR=`dirname "$PRG"`
BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd`

# Reset the REPO variable. If you need to influence this use the environment setup file.
REPO=


# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
case "`uname`" in
CYGWIN*) cygwin=true ;;
Darwin*) darwin=true
if [ -z "$JAVA_VERSION" ] ; then
JAVA_VERSION="CurrentJDK"
else
echo "Using Java version: $JAVA_VERSION"
fi
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
JAVA_HOME=`/usr/libexec/java_home`
else
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
fi
fi
;;
esac

if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi

# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi

# If a specific java binary isn't specified search for the standard 'java' binary
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD=`which java`
fi
fi

if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." 1>&2
echo " We cannot execute $JAVACMD" 1>&2
exit 1
fi

if [ -z "$REPO" ]
then
REPO="$BASEDIR"/../wso2/lib
fi

CLASSPATH="$BASEDIR"/conf:"$REPO"/*

ENDORSED_DIR=
if [ -n "$ENDORSED_DIR" ] ; then
CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH
fi

if [ -n "$CLASSPATH_PREFIX" ] ; then
CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH
fi

if [ -z "$JVM_MEM_OPTS" ]; then
java_version=$("$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}')
JVM_MEM_OPTS="-Xms32m -Xmx128m"
if [ "$java_version" \< "1.8" ]; then
JVM_MEM_OPTS="$JVM_MEM_OPTS"
fi
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
[ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
[ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
fi

exec "$JAVACMD" $JAVA_OPTS \
$JVM_MEM_OPTS \
-classpath "$CLASSPATH" \
-Dapp.name="runtime-diagnostics" \
-Dapp.pid="$$" \
-Dapp.repo="$REPO" \
-Dapp.home="$BASEDIR" \
-Dbasedir="$BASEDIR" \
org.wso2.diagnostics.DiagnosticsApp \
"$@"
11 changes: 11 additions & 0 deletions distribution/src/scripts/micro-integrator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,17 @@ if [ $java_version_formatted -ge 1100 ]; then
JAVA_VER_BASED_OPTS="--add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED"
fi

# start diagnostic tool in background in diagnostic-tool/bin/diagnostic
"$CARBON_HOME"/diagnostics-tool/bin/diagnostics.sh &
diagnostic_tool_pid=$!

# trap signals so we can shutdown the diagnostic tool
cleanup() {
kill "$diagnostic_tool_pid"
}

trap 'cleanup' EXIT

while [ "$status" = "$START_EXIT_STATUS" ]
do
$JAVACMD \
Expand Down
Loading

0 comments on commit 9c14f70

Please sign in to comment.