Saturday 28 May 2016

Generating Thread dump and Heap dumps in JBoss through shell script

You can generate Thread Dump  & Heap dump manually in Jboss using the following shell scripts. 

 Download the following script and store it in a location such as /usr/local/bin.
 Provide the file permissions and ownership for this script as you see fit. In this example, they are:

Generating Thread dump

#==============================================================
#
#               Script Name :   thread_dump.sh
#               Developed by:   Bharathkumar
#
#==============================================================
#!/bin/bash

JBOSS_HOME="/u02/local/opt/jboss-eap-6.2/mydomain/slave02"
JAVA_BIN="/usr/java/default/bin"
echo -e "\nPlease enter the \"EAP name\" !!!"
                read EAP
  LOG_DIR="$JBOSS_HOME/servers/$EAP/log"
  #Get the EAP process ID
  EAP_PID=`ps -ef | grep $EAP | grep -v grep | awk '{print $2}'`
 #generating four thread dump files with 30 seconds interval
for i in 1 2 3 4; do
    $JAVA_BIN/jstack -l $EAP_PID  >> $LOG_DIR/threaddump.log
#Move the dump and keep it with creation dates to recognize the time when the dump taken
    mv $LOG_DIR/threaddump.log  $LOG_DIR/threaddump.`date +%m%d%Y_%H%M`.log
   sleep 30
 done
echo -e "************************************************"
echo -e "please check thread dump files under " $LOG_DIR
echo -e "************************************************"
echo -e "\nThank you!!! Bye!!!\n"
    exit 0
Let see how this script will work

while script executing time this script will ask EAP name. once you enter EAP name.. it will be generate 4 dump files with 30 seconds interval.

[jbossas@middleware shellscripts]$ ./thread_dump.sh

Please enter the "EAP name" !!!
rpa1-AS2
************************************************
please check thread dump files under  /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log
************************************************

Thank you!!! Bye!!!

[jbossas@middleware shellscripts]$ ls -ltr /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/thread*
-rw-rw-r-- 1 jbossas jbossas 59061 May 28 00:05 /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/threaddump.05282016_0005.log
-rw-rw-r-- 1 jbossas jbossas 59049 May 28 00:13 /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/threaddump.05282016_0013.log
-rw-rw-r-- 1 jbossas jbossas 58066 May 28 00:14 /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/threaddump.05282016_0014.log
-rw-rw-r-- 1 jbossas jbossas 59049 May 28 00:15 /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/threaddump.05282016_0015.log
[jbossas@middleware shellscripts]$ 

Generating Heap dump


#==============================================================
#
#               Script Name :  heap_dump.sh
#               Developed by:   Bharathkumar
#
#==============================================================
#!/bin/bash

JBOSS_HOME="/u02/local/opt/jboss-eap-6.2/mydomain/slave02"
JAVA_BIN="/usr/java/default/bin"
echo -e "\nPlease enter the \"EAP name\" !!!"
                read EAP
  LOG_DIR="$JBOSS_HOME/servers/$EAP/log"
  #Script output log directory
  SCRIPT_LOG="$LOG_DIR/heap_dumps.log"
  #Get the EAP process ID
  EAP_PID=`ps -ef | grep $EAP | grep -v grep | awk '{print $2}'`

#generating three heap dump files with 30 seconds interval
for i in 1 2 3 ; do
                echo "`date +%x" "%X` Starting Heap Dump $DUMP_COUNT" >>$SCRIPT_LOG
                $JAVA_BIN/jmap -dump:format=b,file=$LOG_DIR/heapdump.hprof $EAP_PID >>$SCRIPT_LOG
#Move the heap dump and keep it with creation dates to recognize the time when the dump taken
                mv $LOG_DIR/heapdump.hprof  $LOG_DIR/heap_$EAP.`date +%m%d%Y_%H%M`.hprof
                echo "`date +%x" "%X` Completed Heap Dump $DUMP_COUNT" >>$SCRIPT_LOG
                sleep 30
 done
echo -e "************************************************"
echo -e "please check heap dump files under " $LOG_DIR
echo -e "************************************************"
echo -e "\nThank you!!! Bye!!!\n"
    exit 0
Let see how this script will work

while script executing time this script will ask EAP name. once you enter EAP name.. it will be generate 3 dump files with 30 seconds interval.

[jbossas@middleware shellscripts]$ ./heap_dump.sh 

Please enter the "EAP name" !!!
rpa1-AS2
************************************************
please check heap dump files under  /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log
************************************************

Thank you!!! Bye!!!

[jbossas@middleware shellscripts]$ ls -ltr /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/heap*
-rw------- 1 jbossas jbossas 123447340 May 28 00:26 /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/heap_rpa1-AS2.05282016_0026.hprof
-rw------- 1 jbossas jbossas 123723872 May 28 00:27 /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/heap_rpa1-AS2.05282016_0027.hprof
-rw------- 1 jbossas jbossas 124270421 May 28 00:28 /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/heap_rpa1-AS2.05282016_0028.hprof
-rw-rw-r-- 1 jbossas jbossas       848 May 28 00:28 /u02/local/opt/jboss-eap-6.2/mydomain/slave02/servers/rpa1-AS2/log/heap_dumps.log


I hope this information is helpful to you......

 Please register to this blog ...to get alerts when I post new articles or if you have need help in Middleware tasks 

Wednesday 18 May 2016

How to create a datasource from the JBoss CLI in JBoss EAP 6

The following post is showing create a datasource from the JBoss CLI in JBoss EAP 6.

High level Steps create a datasource:

1. Deploy the database driver
2. Create the Datasource
3. Test the datasource connection

=================================================================
        Detailed Steps  
=================================================================

1. Deploy the database driver

[domain@192.168.1.12:9999 /] deploy /u01/app/oracle/product/11.1.0/db_1/jdbc/lib/ojdbc6.jar --all-server-groups

2. Create the Datasource from CLI

[domain@192.168.1.12:9999 /] /profile=rpa1/subsystem=datasources/data-source=rpa-ds1/:add(jndi-name=java:/jboss/jdbc/rpa1-ds,driver-name=ojdbc6.jar,connection-url=jdbc:oracle:thin:@//middleware.tech.com:1521/orcl,driver-class=oracle.jdbc.OracleDriver,prepared-statements-cache-size=10,password=tiger,max-pool-size=20,track-statements=NOWARN,flush-strategy=FailingConnectionOnly,user-name=scott,idle-timeout-minutes=3,query-timeout=2,min-pool-size=1)
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"rpa-group2" => {"host" => {"slave01" => {"rpa1-AS1" => {"response" => {
        "outcome" => "success",
        "result" => undefined,
        "response-headers" => {"process-state" => "restart-required"}
    }}}}}}

}

3. Enable the Datasource

[domain@192.168.1.12:9999 /] /profile=rpa1/subsystem=datasources/data-source=rpa-ds1/:enable
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"rpa-group2" => {"host" => {"slave01" => {"rpa1-AS1" => {"response" => {
        "outcome" => "success",
        "result" => undefined,
        "response-headers" => {"process-state" => "restart-required"}
    }}}}}}

}

 I can see the datasource element in domain xml:

<datasource jndi-name="java:/jboss/jdbc/rpa1-ds" pool-name="rpa-ds1" enabled="true">
              <connection-url>jdbc:oracle:thin:@//middleware.tech.com:1521/orcl</connection-url>
                        <driver-class>oracle.jdbc.OracleDriver</driver-class>
                        <driver>ojdbc6.jar</driver>
                        <pool>
                            <min-pool-size>1</min-pool-size>
                            <max-pool-size>20</max-pool-size>
                            <flush-strategy>FailingConnectionOnly</flush-strategy>
                        </pool>
                        <security>
                            <user-name>scott</user-name>
                            <password>tiger</password>
                        </security>
                        <timeout>
                            <idle-timeout-minutes>3</idle-timeout-minutes>
                            <query-timeout>2</query-timeout>
                        </timeout>
                        <statement>
                            <track-statements>NOWARN</track-statements>
                           <prepared-statement-cache-size>10</prepared-statement-cache-size>
                        </statement>
               </datasource>



4. Test the datasource connection

[domain@192.168.1.12:9999 /] /host=slave01/server=rpa1-AS1/subsystem=datasources/data-source=rpa-ds1:test-connection-in-pool
{
    "outcome" => "success",
    "result" => [true]
}

====================================================================


Remove a datasource from the JBoss CLI  

1. Disable the datasource 

[domain@192.168.1.12:9999 /] /profile=rpa1/subsystem=datasources/data-source=rpa1-ds/:disable
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"rpa-group2" => {"host" => {"slave01" => {"rpa1-AS1" => {"response" => {
        "outcome" => "success",
        "result" => undefined,
        "response-headers" => {
            "operation-requires-restart" => true,
            "process-state" => "restart-required"
        }
    }}}}}}
}


 2. Remove the datasouce 

[domain@192.168.1.12:9999 /] /profile=rpa1/subsystem=datasources/data-source=rpa1-ds/:remove
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"rpa-group2" => {"host" => {"slave01" => {"rpa1-AS1" => {"response" => {
        "outcome" => "success",
        "result" => undefined,
        "response-headers" => {"process-state" => "restart-required"}
    }}}}}}
}




I hope this information is helpful to you......

 Please register to this blog ...to get alerts when I post new articles or if you have need help in Middleware tasks 

Tuesday 10 May 2016

Garbage collection in WebSphere Application Server


Garbage collection (GC) is an integral part of the Java Virtual Machine (JVM) as it collects unused Java heap memory so that the application can continue allocating new objects. The IBM JVM provided with IBM WebSphere Application Server provides four different GC policy algorithms:

-Xgcpolicy:optthruput
-Xgcpolicy:optavgpause
-Xgcpolicy:gencon
-Xgcpolicy:balanced

Default policy in WAS V8 was changed from -Xgcpolicy: optthruput to -Xgcpolicy: gencon .

optthruput:

The JVM allows object allocation continuously till it reaches the threshold value ie(<4% free java heap available). Once it reaches the threshold GC kicks on to clear the dead objects. If the Xmx is huge then there are possibilities of more pausetime but till it reaches the threshold value, application works fine.  

This collector uses a parallel mark-sweep algorithm.
This means that the collector first walks through the set of reachable objects, marking them as live data. A second pass then sweeps away the unmarked objects, leaving behind free memory than can be used for new allocations. The majority of this work can be done in parallel, so the collector uses additional threads (up to the number of CPUs by default) to get the job done faster, reducing the time the application remains paused.

optavgpause: The Concurrent Collector

The optavgpause policy (-Xgcpolicy:optavgpause) attempts to do as much GC work as possible before stopping the application, leading to shorter pauses. The same mark-sweep-compact collector is used, but much of the mark and sweep phases can be done as the application runs. Based on the program's allocation rate, the system attempts to predict when the next garbage collection will be required. When this threshold approaches, a concurrent GC begins.

As application threads allocate objects, they will occasionally be asked to do a small amount of GC work before their allocation is fulfilled. The more allocations a thread does, the more it will be asked to help out.

Meanwhile, one or more background GC threads will use idle cycles to get additional work done. Once all the concurrent work is done, or if free memory is exhausted ahead of schedule, the application is halted and the collection is completed.

This pause is generally short, unless a compaction is required. Because compaction requires moving and updating live objects, it cannot be done concurrently.

Gencon: This policy is meant for less pause time.

Java heap divided into Nursery and tenture. Initial allocations done on nursery area. Once it fill nursery area Scavenge GC occurs(Partial GC on Nursery area). This moves the long lived objects to tenure area and keeps the short lived at nursery. Once nursery and tenure space filled system GC kicks on to clear dead objects.

If the nursery space is not set properly then scavenge gc occurs often which halts the performance of the system. Excess GC always lead to performance impact of the system.

Results:
Reduced major collection frequency (Full GC)
Reduced Full GC elapsed time & pause time
Increase JVM throughput
Increase performance & capacity of your application

Balanced garbage collection policy, a new GC technology available in WebSphere Application Server V8, available through the command line option, -Xgcpolicy:balanced. The balanced collector aims to even out pause times and reduce the overhead of some of the costlier operations typically associated with garbage collection

This policy is available only on 64-bit platforms.

The policy is optimized for larger heaps; if you have a heap size of less than 4 GB you are unlikely to see a benefit compared to using the Gencon policy.
https://www.ibm.com/support/knowledgecenter/SSYKE2_7.0.0/com.ibm.java.zos.70.doc/diag/understanding/mm_gc_balanced_when.html

Friday 6 May 2016

How to enable GC logs in JBoss?


To enable GC logs, the below JVM properties will have to be given to the JVM:

-verbose:gc –Xloggc:logFileName

 Additionally if the detailed log of the GC is required, then an additional below properties will have to be passed.

 –XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading

For a domain server GC logging is not enabled for the Process Controller, Host Controller or the Servers. You will need to enable these yourself through JVM properties on the Domain Controller for the level you want (i.e. Server level, Server Group level, Host level, Domain level)

Enable GC logging at Server level through CLI  

Adding -verbose:gc parameter to specific server instance:

[domain@192.168.1.12:9999 /] /host=slave01/server-config=rpa1/jvm=jvm-rpa:add-jvm-option(jvm-option="-verbose:gc")
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"undefined" => {"host" => {"slave01" => {"rpa1" => {"response" => {
        "outcome" => "success",
        "response-headers" => {
            "operation-requires-restart" => true,
            "process-state" => "restart-required"
        }
    }}}}}}
}


Adding -Xloggc:logFileName parameter to specific server instance:

[domain@192.168.1.12:9999 /] /host=slave01/server-config=rpa1/jvm=jvm-rpa:add-jvm-option(jvm-option="-Xloggc:/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/log/gc.log")
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"undefined" => {"host" => {"slave01" => {"rpa1" => {"response" => {
        "outcome" => "success",
        "response-headers" => {
            "operation-requires-restart" => true,
            "process-state" => "restart-required"
        }    }}}}}}}

Adding XX:+PrintGCDetails parameter to specific server instance:

[domain@192.168.1.12:9999 /] /host=slave01/server-config=rpa1/jvm=jvm-rpa:add-jvm-option(jvm-option="-XX:+PrintGCDetails")                                              {         
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"undefined" => {"host" => {"slave01" => {"rpa1" => {"response" => {
        "outcome" => "success",
        "response-headers" => {
            "operation-requires-restart" => true,
            "process-state" => "restart-required"
        }
    }}}}}}
}



If you want to add multiple JVM arguments to server instance at a time,
The CLI command would be:

/host=slave02/server-config=rpa2/jvm=jvm-rpa:write-attribute(name=jvm-options,value=["-verbose:gc","-Xloggc:/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/log/gc.log","-XX:+PrintGCDateStamps","-XX:+UseGCLogFileRotation","-XX:NumberOfGCLogFiles=5","-XX:GCLogFileSize=3M","-XX:-TraceClassUnloading","-XX:HeapDumpPath=/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/log","-XX:+HeapDumpOnOutOfMemoryError","-XX:+PrintGCDetails"])
Notice: We will have to bounce the application server for the properties to take effect.

Check JVM Settings in host.xml file

<servers>
        <server name="rpa2" group="rpa-group" auto-start="true">
            <jvm name="jvm-rpa">
                <heap size="64m" max-size="220m"/>
                <jvm-options>
                    <option value="-verbose:gc"/>
                    <option value="-Xloggc:/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/log/gc.log"/>
                    <option value="-XX:+PrintGCDateStamps"/>
                    <option value="-XX:+UseGCLogFileRotation"/>
                    <option value="-XX:NumberOfGCLogFiles=5"/>
                    <option value="-XX:GCLogFileSize=3M"/>
                    <option value="-XX:-TraceClassUnloading"/>
                    <option value="-XX:HeapDumpPath=/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/log"/>
                    <option value="-XX:+HeapDumpOnOutOfMemoryError"/>
                    <option value="-XX:+PrintGCDetails"/>
                </jvm-options>
            </jvm>
            <socket-bindings port-offset="150"/>
        </server>

Check application server process, either these changes were effected or not. 


[jboss@middlewaretech log]$ ps -ef | grep -i rpa2

jboss    13888 13178  0 19:54 pts/1    00:00:20 /usr/java/jdk1.7.0_75/jre/bin/java -D[Server:rpa2] -Xms64m -Xmx220m -verbose:gc -Xloggc:/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/log/gc.log -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -XX:HeapDumpPath=/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/log -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -D[Host Controller]=true -Djboss.domain.master.address=192.168.1.12 -Djava.awt.headless=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.home.dir=/u03/local/opt/jboss-eap-6.2 -Djava.net.preferIPv4Stack=true -Djboss.domain.base.dir=/u03/local/opt/jboss-eap-6.2/mydomain/slave2/ -Djboss.server.log.dir=/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/log -Djboss.server.temp.dir=/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/tmp -Djboss.server.data.dir=/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/data -Dlogging.configuration=file:/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/data/logging.properties -jar /u03/local/opt/jboss-eap-6.2/jboss-modules.jar -mp /u03/local/opt/jboss-eap-6.2/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.server

The GC logs generating under  /u03/local/opt/jboss-eap-.2/mydomain/slave2/servers/rpa2/log/

The GC logs rotating as below. 




I hope this information is helpful to you......

 Please register to this blog ...to get alerts when I post new articles or if you have need help in Middleware tasks 

How to obtain heap dump and Thread dump in JBoss?


When your application server is hung for whatever reason, which may involve recycling your application server, you must act swiftly to collect as much diagnostics information as possible before you do that. Obtaining Java Heap dump and Thread dump are extremely valuable in such cases. Here is how you obtain these dumps for a JBoss Application server.

1. Thread dump

Thread dump shows the snapshot of all threads and their stack traces. This means you clearly see what the Application Server was working on when you took the thread dump.

Note: Always take at least 4 thread dumps at 30 seconds interval. This is to identify if a particular thread is at the same work in all thread dumps, which will mean that thread is hung up for some reason – maybe it is waiting for a backend resource to respond.

You can use the ‘jstack‘ command that comes with the JDK to obtain Java thread dump.

a. Log on to Application server

b. Identify the process id of your application server(Execute a ps command to find the process id (ps –ef |grep server_name))

Syntax: /usr/java/default/bin/jstack -l pid >> dump.log

[jboss@middlewaretech ~]$ /usr/java/default/bin/jstack -l 5365 >> /home/jboss/Desktop/threaddump.log

[jboss@middlewaretech ~]$ ls -ltr /home/jboss/Desktop/threaddump.log
-rw-r--r-- 1 jboss dba 57108 May  6 15:58 /home/jboss/Desktop/threaddump.log


The process id in the above command is 5365. The thread dump gets stored in /home/jboss/Desktop/threaddump.log

2.  Heap dump:

Java heap dump has the snapshot of the Java heap at the time of the dump. It is extremely valuable in troubleshooting ‘OutOfMemory’ errors. For example, if the biggest object in the Heap generally points to the leak suspect. When you provide the object name to the Application Developer, you give him a good starting point on analyzing the issue from his perspective.

You can use the ‘jmap’ command that comes with the JDK  to obtain the heap dump.

a. Log on to Application server

b. Identify the process id of your application server(Execute a ps command to find the process id (ps –ef |grep server_name))

Sytax: /usr/java/default/bin/jmap -dump:format=b,file=/path/to/the/dump.hprof pid


[jboss@middlewaretech ~]$ /usr/java/default/bin/jmap -dump:format=b,file=/home/jboss/Desktop/heapdump.hprof 5365

Dumping heap to /home/jboss/Desktop/heapdump.hprof ...
Heap dump file created


Here 
Format=b  à  b menace binary format
file= <path>/<name of heapdump file>  à Enter the obsolete path of file and name wherever you want to generate the file.

And finally  EAP process id and enter.
Then heap dump file will be generated in the specified path.


you can easily create a heap dump automatically when JBoss is going OutOfMemory. Just add the following Java arguments in your EAP JVM settings

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heap.dump


Click below links for configuration of  OutOfMemory (OOM) parameters in JBOSS 6


I hope this information is helpful to you......

 Please register to this blog ...to get alerts when I post new articles or if you have need help in Middleware tasks 

Thursday 5 May 2016

Generating Thread dump & Heap dump using WSAdmin script

You can generate Thread Dump  & Heap dump manually using the following WSAdmin Script
Copy the Below Code and create a file heap_thread_dump.py  and place the file in home Directory  :

#================================================================
#
#               Script Name :  heap_thread_dump.py
#               Developed by:   Bharathkumar
#
#================================================================

import sys,java
from java.util import Properties
from java.io import FileInputStream
from org.python.modules import time
lineSep = java.lang.System.getProperty('line.separator')

def linedesign(): print '@'*50
def menu():
        linedesign()
        print """heap & thread dumps options
        1. generate heap dump
        2. generate Thread dump
        3. Exit
        """
        linedesign()
        ch=input("Please enter your choice: ")
        return ch

def main():
        """ Main program logic starts here """
        while 1:
                ch=menu()
                if ch == 1:
                        linedesign();  
                        print "You selected to generate heap dump"
                                                appServer=raw_input("Enter application server name: ")
                                                JVMName = AdminControl.completeObjectName('type=JVM,process='+ appServer +',*')
                                                dumpFile = AdminControl.invoke(JVMName, 'generateHeapDump')
                                                print 'Heap dump file: ' + dumpFile
                        linedesign()
                elif ch == 2:
                        print "You selected to generate Thread dump"
                        appServer1=raw_input("Enter application server name: ")
                                                JVMName = AdminControl.completeObjectName('type=JVM,process='+ appServer1 +',*')
                                                dumpFile1 = AdminControl.invoke(JVMName, 'dumpThreads')
                                                print 'thread dump file: ' + dumpFile1
                        linedesign()
                else:
                        print "Exiting from the script...."
                        #sys.exit(0)
                        break

main()

Copy the Below Code and create a file heap_thread_dump.sh  and place the file in home Directory  :

#================================================================
#
#               Script Name :  heap_thread_dump.sh
#               Developed by:   Bharathkumar
#
#================================================================
#!/bin/sh
WAS_HOME="/u02/local/opt/was/was70/profiles/node/bin"
$WAS_HOME/wsadmin.sh -lang jython -conntype SOAP -f /home/mqm/Desktop/wsadmin/heap_thread_dump.py

exit 0

Let see how this script will work



Look for an output file, in the installation root directory for the product, with a name like javacore.date.time.pid.number.txt. or heapdump.date.time.pid.number.phd

Friday 29 April 2016

deploy and undeploy an application in JBoss EAP 6 through shell script

I have written a shell script to deploy and undeploy an application in JBoss EAP 6.

 Download the following script and store it in your linux machine.
 Provide the file permissions and ownership for this script as you see fit. In this example, they are:

[root@middlewaretech script]# chmod 755  install_uninstall_APP.sh
[root@middlewaretech script]# ls -ltr install_uninstall_APP.sh
-rwxr-xr-x 1 jboss dba 1172 Apr 29 22:36 install_uninstall_APP.sh

#!/bin/bash
JBOSS_HOME=/u03/local/opt/jboss-eap-6.2
DC=192.168.1.12
DC_port=9999

#---------------------
#application deployment.....
#---------------------
deploy()
{
echo -e  "\nPlease enter the \"EAR\" or \"WAR\" with obsolete path !!!"
read EAR
echo -e  "\nPlease enter the \"server_group\" !!!"
read server_group

$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$DC:$DC_port --command="deploy "$EAR" --server-groups="$server_group 2>&1
echo -e "\n "$EAR " has deployed suucessupply on "$server_group
}
#
---------------------
#application undeployment.....
#---------------------
undeploy()
{
echo -e  "\nPlease enter the \"EAR\" or \"WAR\"  !!!"
read EAR
echo -e  "\nPlease enter the \"server_group\" !!!"
read server_group
$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$DC:$DC_port --command="undeploy "$EAR" --server-groups="$server_group 2>&1

echo -e "\n "$EAR "has undeployed suucessupply from "$server_group
}

echo -e "please enter one of the option from deploy/undeploy"
read operation
if [[ $operation == "deploy" ]];
then
deploy
elif [[ $operation  == "undeploy" ]];
then
undeploy
else
echo -e "\n\n Thank You!!! Bye!!!\n\n"
exit 0;
fi;


Let see how this script will work

while script executing time this script will ask deploy/undeploy, WAR/EAR and server-group details

Application deployment
 

Application Undeployment

I
I hope this information is helpful to you