Friday, November 26, 2010

Wsadmin updated

Example: Identifying running objects

In the WebSphere Application Server, MBeans represent running objects. You can interrogate the MBean server to see the objects it contains. Use the AdminControl object to interact with running MBeans.

* Use the queryNames command to see running MBean objects. For example:

$AdminControl queryNames *

This command returns a list of all MBean types. Depending on the server to which your scripting client attaches, this list can contain MBeans that run on different servers:

* If the client attaches to a stand-alone WebSphere Application Server, the list contains MBeans that run on that server.
* If the client attaches to a node agent, the list contains MBeans that run in the node agent and MBeans that run on all application servers on that node.
* If the client attaches to a deployment manager, the list contains MBeans that run in the deployment manager, all of the node agents communicating with that deployment manager, and all application servers on the nodes served by those node agents.

· The list that the queryNames command returns is a string representation of JMX ObjectName objects. For example:

WebSphere:cell=MyCell,name=TraceService,mbeanIdentifier=TraceService,
type=TraceService,node=MyNode,process=server1

This example represents a TraceServer object that runs in server1 on MyNode.

* The single queryNames argument represents the ObjectName object for which you are searching. The asterisk ("*") in the example means return all objects, but it is possible to be more specific. As shown in the example, ObjectName has two parts: a domain, and a list of key properties. For MBeans created by the WebSphere Application Server, the domain is WebSphere. If you do not specify a domain when you invoke queryNames, the scripting client assumes the domain is WebSphere. This means that the first example query above is equivalent to:

$AdminControl queryNames WebSphere:*

* WebSphere Application Server includes the following key properties for the ObjectName object:
* name
* type
* cell
* node
* process mbeanIdentifier

These key properties are common. There are other key properties that exist. You can use any of these key properties to narrow the scope of the queryNames command. For example:

$AdminControl queryNames WebSphere:type=Server,node=myNode,*

This example returns a list of all MBeans that represent server objects running the node myNode. The, * at the end of the ObjectName object is a JMX wildcard designation. For example, if you enter the following:

$AdminControl queryNames WebSphere:type=Server,node=myNode

you get an empty list back because the argument to queryNames is not a wildcard. There is no Server MBean running that has exactly these key properties and no others.

* If you want to see all the MBeans representing applications running on a particular node, invoke the following example:

$AdminControl queryNames WebSphere:type=Application,node=myNode,*

Example: Turning traces on and off in a server process with the wsadmin tool

The following example turns on tracing in a server process:

* Identify the object name for the TraceService MBean running in the process:

$AdminControl completeObjectName type=Server,name=server1,*

* Obtain the name of the object and set it to a variable:

set ts [$AdminControl completeObjectName type=TraceService,process=server1,*]

* Turn on traces for the server:

$AdminControl setAttribute $ts traceSpecification com.ibm.*=all=enabled

Example: Dumping threads in a server process

Use the AdminControl object to dump the Java threads of a running server.

* For example, in Jacl:

set jvm [$AdminControl completeObjectName type=JVM,process=server1,*]

$AdminControl invoke $jvm dumpThreads

This example produces a Java core file. You can use this file for problem determination.

Example: Starting a server using wsadmin

The following example starts an application server with the node specified.

* The following command starts server1 in mynode node:

$AdminControl startServer server1 mynode

Example output:

WASX7319I: The serverStartupSyncEnabled attribute is set to false. A startwill be attempted for server "server1" but the configuration information fornode "mynode" may not be current.WASX7262I: Start completed for server "server1" on node "mynode"

* The startServer command has several command syntax options. If you have Network Deployment installation, you have to use one of following:

$AdminControl startServer serverName nodeName

$AdminControl startServer serverName nodeName waitTime

* If you have an application server base installation, you can use the following syntax in addition to the previous syntax:

$AdminControl startServer serverName
$AdminControl startServer serverName waitTime


Example: Stopping a server using wsadmin

The following example stops an application server with the node specified.

* The following command stops server1 in node mynode.

$AdminControl stopServer server1 mynode

Example output:
WASX7337I: Invoked stop for server "server1" Waiting for stop completion.
WASX7264I: Stop completed for server "server1" on node "mynode"

* The stop command has serveral command syntaxes.

If you have Network Deployment installation, use the one of following command syntax:

$AdminControl stopServer serverName nodeName

$AdminControl stopServer serverName nodeName immediate
If you have application server base installation, you can use the following syntax, in addition to the previous syntax:

$AdminControl stopServer serverName

$AdminControl stopServer serverName immediate

Example: Querying the server state using the wsadmin tool

The following example queries the server state.

* Identify the server and assign it to the server variable.

set server [$AdminControl completeObjectName cell=mycell,node=mynode,name=server1,type=Server,*]

This command returns the server MBean that matches the partial object name string.


Example output:
WebSphere:cell=mycell,name=server1,mbeanIdentifier=server.xml#Server_1,
type=Server,node=mynode,process=server1,processType=ManagedProcess

* Query for the state attribute.

$AdminControl getAttribute $server state

The getAttribute command returns the value of a single attribute.

Example output:
STARTED

Example: Starting a listener port using wsadmin

The following example starts a listener port on an application server.

* Identify the listener port MBeans for the application server and assign it to the lPorts variable.

set lPorts [$AdminControl queryNames type=ListenerPort,cell=mycell,node=mynode,process=server1,*]


This command returns a list of listener port MBeans.

Example output: WebSphere:cell=mycell,name=ListenerPort,mbeanIdentifier=server.xml#ListenerPort_1,

type=ListenerPort,node=mynode,process=server1

WebSphere:cell=mycell,name=listenerPort,mbeanIdentifier=ListenerPort,type=server.xml#ListenerPort_2,

node=mynode,process=server1

* Start the listener port if it is not started with the following example:·

foreach lPort $lPorts

{ set state [$AdminControl getAttribute $lport started]

if {$state == "false"} {

$AdminControl invoke $lPort start

}

}
This piece of Jacl code loops through the listener port MBeans. For each listener port MBean, get the attribute value for the started attribute. If the attribute value is set to false, then start the listener port by invoking the start operation on the MBean.

Example: Testing data source connection using wsadmin

The following example tests a dataSource, to ensure a connection to the database.

* Identify the DataSourceCfgHelper MBean and assign it to the dshelper variable.

set dshelper [$AdminControl queryNames type=DataSourceCfgHelper,process=server1*]

Example output:

WebSphere:cell=mycell,name=DataSourceCfgHelper,mbeanIdentifier=DataSourceCfgHelper,

type=DataSourceCfgHelper,node=mynode,process=server1

* Test the connection.

$AdminControl invoke $dshelper testConnectionToDataSource "COM.ibm.db2.jdbc.DB2XADataSource dbuser1 dbpwd1 {{databaseName jtest1}} c:/sqllib/java12/db \"\" \"\""

This example command invokes the testConnectionToDataSource operation on the MBean, passing in the classname, userid, password, database name, JDBC driver class path, language, and country.

Example output:

DSRA8025I: Successfully connected to DataSource

Example: Starting an application using wsadmin

The following example starts an application:

* Identify the application manager MBean for the server where the application resides and assign it the appManager variable.

set appManager [$AdminControl queryNames cell=mycell,node=mynode,type=ApplicationManager,process=server1,*]

This command returns the application manager MBean.


Example output:

WebSphere:cell=mycell,name=ApplicationManager,mbeanIdentifier=ApplicationManager,

type=ApplicationManager,node=mynode,process=server1

* Start the application.

$AdminControl invoke $appManager startApplication myApplication

This command invokes the startApplication operation on the MBean, passing in the application name to start.

Example: Stopping running applications on a server using wsadmin

The following example stops all running applications on a server:

* Identify the application manager MBean for the server where the application resides, and assign it to the appManager variable.

set appManager [$AdminControl queryNames cell=mycell,node=mynode,type=ApplicationManager,process=server1,*]

This command returns the application manager MBean.

Example output: WebSphere:cell=mycell,name=ApplicationManager,mbeanIdentifier=ApplicationManager,

type=ApplicationManager,node=mynode,process=server1

* Query the running applications belonging to this server and assign the result to the apps variable.

set apps [$AdminControl queryNames cell=mycell,node=mynode,type=Application,process=server1,*]

This command returns a list of application MBeans.
Example output:

WebSphere:cell=mycell,name=adminconsole,mbeanIdentifier=deployment.xml#ApplicationDeployment_1,

type=Application,node=mynode,Server=server1,process=server1,J2EEName=adminconsole

WebSphere:cell=mycell,name=filetransfer,mbeanIdentifier=deployment.xml#ApplicationDeployment_1,

type=Application,node=mynode,Server=server1,process=server1,J2EEName=filetransfer

* Stop all the running applications.

foreach app $apps

{

set appName [$AdminControl getAttribute $app name]

$AdminControl invoke $appManager stopApplication $appName

}
This command stops all the running applications by invoking the stopApplication operation on the MBean, passing in the application name to stop.

Example: Querying application state using wsadmin

The following examples queries for the presence of Application MBean to find out whether the application is running.

$AdminControl completeObjectName type=Application,name=myApplication,*

If myApplication is running, then there should be an MBean created for it. Otherwise, the command returns nothing. If myApplication is running,
the following is the example output:

WebSphere:cell=mycell,name=myApplication,mbeanIdentifier=cells/mycell/applications/myApplication.ear/deployments/myApplication/deployment.xml#ApplicationDeployment_1,
type=Application,node=mynode,Server=dmgr,process=dmgr,J2EEName=myApplication

Example: Updating the Web server plug-in configuration files using wsadmin

This examples regenerates the web serer plugin configuration file.

* Identify the web server plugin configuraiton file generator MBean and assign it to the pluginGen variable.

EX:
set pluginGen [$AdminControl completeObjectName type=PluginCfgGenerator,*]

Example output:
WebSphere:cell=pongoNetwork,name=PluginCfgGenerator,
mbeanIdentifier=PluginCfgGenerator,type=PluginCfgGenerator,node=pongoManager,
process=dmgr

* Generate the updated plugin configuration file.

EX:

$AdminControl invoke $pluginGen generate "c:/WebSphere/DeploymentManager c:/WebSphere/DeploymentManager/config mycell null null plugin-cfg.xml"
This example command assumes a Windows system install. It invokes the generate operation on the MBean, passing in the install root directory, configuration root directory, cell name, node name, server name, and output file name. To pass in null as the value of an argument, enter null as given in the example. This is provided for operation that allows null as the value of its argument and processes null differently from an empty string. In this example, both node and server are set to null. The generate operation generates plugin configuration for all the nodes and servers resided in the cell. The output file plugin-cfg.xml is created in the config root directory.

You can modify this example command to generate plugin configuration for a particular node or server by specifying the node and server names.

Friday, November 19, 2010

AIX commands you should not leave home without

Commands
Kernel

How would I know if I am running a 32-bit kernel or 64-bit kernel?
To display if the kernel is 32-bit enabled or 64-bit enabled, type:
bootinfo -K

How do I know if I am running a uniprocessor kernel or a multiprocessor kernel?
/unix is a symbolic link to the booted kernel. To find out what kernel mode is running, enter ls -l /unix and see what file /unix it links to. The following are the three possible outputs from the ls -l /unix command and their corresponding kernels:
/unix -> /usr/lib/boot/unix_up # 32 bit uniprocessor kernel
/unix -> /usr/lib/boot/unix_mp # 32 bit multiprocessor kernel
/unix -> /usr/lib/boot/unix_64 # 64 bit multiprocessor kernel

Note:
AIX 5L Version 5.3 does not support a uniprocessor kernel.
How can I change from one kernel mode to another?
During the installation process, one of the kernels, appropriate for the AIX version and the hardware in operation, is enabled by default. Let us use the method from the previous question and assume the 32-bit kernel is enabled. Let us also assume that you want to boot it up in the 64-bit kernel mode. This can be done by executing the following commands in sequence:
ln -sf /usr/lib/boot/unix_64 /unix
ln -sf /usr/lib/boot/unix_64 /usr/lib/boot/unix

bosboot -ad /dev/hdiskxx
shutdown -r

The /dev/hdiskxx directory is where the boot logical volume /dev/hd5 is located. To find out what xx is in hdiskxx, run the following command:
lslv -m hd5


Note:
In AIX 5.2, the 32-bit kernel is installed by default. In AIX 5.3, the 64-bit kernel is installed on 64-bit hardware and the 32-bit kernel is installed on 32-bit hardware by default.
Hardware
How would I know if my machine is capable of running AIX 5L Version 5.3?
AIX 5L Version 5.3 runs on all currently supported CHRP (Common Hardware Reference Platform)-based POWER hardware.
How would I know if my machine is CHRP-based?
Run the prtconf command. If it's a CHRP machine, the string chrp appears on the Model Architecture line.
How would I know if my System p machine (hardware) is 32-bit or 64-bit?
To display if the hardware is 32-bit or 64-bit, type:
bootinfo -y

How much real memory does my machine have?
To display real memory in kilobytes (KB), type one of the following:
bootinfo -r

lsattr -El sys0 -a realmem

Can my machine run the 64-bit kernel?
64-bit hardware is required to run the 64-bit kernel.
What are the values of attributes for devices in my system?
To list the current values of the attributes for the tape device, rmt0, type:
lsattr -l rmt0 -E

To list the default values of the attributes for the tape device, rmt0, type:
lsattr -l rmt0 -D

To list the possible values of the login attribute for the TTY device, tty0, type:
lsattr -l tty0 -a login -R

To display system level attributes, type:
lsattr -E -l sys0

How many processors does my system have?
To display the number of processors on your system, type:
lscfg | grep proc

How many hard disks does my system have and which ones are in use?
To display the number of hard disks on your system, type:
lspv

How do I list information about a specific physical volume?
To find details about hdisk1, for example, run the following command:
lspv hdisk1


How do I get a detailed configuration of my system?
Type the following:
lscfg

The following options provide specific information:
-p Displays platform-specific device information. The flag is applicable to AIX 4.2.1 or later.
-v Displays the VPD (Vital Product Database) found in the customized VPD object class.
For example, to display details about the tape drive, rmt0, type:
lscfg -vl rmt0

You can obtain very similar information by running the prtconf command.
How do I find out the chip type, system name, node name, model number, and so forth?
The uname command provides details about your system.
uname -p Displays the chip type of the system. For example, PowerPC.
uname -r Displays the release number of the operating system.
uname -s Displays the system name. For example, AIX.
uname -n Displays the name of the node.
uname -a Displays the system name, nodename, version, machine ID.
uname -M Displays the system model name. For example, IBM, 9114-275.
uname -v Displays the operating system version.
uname -m Displays the machine ID number of the hardware running the system.
uname -u Displays the system ID number.
AIX
What version, release, and maintenance level of AIX is running on my system?
Type one of the following:
oslevel -r

lslpp -h bos.rte

How can I determine which fileset updates are missing from a particular AIX level?
To determine which fileset updates are missing from 5300-04, for example, run the following command:
oslevel -rl 5300-04

What SP (Service Pack) is installed on my system?
To see which SP is currently installed on the system, run the oslevel -s command. Sample output for an AIX 5L Version 5.3 system, with TL4, and SP2 installed would be:
oslevel –s
5300-04-02


Is a CSP (Concluding Service Pack) installed on my system?
To see if a CSP is currently installed on the system, run the oslevel -s command. Sample output for an AIX 5L Version 5.3 system, with TL3, and CSP installed would be:
oslevel –s
5300-03-CSP


How do I create a file system?
The following command will create, within volume group testvg, a jfs file system of 10MB with mounting point /fs1:
crfs -v jfs -g testvg -a size=10M -m /fs1


The following command will create, within volume group testvg, a jfs2 file system of 10MB with mounting point /fs2 and having read only permissions:
crfs -v jfs2 -g testvg -a size=10M -p ro -m /fs2


How do I change the size of a file system?
To increase the /usr file system size by 1000000 512-byte blocks, type:
chfs -a size=+1000000 /usr

Note:
In AIX 5.3, the size of a JFS2 file system can be shrunk as well.
How do I mount a CD?
Type the following:
mount -V cdrfs -o ro /dev/cd0 /cdrom

How do I mount a file system?
The following command will mount file system /dev/fslv02 on the /test directory:
mount /dev/fslv02 /test

How do I mount all default file systems (all standard file systems in the /etc/filesystems file marked by the mount=true attribute)?
The following command will mount all such file systems:
mount {-a|all}

How do I unmount a file system?

Type the following command to unmount /test file system:
umount /test

How do I display mounted file systems?
Type the following command to display information about all currently mounted file systems:
mount

How do I remove a file system?
Type the following command to remove the /test file system:
rmfs /test

How can I defragment a file system?
The defragfs command can be used to improve or report the status of contiguous space within a file system. For example, to defragment the file system /home, use the following command:
defragfs /home

Which fileset contains a particular binary?
To show bos.acct contains /usr/bin/vmstat, type:
lslpp -w /usr/bin/vmstat

Or to show bos.perf.tools contains /usr/bin/svmon, type:
which_fileset svmon

How do I display information about installed filesets on my system?
Type the following:
lslpp -l


How do I determine if all filesets of maintenance levels are installed on my system?
Type the following:
instfix -i | grep ML

How do I determine if a fix is installed on my system?
To determine if IY24043 is installed, type:
instfix -ik IY24043

How do I install an individual fix by APAR?

To install APAR IY73748 from /dev/cd0, for example, enter the command:
instfix -k IY73748 -d /dev/cd0


How do I verify if filesets have required prerequisites and are completely installed?

To show which filesets need to be installed or corrected, type:
lppchk -v

How do I get a dump of the header of the loader section and the symbol entries in symbolic representation?
Type the following:
dump -Htv

How do I determine the amount of paging space allocated and in use?
Type the following:
lsps -a

How do I increase a paging space?
You can use the chps -s command to dynamically increase the size of a paging space. For example, if you want to increase the size of hd6 with 3 logical partitions, you issue the following command:
chps -s 3 hd6


How do I reduce a paging space?
You can use the chps -d command to dynamically reduce the size of a paging space. For example, if you want to decrease the size of hd6 with four logical partitions, you issue the following command:
chps -d 4 hd6


How would I know if my system is capable of using Simultaneous Multi-threading (SMT)?
Your system is capable of SMT if it's a POWER5-based system running AIX 5L Version 5.3.
How would I know if SMT is enabled for my system?
If you run the smtctl command without any options, it tells you if it's enabled or not.
Is SMT supported for the 32-bit kernel?
Yes, SMT is supported for both 32-bit and 64-bit kernel.
How do I enable or disable SMT?
You can enable or disable SMT by running the smtctl command. The following is the syntax:
smtctl [ -m off | on [ -w boot | now]]

The following options are available:
-m off Sets SMT mode to disabled.
-m on Sets SMT mode to enabled.
-w boot Makes the SMT mode change effective on next and subsequent reboots if you run the bosboot command before the next system reboot.
-w now Makes the SMT mode change immediately but will not persist across reboot.
If neither the -w boot or the -w now options are specified, then the mode change is made immediately. It persists across subsequent reboots if you run the bosboot command before the next system reboot.
How do I get partition-specific information and statistics?
The lparstat command provides a report of partition information and utilization statistics. This command also provides a display of Hypervisor information.
Volume groups and logical volumes
How do I know if my volume group is normal, big, or scalable?
Run the lsvg command on the volume group and look at the value for MAX PVs. The value is 32 for normal, 128 for big, and 1024 for scalable volume group.
How to create a volume group?
Use the following command, where spartition_size sets the number of megabytes (MB) in each physical partition where the partition_size is expressed in units of MB from 1 through 1024. (It's 1 through 131072 for AIX 5.3.) The partition_size variable must be equal to a power of 2 (for example: 1, 2, 4, 8). The default value for standard and big volume groups is the lowest value to remain within the limitation of 1016 physical partitions per physical volume. The default value for scalable volume groups is the lowest value to accommodate 2040 physical partitions per physical volume.
mkvg -y name_of_volume_group -s partition_size list_of_hard_disks

How can I change the characteristics of a volume group?
You use the following command to change the characteristics of a volume group:
chvg

How do I create a logical volume?
Type the following:
mklv -y name_of_logical_volume name_of_volume_group number_of_partition

How do I increase the size of a logical volume?
To increase the size of the logical volume represented by the lv05 directory by three logical partitions, for example, type:
extendlv lv05 3


How do I display all logical volumes that are part of a volume group (for example, rootvg)?
You can display all logical volumes that are part of rootvg by typing the following command:
lsvg -l rootvg

How do I list information about logical volumes?
Run the following command to display information about the logical volume lv1:
lslv lv1

How do I remove a logical volume?
You can remove the logical volume lv7 by running the following command:
rmlv lv7

The rmlv command removes only the logical volume, but does not remove other entities, such as file systems or paging spaces that were using the logical volume.
How do I mirror a logical volume?
1. mklvcopy LogicalVolumeName Numberofcopies
2. syncvg VolumeGroupName
How do I remove a copy of a logical volume?
You can use the rmlvcopy command to remove copies of logical partitions of a logical volume. To reduce the number of copies of each logical partition belonging to logical volume testlv, enter:
rmlvcopy testlv 2

Each logical partition in the logical volume now has at most two physical partitions.
Queries about volume groups
To show volume groups in the system, type:
lsvg

To show all the characteristics of rootvg, type:
lsvg rootvg

To show disks used by rootvg, type:
lsvg -p rootvg

How to add a disk to a volume group?
Type the following:
extendvg VolumeGroupName hdisk0 hdisk1 ... hdiskn

How do I find out what the maximum supported logical track group (LTG) size of my hard disk?
You can use the lquerypv command with the -M flag. The output gives the LTG size in KB. For instance, the LTG size for hdisk0 in the following example is 256 KB.
/usr/sbin/lquerypv -M hdisk0
256

You can also run the lspv command on the hard disk and look at the value for MAX REQUEST.
What does syncvg command do?
The syncvg command is used to synchronize stale physical partitions. It accepts names of logical volumes, physical volumes, or volume groups as parameters.
For example, to synchronize the physical partitions located on physical volumes hdisk6 and hdisk7, use:
syncvg -p hdisk4 hdisk5


To synchronize all physical partitions from volume group testvg, use:
syncvg -v testvg


How do I replace a disk?
1. extendvg VolumeGroupName hdisk_new
2. migratepv hdisk_bad hdisk_new
3. reducevg -d VolumeGroupName hdisk_bad
How can I clone (make a copy of ) the rootvg?
You can run the alt_disk_copy command to copy the current rootvg to an alternate disk. The following example shows how to clone the rootvg to hdisk1.
alt_disk_copy -d hdisk1

Network
How can I display or set values for network parameters?
The no command sets or displays current or next boot values for network tuning parameters.
How do I get the IP address of my machine?
Type one of the following:
ifconfig -a

host Fully_Qualified_Host_Name

For example, type host cyclop.austin.ibm.com.
How do I identify the network interfaces on my server?
Either of the following two commands will display the network interfaces:
lsdev -Cc if

ifconfig -a

To get information about one specific network interface, for example, tr0, run the command:
ifconfig tr0

How do I activate a network interface?
To activate the network interface tr0, run the command:
ifconfig tr0 up

How do I deactivate a network interface?
For example, to deactivate the network interface tr0, run the command:
ifconfig tr0 down

WebSphere Password Decoder

This utility can decode WebSphere encoded passwords.
If you have lost your password(s), use this utility to recover them.

url: http://www.sysman.nl/wasdecoder/

Tuesday, September 21, 2010

wsadmin commands

Handy wsadmin commands:

I feel jacl is much easier than jython :) . Hence here are the jacl commands


To list the installed applications:
/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin -c '$AdminApp list'

To Uninstall the Application:
/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin -c '$AdminApp uninstall application-xyz'

To backup the existing application:

/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin -c '$AdminApp export utilities /tmp/utilities_backup.ear'


To Stop the application:

/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin

wsadmin>set appManager [$AdminControl queryNames type=ApplicationManager,*]
WebSphere:name=ApplicationManager,process=xyz,platform=dynamicproxy,node=xyz,version=6.1.0.0,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=xyz,spec=1.0

wsadmin>$AdminApp list
x1
x2
wsadmin>$AdminControl invoke $appManager stopApplication x1


To Start the application:

/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin

wsadmin>set appManager [$AdminControl queryNames type=ApplicationManager,*]
WebSphere:name=ApplicationManager,process=xyz,platform=dynamicproxy,node=xyz,version=6.1.0.0,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=xyz,spec=1.0

wsadmin>$AdminApp list
x1
x2
wsadmin>$AdminControl invoke $appManager startApplication x1


To Restart all the application:

Run this command to stop all of the running applications:

foreach app $apps {set appName [$AdminControl getAttribute $app name];
$AdminControl invoke $appManager stopApplication $appName}

Run this command to start all of the running applications:

foreach app $apps {set appName [$AdminControl getAttribute $app name];
$AdminControl invoke $appManager startApplication $appName}

Tuesday, September 14, 2010

JRockit - Understanding Threads and Locks

Understanding Threads and Locks

A running application is usually made up of one process with its own memory space. A computer is generally running several processes at the same time. For example, a word processor application process might be running alongside a media player application process. Furthermore, a process consists of many concurrently running threads. When you run a Java application, a new JVM process is started.

Each Java process has at least one application thread. Besides the threads of the running Java application, there are also Oracle JRockit JVM internal threads that take care of garbage collection or code generation.

This section contains basic information about threads and locks in the JRockit JVM. The following subjects are discussed:

* Understanding Threads
* Understanding Locks

For information about how to make so-called thread dumps, printouts of the stacks of all the threads in an application, see Using Thread Dumps. Thread dumps can be used to diagnose problems and optimize application and JVM performance.


Understanding Threads

A java application consists of one or more threads that run Java code. The entire JVM process consists of the Java threads and some JVM internal threads, for example one or more garbage collection threads, a code optimizer thread and one or more finalizer threads.

From the operating system’s point of view the Java threads are just like any application threads. Scheduling of the threads is handled by the operating system, as well as thread priorities.

Within Java, the Java threads are represented by thread objects. Each thread also has a stack, used for storing runtime data. The thread stack has a specific size. If a thread tries to store more items on the stack than the stack size allows, the thread will throw a stack overflow error.
Default Stack Size for Java Threads

This section lists the default stack sizes. You can change the thread stack size with the -Xss command line option, for example:

java -Xss:512k MyApplication

The default stack sizes differ depending upon whether you are using IA32 and X64, as shown

OS Default Stack Size
Windows IA32 64 kB
Windows IA64 320 KB
Windows x64 128 kB
Linux IA32 128 kB
Linux IA64 1024 KB
Linux x64 256 kB
Solaris/SPARC 512 KB

Default Stack Size for JVM Internal Threads

A special “system” stack size is used for JVM internal threads; for example, the garbage collection and code generation threads. The default system stack size is 256 KB on all platforms.
Note: The -Xss command line option sets the stack size of both application threads and JVM internal threads.


Understanding Locks

When threads in a process share and update the same data, their activities must be synchronized to avoid errors. In Java, this is done with the synchronized keyword, or with wait and notify. Synchronization is achieved by the use of locks, each of which is associated with an object by the JVM. For a thread to work on an object, it must have control over the lock associated with it, it must “hold” the lock. Only one thread can hold a lock at a time. If a thread tries to take a lock that is already held by another thread, then it must wait until the lock is released. When this happens, there is so called “contention” for the lock.

There are four different kinds of locks:

* Fat locks: A fat lock is a lock with a history of contention (several threads trying to take the lock simultaneously), or a lock that has been waited on (for notification).
* Thin locks: A thin lock is a lock that does not have any contention.
* Recursive locks: A recursive lock is a lock that has been taken by a thread several times without having been released.
* Lazy locks: A lazy lock is a lock that is not released when a critical section is exited. Once a lazy lock is acquired by a thread, other threads that try to acquire the lock have to ensure that the lock is, or can be, released. Lazy locks are used by default in Oracle JRockit JVM 27.6. In older releases, lazy locks are only used if you have started the JVM with the -XXlazyUnlocking option.

A thin lock can be inflated to a fat lock and a fat lock can be deflated to a thin lock. The JRockit JVM uses a complex set of heuristics to determine when to inflate a thin lock to a fat lock and when to deflate a fat lock to a thin lock.
Spinning and Sleeping

Spinning occurs when a thread that wants a specific lock continuously checks that lock to see if it is still taken, instead of yielding CPU-time to another thread.

Alternatively, a thread that tries to take a lock that is already held waits for notification from the lock and goes into a sleeping state. The thread will then wait passively for the lock to be released.
Lock Chains

Several threads can be tied up in what is called lock chains. Although they appear somewhat complex, lock chains are fairly straightforward. They can be defined as follows:

* Threads A and B form a lock chain if thread A holds a lock that thread B is trying to take. If A is not trying to take a lock, then the lock chain is “open.”
* If A->B is a lock chain, and B->C is a lock chain, then A->B->C is a more complete lock chain.
* If there is no additional thread waiting for a lock held by C, then A->B->C is a complete and open lock chain.

Lock Chain Types

The JRockit JVM analyzes the threads and forms complete lock chains. There are three possible kinds of lock chains: Open, Deadlocked and Blocked lock chains.
Open Chains

Open lock chains represent a straight dependency, thread A is waiting for B which is waiting for C, and so on. If you have long open lock chains, your application might be wasting time waiting for locks. You may then want to reconsider how locks are used for synchronization in your application.
Deadlock Chains

A deadlocked, or circular, lock chain consists of a chain of threads, in which the first thread in the chain is waiting for the last thread in the chain. In the simplest case, thread A is waiting for thread B, while thread B is waiting for thread A. Note that a deadlocked chain has no head. In thread dumps, the Oracle JRockit JVM selects an arbitrary thread to display as the first thread in the chain.

Deadlocks can never be resolved, and the application will be stuck waiting indefinitely.
Blocked Chains

A blocked lock chain is made up of a lock chain whose head thread is also part of another lock chain, which can be either open or deadlocked. For example, if thread A is waiting for thread B, thread B is waiting for thread A, and thread C is waiting for thread A, then thread A and B form a deadlocked lock chain, while thread C and thread A form a blocked lock chain.

Nice Doc from Oracle

Thursday, September 9, 2010

Plumb the IP Address (ifconfig)

'ifconfig -a' that will show you all your ports and there name, netmask and everything else you could need to knwo about the card/port.

output :
lo0: flags=1000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
hme0: flags=1000843 mtu 1500 index 2
inet 163.37.178.200 netmask ffffffe0 broadcast 163.37.178.223
ether 8:0:20:aa:45:f3

[ If executed as normal user, except the "ether" information
U will get the rest as stated above]

Interpretation from above output :
(a) lo0 & hme0 are the interface names
lo0 is for internal network, hme0 is for external network
(b) numbers given after "inet" are the IP Addresses
for the corresponding Interface
(c) address specified after "ether" is the MAC/Ethernet
address for the Interface Card (only for external cards)
(d) similarly netmask & broadcast addresses are specified




So run a 'ifocnfig -a' the first result will always be 'le0' or 'lo0' forget about that one. Never worry about that. Say you got a quad fast ether net card. You'll then have 4 more results after that. Say hme0 hme1 hme2 hme3, there's your 4 ports you can use (hmex is a example could be qfex or whatever).

Say you want to change hme2 from 192.168.0.1 with netmask of 255.255.0.0 to 192.165.0.1 with a netmask of 255.255.255.0 then you would type the follow command.

ifconfig hme2 plumb up 192.165.0.1 netmask 255.255.255.0

That will change the port. I perfer to unplumb the port first to make sure the above command will work.

Ok so a full set of commands I would type to make the above changes would be.

ifconfig hme2 unplumb (this will bring down port hme2 so it's not used any more)
ifconfig -a (just to make sure the port is no longer used)
ifconfig hme2 plumb up 192.165.0.1 netmask 255.255.255.0 (this will bring port hme2 up with the IP address of 192.165.0.1 and a netmask of 255.255.255.0)
ifconfig -a (just to confirm the changes)

Apache Installation on Linux ( Compile)

Download and Install Apache 2.2

Download apache from the Apache 2.2 http://httpd.apache.org/download.cgi#apache22

Look for the section with the phrase "best available version" like "Apache HTTP Server (httpd) 2.2.x is the best available version". At the time of writing this tutorial Apache 2.2.16 is the official best available version.

Click on the link for "httpd-2.2.16.tar.gz" and download the installer.



Once the file is copied on the Linux server (example: /usr/local/install).

1. Use the following command to extract the tar file.

cd /usr/local/install

tar -xzf httpd-2.2.16.tar.gz


A directory will be created "httpd-2.2.16"

2. Now, Let`s execute the configuration script:

cd /usr/local/install/httpd-2.2.16

./configure --prefix=/usr/local/install/apache --enable-mods-shared=all --enable-proxy --enable-expires --enable-vhost-alias

or

./configure --prefix=/usr/local/install/apache --enable-so --with-mpm=worker --enable-proxy=share --enable-ssl --enable-proxy --enable-rewrite --enable-headers --enable-deflate --enable-proxy-http --enable-proxy-balancer --enable-proxy-ajp --enable-expires --enable-usertrack


3. The following steps will compile Apache based upon the configuration defined:

make



4. The following step will install the Apache build:

make install



5. Use the following commands to control the Apache Web Server.

/usr/local/install/apache/bin/apachectl -k stop

/usr/local/install/apache/bin/apachectl -k start



6. Go to the internet browser and try the url http://host:80/.

You should see, It Works!

This means, the Apache webserver installation went successful.

Tuesday, September 7, 2010

Simple Script to check if file exists and invoke a operation

#Script to check the file and invoke other script
#Author- Satish Kumar
#ver 1.0
#!/bin/bash
HOME=/opt/apps/RAM
FILENAME=$HOME/DRDM_ETL.complete


if [ -e $FILENAME ]
then
cd $HOME
echo Invoking the script at `date '+%F_%H:%M'` >> DRDM_ETL.status
/opt/apps/scripts/invoke.sh
echo Removing the $FILENAME at date '+%F_%H:%M'` >> DRDM_ETL.status
rm $FILENAME
else
echo data file does not exist
fi

Thursday, August 26, 2010

Sticky Bit (-rwsr-xr-x Unix file permission)

Everybody handling a Unix operating system would very well know what chmod 777 means. That the owner, group and the user of the file is given all permissions (Read, Write and Execute on a particular file). This could otherwise be written as “chmod ugo+rwx “. Meaning that you are giving User, Group and Owner of the file, the rights to Read, Write and Execute the file.

Here comes the rws scenario. Best example that is available for this rws is /usr/bin/passwd command (just issue a “ls -l /usr/bin/passwd”) .

Normally, any user is allowed change HIS password. Meaning he can make an entry or change HIS entry in the /etc/passwd file. But he can never be given ‘WRITE’ permissions on the file because he might end up disturbing other person’s password too. Only a ROOT user is allowed permissions on the /etc/passwd file.

This is where the “rws” comes to picture. When we give “rws” permission to the /usr/bin/passwd command, Unix would assume that the command is executed by the ROOT user. (the user doesnt have permissions on the /etc/passwd file but the root user has). Root user (RWS) permissions could be given on a file as chmod 4700 .

arun@arun-desktop:~/Desktop$ chmod 4700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rws—— 1 arun arun 0 2007-01-17 06:48 hi.txt

If you need to act as a group user of a file and not a normal user when executing a particular command (as against the root user) then user “chmod 2700 ”

arun@arun-desktop:~/Desktop$ chmod 2700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rwx–S— 1 arun arun 0 2007-01-17 06:48 hi.txt

The 4 and 2 in the front of the chmod commands are called as SUID and SGID bits.

What if we put a 1 instead of 4 and 2 (chmod 1700 ).

arun@arun-desktop:~/Desktop$ chmod 1700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rwx—–T 1 arun arun 0 2007-01-17 06:48 hi.txt

It shows a “T” in the place of “x” for a normal user. This “T” bit is called as the Sticky bit.

“When the sticky bit is turned on for a directory users can have read and/or write permissions for that directory, but they can only remove or rename files that they own. The sticky bit on a file tells the operating system that the file will be executed frequently. Files like this are kept in swap space even when they aren’t being executed. Although this takes up swap space it greatly reduces the time it takes to execute the program. Some programs such as vi have the sticky bit turned on by default on some Unixes.”

Monday, August 9, 2010

OReilly Books

Looks like this site is offering OReilly Books in chm and pdf format online.


http://www.ibreakyoufix.com/tools/books/OReilly/

Friday, August 6, 2010

To verify if TRACE is enabled/disabled for Apache Webserver

After TRACE has been disabled according to the instructions mentioned in my thread, a TRACE request will be responded to with HTTP status code 403 (FORBIDDEN).

Using telnet to verify the configuration for a non-SSL web server port
The telnet command provided with most operating systems can be used to verify that the configuration changes to disable TRACE have been made. Note that telnet can only be used to test non-SSL ports, since it does not have the capability to perform the SSL handshake or to encrypt the data.

$ telnet 127.0.0.1 8080
Trying...
Connected to 127.0.0.1.
Escape character is '^]'.
TRACE / HTTP/1.0
A: b
C: d
Host: foo

HTTP/1.1 403 Forbidden
Date: Mon, 04 Oct 2004 14:23:31 GMT
Server: IBM_HTTP_SERVER
Connection: close
Content-Type: text/html; charset=iso-8859-1



403 Forbidden

Forbidden


You don't have permission to access /
on this server.



Connection closed.

The information sent by the client is no longer echoed, and the request fails with HTTP status code 403.

If the response to the TRACE request continues to result in a response with status code 200, verify that the required directives were added to all containers and the main scope of the configuration file, and also verify that the web server has been restarted to activate the updated configuration.

Installing Apache with SSL

This article outlines the steps followed while installing the Apache Web Server using the SSL technology. This was done much earlier but steps remain the same.


Installation of Apache and SSL (Requires OpenSSL > openssl-0.9.5a or better. www.openssl.com).

1. Download the latest Apache Webserver from: http://httpd.apache.org/dist/httpd/apache_1.3.19.tar.gz

2. tar zxvf apache_1.3.19.tar.gz
3. Download the latest apache+ssl source from: ftp://opensores.thebunker.net/pub/mirrors/apachessl/apache_1.3.9+ssl_1.42.tar.gz
4. mv apache_1.3.9+ssl_1.42.tar.gz apache_1.3.19
5. tar zxvf apache_1.3.9+ssl_1.42.tar.gz
6. Run the executable: ./FixPatch
7. ./configure --prefix=/usr/local/apache * ./configure -help to get other config time options as needed.
8. make
9. su -
10. make install
11. ln -s /usr/local/apache/conf/httpsd.conf /usr/local/apache/conf/httpd.conf
12. cd /usr/local/apache ; mkdir certs
13. cd certs
14. openssl genrsa -des3 -out ssl.key 1024 -days 365

Remember the PEM password you choose! This command will create ssl.key -days 365 means you will have to do steps 14 & 16 again in 365 days
15. At his point, you are going to create a self-signed Certificate for your site. If you will be using a CA ( Certifying Authority ) Certificate, please review http://www.linuxdoc.org/HOWTO/SSL-RedHat-HOWTO-3.html#ss3.2
16. What is very important to remember in creating the the ssl.crt file is deciding "what is the URL people enter to come to my web site? ". For example, if you own blah.com, and you define blah.com when creating the ssl.crt key, then people who access your site via www.blah.com will get a "Certificate Name Check" that might scare people away because it contains a ominous warning. People who access your site via http://blah.com will not get this warning. However you choose to name your server that is how you must define ServerName in the section below.
17. openssl req -new -key ssl.key -x509 -out ssl.crt Enter your PEM; this will create ssl.crt
This is the Information you will be presented with when issuing this command:

Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:South Carolina
Locality Name (eg, city) []:West Columbia
Organization Name (eg,company) [Internet Widgits Pty Ltd]:Michael Sharp
Organizational Unit Name (eg, section) []:Secure Web Server
Common Name (eg, your name or your server's hostname) []:reality.dynip.com
Email Address []:msharp@medmail.com

The Common Name portion is where you define what I was talking about in 15.
18. edit /usr/local/apache/conf/httpsd.conf and at the bottom, under add this:

SSLDisable
EXAMPLE:

SSLCacheServerPort logs/gcache_port
SSLCacheServerPath bin/gcache
SSLSessionCacheTimeout 10
SSLVerifyClient 0
SSLVerifyDepth 10
SSLCacheServerRunDir /tmp
SSLFakeBasicAuth
SSLRandomFile /dev/random 1024
DocumentRoot /usr/local/apache/htdocs ServerName www.CHANGE-THIS.com
ServerAdmin SOMEONE@SOMEWHERE.COM
ErrorLog /usr/local/apache/logs/httpsd_error.log TransferLog /usr/local/apache/logs/httpsd_access.log SSLEnable
SSLCertificateFile /usr/local/apache/certs/ssl.crt SSLCertificateKeyFile /usr/local/apache/certs/ssl.key


You must also comment out Document Root, ServerName, ServerAdmin, ErrorLog, and TransferLog in the Main Server configuration:

#DocumentRoot
#ServerName
#ErrorLog
#ServerAdmin
#TransferLog

Where you see:

# Port: The port to which the standalone server listens. For
# ports < 1023, you will need httpd to be run as root initially.
#
Port 8080

change 8080 to 443

Add any other configuration variables to the httpsd.conf file per your needs.
19. Start the Server:

/usr/local/apache/bin/httpsdctl start

You will have to issue your PEM to start the web server! Don't panic just because it doesn't start immediately give it a few moments.
20. Check out: https://YOUR-WEB-SITE to review if you were successful.
21. Now add your content to /usr/local/apache/htdocs

Virtual Hosts

Virtual hosts enable you to intelligently run multiple sites on a single server. The useful side effect is that with proper setup, you can point your browser to www.whatever.whatever and load a local copy. My development site is now www.mezzoblue.dev, which works exactly the same as the .com, just faster.


Find your httpd.conf file, and then add this line somewhere near the bottom (there’s a spot with example virtual server code)

NameVirtualHost 127.0.0.1

You might want to run a search for ‘NameVirtualHost’ within the file before-hand to make sure it’s not already set, or at least commented out with a preceding octothorpe (#).

Next add an entry for localhost pointing to the root of your web server, so that typing localhost in your browser’s address bar continues pulling up the default site:


ServerName localhost
DocumentRoot /Path/To/WebRoot


And finally, for each individual virtual site you wish to run, add a new entry pointing to the proper directory. This is especially useful because, at least on Unix-based systems, this means it can sit anywhere in your filesystem.


ServerName www.mezzoblue.dev
DocumentRoot /Volumes/Shine/www/delhi

Handy Unix and linux commands

####################################################################

Finding CPU Information:

Solaris: /usr/platform/sun4u/sbin/prtdiag | grep 'System Configuration' | sed 's/.*(\\(.*\\) .*)/\\1/'

Linux: cat /proc/cpuinfo | grep '^model name' | sed 's/.*: //'
####################################################################

CPU Speed:
Solaris: psrinfo -v | grep MHz | awk '{print $6 $7}'

Linux: cat /proc/cpuinfo | grep '^cpu MHz' | sed 's/.*: //'
####################################################################
total Disk Space:

Solaris: /usr/sbin/df -kF ufs | grep -v Filesystem | awk '{print $2,$6}'

Linux: /bin/df -kl -x tmpfs | grep -v Filesystem | awk '{print $2,$6}'
####################################################################
Total Physical Memory
Solaris: /usr/sbin/prtconf | grep Memory | sed 's/.*: //' | awk '{print $1*1024}'

Linux: cat /proc/meminfo | grep '^MemTotal' | sed 's/.*: //' | awk '{print $1}'
####################################################################

echo $?

result of last command... 0 success and 1 failure
####################################################################
Send mail as an attachment with subject as "Logs"
uuencode log log | mailx -s "Logs" username@domain.com
####################################################################
find command with different options

find . -name "*.log" -type f -print -exec -mtime +7 gzip {} \ ; finding files with *.log and checking if older than 7 days and gzipping them

find . -name "*.log" -mtime +7 -exec rm -rf {} \; finding *.log and checking if older than 7 days and removing them

find . -size +1000m -exec ls -ltr {} \;
####################################################################
Command to clear Semaphore and Shared memory

Clear Semaphore : ipcs|grep ^s|awk '{print "ipcrm -s " $2}'|sh
Clear Shared memory : ipcs|grep ^m|awk '{print "ipcrm -m " $2}'|sh
Check semaphore and shared memory: ipcs
####################################################################

screen -S backup -t backup

screen -d -r pid.backup
####################################################################

tar cf - dir/ | gzip -c > file.tar.gz
####################################################################
kill all the httpd process

ps -ef | grep httpd | sed -e '/grep/d' | awk '{print $2}'|xargs kill -9
####################################################################
Simple for loop to check the remote hostname and output of the command

for i in a b c; do ssh apache@server${i}col "echo \"Host: server${i}col\";ls -ltr /tmp";done
####################################################################
Command to check Processor 32 or 64 bit

Solaris: isainfo -b
Linux : uname -a
x86_64 and ia64 are 64 bit , if i386 is 32 bit
####################################################################

###################################################
AIX command to check machine name.
###################################################

/opt/local/bin/nmon -r -t
###################################################
AIX command to check CPU name.
###################################################

topas
vmstat --- for memory
###################################################
Command to check WLM on AIX
###################################################

smitty
wlmstat

Websphere - What you want to know about HTTP session persistence

. With Web 2.0 technologies taking off, more and more Web applications are being redesigned, and as they get changed, these same questions come up even more frequently. If you are involved in redesigning any Web applications for Web 2.0, here are answers to some of the questions you might soon be asking.

1. If I don’t need session persistence, can I turn it off?
Yes, you can configure session management to run with in-memory sessions, which is actually the default. You can still use HttpSessions in this mode, but if a failure occurs, the data stored in the HttpSessions will be lost.

2. What are the session persistence options with WebSphere® Application Server Network Deployment, and what are the advantages and disadvantages of each?
The two main options for HttpSession are database persistence and memory to memory replication. SipSession replication only can use the memory to memory replication. In IBM® WebSphere Application Server Network Deployment, memory to memory replication uses what is called the data replication service (DRS). Additionally, the ObjectGrid (OG) feature of IBM WebSphere eXtreme Scale also offers memory to memory replication for HttpSession.
* Database persistence is the most widely-used option. The performance of database persistence is also better than memory to memory replication, when not taking the extra hardware that the database is running on into account. Another advantage is that this solution can handle cascading failures of application servers, which is only possible with more than one replica in a memory to memory configuration. The disadvantage of database persistence is the cost of the database, particularly if the session data stored in the database should itself be highly available.
* The DRS memory to memory solution is a good solution for many deployments. DRS is "best effort" memory to memory replication, which performs slightly worse than database persistence, depending on data size and number of sessions. The primary advantage of DRS is that you avoid the cost of the database. The disadvantage of DRS is that it is less reliable than the other options. Although we say that DRS is "best effort" and sessions might be lost in the event of a failure, the chances of session loss are minimal in a properly tuned system.
* The third option is the OG memory to memory solution. The advantage of this solution is that it provides everything from asynchronous replication that is not best effort to guaranteed synchronous transactional replication. It is also less expensive than most database solutions. The primary disadvantage would be the added cost above WebSphere Application Server Network Deployment, even though this is less than most database license costs.

3. If I need to come up with a one-size-fits-all general architecture, which do I choose?
In my opinion, I would start with database persistence and investigate OG memory to memory persistence to reduce database costs. Database persistence is the most commonly used architecture and it performs the best.

4. Under what conditions can data be lost?
The most common scenario for session loss is when the write frequency is set to something like time-based writes. Any changes in the session between the last write and a server failure can be lost. This applies to any session replication options.
As I pointed out above, DRS has only a slight chance of losing a session because it is best effort. We say that DRS is best effort because it has no acknowledgements to ensure the data is received by the backup system, and in a system that has congestion issues, a session might not get replicated at all. When the high availability management system in WebSphere Application Server gets very busy, a failure to send the session might occur. While DRS will attempt to retry the send of the session, it might eventually fail if the congestion still exists with each retry. The number of retries and the retry interval is configurable. In the end, you might lose a session if a heavy workload causes these congestion failures for eac h initial try and for the retries, and if the server with that session fails. In this case, the session will be lost and the application will need to handle such a scenario.
The important thing to understand about DRS is that under non-failure conditions, the session will always be there. When a failure does occur, data that has not been written out before the failure occurred might be lost, regardless of whether the server is using database or DRS persistence. If this is a problem for a specific application, you might consider using something like the ObjectGrid cache instead of the session to store those objects. ObjectGrid provides transactional semantics around the object to ensure that if a failure occurs, you know when the change has been committed so that, if the error occurred before the change is committed, you can roll back.

5. Will a loss of session affect any of the other WebSphere Application Server components?
Some parts of the application server itself depend on session to store state like JavaServer™ Faces (JSF) widgets. When a session is lost, however, those pieces are able to recover with some notable problems. For example, if a tree JSF widget was expanded to a certain section and a failure occurs, the next refreshed view of that tree might no longer be expanded.

6. What are other recommendations for using sessions that will be persisted?
* Keep the session state small, preferably less than 4K overall.
* Use transient variables when possible, particularly when caching items in the session. A transient variable enables the application to keep a copy in local memory, but rebuilds the object if using the backup copy.
* Consider using an object cache like WebSphere eXtreme Scale rather than using the session for caching. While sessions might be convenient, the APIs are not purposed as a cache and do not meet many of the needs you could encounter with an object cache.

7. Should I use a single row or multi-row schema with database persistence?
A single row schema provides fewer database queries overall and pushes more data to the database with each update. However, a multi-row schema can be more efficient -- or even necessary -- when there are large session attributes or very few changes to the attributes. Larger amounts of data can be stored using these multi-row schemas since each attribute is stored in its own row in the database. However, the resulting performance can be worse with a multi-row schema, since gathering attributes out of the session might cause multiple queries.

8. What tuning parameters are available for HttpSession in WebSphere Application Server Network Deployment?
The major session tuning options are outlined in the WebSphere Application Server Information Center. For HttpSession, a good place to begin tuning is the write frequency. Basically, you can configure how often the session manager writes to the database or to the peer server’s memory. The best performing options will perform the writes less frequently via the time-based options. The worst performing options are at the end of servlet service method (when the servlet returns from whatever method it was called through) or the manual update (where the servlet itself calls a method on the IBMSession object to cause the write to happen). The manual update can be the most efficient means of session persistence if the attributes are infrequently updated. However, they do introduce the potential for the application failing to call the sync method on the IBMSession after having updated the attribute.
The next major piece to change would be the "write contents," or the options as to what the session manager will write out. Those options consist of whether to write all the session attributes out to the persistence mechanism, or to write just the updated attributes. Writing all of the attributes out each time should really never be done. Aside from the performance not being as good as writing out just the updated attributes, it also can hurt portability to other platforms. Some servers do not support anything but the basic requirement, which is to persist the attribute when a setAttribute method is called.

MQSC commands / mqsc command reference / ibm mqsc commands

The MQSC commands
==================



This section describes, in alphabetic order, all the MQSC commands that can be issued by operators and administrators.

* ALTER AUTHINFO
Use the MQSC command ALTER AUTHINFO to alter an authentication information object. Start of changeThese objects contain the definitions required to perform certificate revocation checking using OCSP or Certificate Revocation Lists (CRLs) on LDAP servers.End of change

* ALTER BUFFPOOL
Use the MQSC command ALTER BUFFPOOL to dynamically add buffers to a predefined buffer pool, or remove buffers from a predefined buffer pool.

* ALTER CFSTRUCT
Use the MQSC command ALTER CFSTRUCT to alter the CF application structure backup and recovery parameters for any specified application structure.

* ALTER CHANNEL
Use the MQSC command ALTER CHANNEL to alter the parameters of a channel.

* ALTER LISTENER
Use MQSC command ALTER LISTENER to alter the parameters of an existing WebSphere® MQ listener definition. If the listener is already running, any changes you make to its definition are effective only after the next time that the listener is started.

* ALTER NAMELIST
Use the MQSC command ALTER NAMELIST to alter a list of names. This is most commonly a list of cluster names or queue names.

* ALTER PROCESS
Use the MQSC command ALTER PROCESS to alter the parameters of an existing WebSphere MQ process definition.

* ALTER PSID
Use the MQSC command ALTER PSID to change the expansion method for a page set.

* ALTER QMGR
Use the MQSC command ALTER QMGR to alter the queue manager parameters for the local queue manager.

* ALTER queues
Use the MQSC command ALTER command to alter the parameters of a local queue (ALTER QLOCAL), alias queue (ALTER QALIAS), model queue (ALTER QMODEL), a remote queue, a queue-manager alias, or a reply-to queue alias (ALTER QREMOTE).

* ALTER SECURITY
Use the MQSC command ALTER SECURITY to define system-wide security options.

* ALTER SERVICE
Use the MQSC command ALTER SERVICE to alter the parameters of an existing WebSphere MQ service definition.

* ALTER STGCLASS
Use the MQSC command ALTER STGCLASS to alter the characteristics of a storage class.

* ALTER SUB
Use the MQSC command ALTER SUB to alter the characteristics of an existing subscription.

* ALTER TOPIC
Use ALTER TOPIC to alter the parameters of an existing WebSphere MQ topic object.
* ALTER TRACE
Use the MQSC command ALTER TRACE to change the trace events being traced for a particular active queue manager trace. ALTER TRACE stops the specified trace, and restarts it with the altered parameters.

* ARCHIVE LOG
Use the MQSC command ARCHIVE LOG as part of your backup procedure. It takes a copy of the current active log (or both logs if you are using dual logging).

* BACKUP CFSTRUCT
Use the MQSC command BACKUP CFSTRUCT to initiate a CF application structure backup.

* CLEAR QLOCAL
Use the MQSC command CLEAR QLOCAL to clear the messages from a local queue.

* CLEAR TOPICSTR
Use the MQSC command CLEAR TOPICSTR to clear the retained message which is stored for the specified topic string.

* DEFINE AUTHINFO
Use the MQSC command DEFINE AUTHINFO to define an authentication information object. Start of changeThese objects contain the definitions required to perform certificate revocation checking using OCSP or Certificate Revocation Lists (CRLs) on LDAP servers.End of change

* DEFINE BUFFPOOL
Use the MQSC command DEFINE BUFFPOOL to define a buffer pool that is used for holding messages in main storage.

* DEFINE CFSTRUCT
Use the MQSC command DEFINE CFSTRUCT to define queue manager CF level capability, and backup and recovery parameters for a Coupling Facility application structure.

* DEFINE CHANNEL
Use the MQSC command DEFINE CHANNEL to define a new channel, and set its parameters.

* DEFINE LISTENER
Use the MQSC command DEFINE LISTENER to define a new WebSphere MQ listener definition, and set its parameters.

* DEFINE LOG
Use the MQSC command DEFINE LOG to add a new active log data set in the ring of active logs.

* DEFINE MAXSMSGS
Use the MQSC command DEFINE MAXSMSGS to define the maximum number of messages that a task can get or put within a single unit of recovery.

* DEFINE NAMELIST
Use the MQSC command DEFINE NAMELIST to define a list of names. This is most commonly a list of cluster names or queue names.

* DEFINE PROCESS
Use the MQSC command DEFINE PROCESS to define a new WebSphere MQ process definition, and set its parameters.

* DEFINE PSID
Use the MQSC command DEFINE PSID to define a page set and associated buffer pool.

* DEFINE QUEUE

* DEFINE SERVICE

Use the MQSC command DEFINE SERVICE to define a new WebSphere MQ service definition, and set its parameters.

* DEFINE STGCLASS
Use the MQSC command DEFINE STGCLASS to define a storage class to page set mapping.

* DEFINE SUB
Use DEFINE SUB to allow an existing application to participate in a publish/subscribe application by allowing the administrative creation of a subscription.

* DEFINE TOPIC
Use DEFINE TOPIC to define a new WebSphere MQ administrative topic node in a topic tree, and set its parameters.

* DELETE AUTHINFO
Use MQSC command DELETE AUTHINFO to delete an authentication information object.

* DELETE BUFFPOOL
Use the MQSC command DELETE BUFFPOOL to delete a buffer pool that is used for holding messages in main storage.

* DELETE CFSTRUCT
Use the MQSC command DELETE CFSTRUCT to delete a CF application structure definition.

* DELETE CHANNEL
Use the MQSC command DELETE CHANNEL to delete a channel definition.

* DELETE LISTENER
Use the MQSC command DELETE LISTENER to delete a listener definition.

* DELETE NAMELIST
Use the MQSC command DELETE NAMELIST to delete a namelist definition.

* DELETE PROCESS
Use the MQSC command DELETE PROCESS to delete a process definition.


* DELETE PSID
Use the MQSC command DELETE PSID to delete a page set. This command closes the page set and de-allocates it from the queue manager.

* DELETE queues

* DELETE SERVICE
Use the MQSC command DELETE SERVICE to delete a service definition.

* DELETE SUB
Use the MQSC command DELETE SUB to remove a durable subscription from the system. For a managed destination, any unprocessed messages left on the destination are removed.

* DELETE STGCLASS
Use the MQSC command DELETE STGCLASS to delete a storage class definition.

* DELETE TOPIC
Use DELETE TOPIC to delete a WebSphere MQ administrative topic node.

* DISPLAY ARCHIVE
Use the MQSC command DISPLAY ARCHIVE to display archive system parameters and information.

* DISPLAY AUTHINFO
Use the MQSC command DISPLAY AUTHINFO to display the attributes of an authentication information object.

* DISPLAY CFSTATUS
Use the MQSC command DISPLAY CFSTATUS to display the status of one or more CF application structures. This command is valid only on WebSphere MQ for z/OS® when the queue manager is a member of a queue-sharing group.

* DISPLAY CFSTRUCT
Use the MQSC command DISPLAY CFSTRUCT to display the attributes of one or more CF application structures. This command is valid only on z/OS when the queue manager is a member of a queue-sharing group.

* DISPLAY CHANNEL
Use the MQSC command DISPLAY CHANNEL to display a channel definition.

* DISPLAY CHINIT
Use the MQSC command DISPLAY CHINIT to display information about the channel initiator. The command server must be running.

* DISPLAY CHSTATUS
Use the MQSC command DISPLAY CHSTATUS to display the status of one or more channels.

* DISPLAY CLUSQMGR
Use the MQSC command DISPLAY CLUSQMGR to display information about cluster channels for queue managers in a cluster.

* DISPLAY CMDSERV
Use the MQSC command DISPLAY CMDSERV to display the status of the command server.

* DISPLAY CONN
Use the MQSC command DISPLAY CONN to display connection information about the applications connected to the queue manager. This is a useful command because it enables you to identify applications with long-running units of work.

* DISPLAY GROUP
Use the MQSC command DISPLAY GROUP to display information about the queue-sharing group to which the queue manager is connected. This command is valid only when the queue manager is a member of a queue-sharing group.

* DISPLAY LISTENER
Use the MQSC command DISPLAY LISTENER to display information about a listener.

* DISPLAY LOG
Use the MQSC command DISPLAY LOG to display log system parameters and information.

* DISPLAY LSSTATUS
Use the MQSC command DISPLAY LSSTATUS to display status information for one or more listeners.

* DISPLAY MAXSMSGS
Use the MQSC command DISPLAY MAXSMSGS to see the maximum number of messages that a task can get or put within a single unit of recovery.

* DISPLAY NAMELIST
Use the MQSC command DISPLAY NAMELIST to display the names in a namelist.

* DISPLAY PROCESS
Use the MQSC command DISPLAY PROCESS to display the attributes of one or more WebSphere MQ processes.

* DISPLAY PUBSUB
Use the MQSC command DISPLAY PUBSUB to display publish/subscribe status information for a queue manager.

* DISPLAY QMGR
Use the MQSC command DISPLAY QMGR to display the queue manager parameters for this queue manager.

* DISPLAY QMSTATUS
Use the MQSC command DISPLAY QMSTATUS to display status information associated with this queue manager.

* DISPLAY QSTATUS
Use the MQSC command DISPLAY QSTATUS to display the status of one or more queues.

* DISPLAY QUEUE
Use the MQSC command DISPLAY QUEUE to display the attributes of one or more queues of any type.

* DISPLAY SBSTATUS
Use the MQSC command DISPLAY SBSTATUS to display the status of a subscription.

* DISPLAY SECURITY
Use the MQSC command DISPLAY SECURITY to display the current settings for the security parameters.

* DISPLAY SERVICE
Use the MQSC command DISPLAY SERVICE to display information about a service.

* DISPLAY STGCLASS
Use the MQSC command DISPLAY STGCLASS to display information about storage classes.

* DISPLAY SUB
Use the MQSC command DISPLAY SUB to display the attributes associated with a subscription.

* DISPLAY SVSTATUS
Use the MQSC command DISPLAY SVSTATUS to display status information for one or more services.

* DISPLAY SYSTEM
Use the MQSC command DISPLAY SYSTEM to display general system parameters and information.
* DISPLAY THREAD
Use the MQSC command DISPLAY THREAD to display information about active and in-doubt threads.

* DISPLAY TOPIC
Use the MQSC command DISPLAY TOPIC to display the attributes of one or more WebSphere MQ topic objects of any type.

* DISPLAY TPSTATUS
Use the MQSC command DISPLAY TPSTATUS to display the status of one or more topic nodes in a topic tree.

* DISPLAY TRACE
Use the MQSC command DISPLAY TRACE to display a list of active traces.

* DISPLAY USAGE
Use the MQSC command DISPLAY USAGE to display information about the current state of a page set, or to display information about the log data sets.

* MOVE QLOCAL
Use the MQSC command MOVE QLOCAL to move all the messages from one local queue to another.

* PING CHANNEL
Use the MQSC command PING CHANNEL to test a channel by sending data as a special message to the remote queue manager, and checking that the data is returned. The data is generated by the local queue manager.

* PING QMGR
Use the MQSC command PING QMGR to test whether the queue manager is responsive to commands.

* RECOVER BSDS
Use the MQSC command RECOVER BSDS to reestablish a dual bootstrap data set (BSDS) after one has been disabled by a data set error.

* RECOVER CFSTRUCT
Use the MQSC command RECOVER CFSTRUCT to initiate recovery of CF application structures. This command is valid only when the queue manager is a member of a queue-sharing group.

* REFRESH CLUSTER
Use the MQSC command REFRESH CLUSTER to discard all locally held cluster information (including any autodefined channels that are in doubt), and force it to be rebuilt. This enables you to perform a "cold-start" on the cluster.

* REFRESH QMGR
Use the MQSC command REFRESH QMGR to perform special operations on queue managers.

* REFRESH SECURITY
Use the MQSC command REFRESH SECURITY to perform a security refresh.

* RESET CHANNEL
Use the MQSC command RESET CHANNEL to reset the message sequence number for a WebSphere MQ channel with, optionally, a specified sequence number to be used the next time that the channel is started.

* RESET CLUSTER
Use the MQSC command RESET CLUSTER to perform special operations on clusters.

* RESET QMGR
Use the MQSC command RESET QMGR as part of your backup and recovery procedures.

* RESET QSTATS
Use the MQSC command RESET QSTATS to report performance data for a queue and then to reset that data.

* RESET TPIPE
Use the MQSC command RESET TPIPE to reset the recoverable sequence numbers for an IMS™ Tpipe used by the WebSphere MQ-IMS bridge.

* RESOLVE CHANNEL
Use the MQSC command RESOLVE CHANNEL to request a channel to commit or back out in-doubt messages.

* RESOLVE INDOUBT
Use the MQSC command RESOLVE INDOUBT to resolve threads left in doubt because WebSphere MQ or a transaction manager could not resolve them automatically.

* RESUME QMGR
Use the MQSC command RESUME QMGR to inform other queue mangers in a cluster that the local queue manager is available again for processing and can be sent messages. It reverses the action of the SUSPEND QMGR command.

* RVERIFY SECURITY
Use the MQSC command RVERIFY SECURITY to set a reverification flag for all specified users. The user is reverified the next time that security is checked for that user.

* SET ARCHIVE
Use the MQSC command SET ARCHIVE to dynamically change certain archive system parameter values initially set by your system parameter module at queue manager startup.

* SET LOG
Use the MQSC command SET LOG to dynamically change certain log system parameter values that were initially set by your system parameter module at queue manager startup.

* SET SYSTEM
Use the MQSC command SET SYSTEM to dynamically change certain general system parameter values that were initially set from your system parameter module at queue manager startup.

* START CHANNEL
Use the MQSC command START CHANNEL to start a channel.

* START CHINIT
Use the MQSC command START CHINIT to start a channel initiator.

* START CMDSERV
Use the MQSC command START CMDSERV to initialize the command server.

* START LISTENER
Use the MQSC command START LISTENER to start a channel listener.

* START QMGR
Use the MQSC command START QMGR to initialize the queue manager.

* START SERVICE
Use the MQSC command START SERVICE to start a service. The identified service definition is started within the queue manager and inherits the environment and security variables of the queue manager.

* START TRACE
Use the MQSC command START TRACE to start traces.

* STOP CHANNEL
Use the MQSC command STOP CHANNEL to stop a channel.

* STOP CHINIT
Use the MQSC command STOP CHINIT to stop a channel initiator. The command server must be running.

* STOP CMDSERV
Use the MQSC command STOP CMDSERV to stop the command server.

* STOP CONN
Use the MQSC command STOP CONN to break a connection between an application and the queue manager.

* STOP LISTENER
Use the MQSC command STOP LISTENER to stop a channel listener.

* STOP QMGR
Use the MQSC command STOP QMGR to stop the queue manager.

* STOP SERVICE
Use the MQSC command STOP SERVICE to stop a service.

* STOP TRACE
Use the MQSC command STOP TRACE to stop tracing.

* SUSPEND QMGR
Use the MQSC command SUSPEND QMGR to inform other queue managers in a cluster that the local queue manager is not available for processing and cannot be sent messages, or to suspend logging and update activity for the queue manager until a subsequent RESUME QMGR command is issued. Its action can be reversed by the RESUME QMGR command.

Memory Utilization of Individual Process on Linux

One of my colleague found this easy way to figure of memory utilization of each process running on linux machine without root access though :)

To calculate for each process on linux we do the following:

We have a java process runing on 7804 . Hence pid is 7804

[test@appsupport /]$ cat /proc/7804/statm

124 123 108 6 1 117 10

[test@appsupport /]$


In this 124 is in pages, to calculate it to KB multiply It with 4 ( 124*4 => 496 KB ).

################
Script to calculate the total memory for n number of processes.
################
Below we are calculating for all root process running.

ps auxwww | grep -i root | awk '{ print $2}' > /tmp/txt.txt

for i in `cat /tmp/txt.txt`; do cd /proc/;cd $i;a=`cat statm | awk '{ print $1}'`; let a*=4; echo $a memory utilized by $i "completed";let b=b+a;cd ../; done

Thursday, August 5, 2010

mod_proxy or mod_jk

There are several ways to run Tomcat applications. You can either run tomcat direcly on port 80, or you can put a webserver in front of tomcat and proxy connections to it. I would highly recommend using Apache as a front end. The main reason for this suggestion is that Apache is more flexible than tomcat. Apache has many modules that would require you to code support yourself in Tomcat. For example, while Tomcat can do gzip compression, it's a single switch; enabled or disabled. Sadly you can not compress CSS or javascript for Internet Explorer 6. This is easy to support in Apache, but impossible to do in Tomcat. Things like caching are also easier to do in Apache.

Having decided to use Apache to front Tomcat, you need to decide how to connect them. There are several choices: mod_proxy ( more accurately, mod_proxy_http in Apache 2.2, but I'll refer to this as mod_proxy), mod_jk and mod_jk2. Mod_jk2 is not under active development and should not be used. This leaves us with mod_proxy or mod_jk.

Both methods forward requests from apache to tomcat. mod_proxy uses the HTTP that we all know an love. mod_jk uses a binary protocol AJP. The main advantages of mod_jk are:

  • AJP is a binary protocol, so is slightly quicker for both ends to deal with and uses slightly less overhead compared to HTTP, but this is minimal.
  • AJP includes information like original host name, the remote host and the SSL connection. This means that ServletRequest.isSecure() works as expected, and that you know who is connecting to you and allows you to do some sort of virtualhosting in your code.

A slight disadvantage is that AJP is based on fixed sized chunks, and can break with long headers, particularly request URLs with long list of parameters, but you should rarely be in a position of having 8K of URL parameters. (It would suggest you were doing it wrong. :) )

It used to be the case that mod_jk provided basic load balancing between two tomcats, which mod_proxy couldn't do, but with the new mod_proxy_balancer in Apache 2.2, this is no longer a reason to choose between them.

The position is slightly complicated by the existence of mod_proxy_ajp. Between them, mod_jk is the more mature of the two, but mod_proxy_ajp works in the same framework as the other mod_proxy modules. I have not yet used mod_proxy_ajp, but would consider doing so in the future, as mod_proxy_ajp is part of Apche and mod_jk involves additional configuration outside of Apache.

Given a choice, I would prefer a AJP based connector, mostly due to my second stated advantage, more than the performance aspect. Of course, if your application vendor doesn't support anything other than mod_proxy_http, that does tie your hands somewhat.

You could use an alternative webserver like lighttpd, which does have an AJP module. Sadly, my prefered lightweight HTTP server, nginx, does not support AJP and is unlike ever to do so, due to the design of its proxying system.

########################################

mod_jk Configuration

########################################

Here's an example of the extra configuartion needed in the Apache httpd configuration file - (/usr/local/apache2/conf/httpd.conf)

LoadModule jk_module modules/mod_jk.so
JkWorkersFile /usr/local/apache2/conf/jkworkers.properties
JkMount /latmjdemo* catkin


And here's the jkworkers.properties file:

worker.list=catkin
worker.oak.port=8009
worker.oak.host=192.168.200.1
worker.oak.lbfactor=5
worker.elm.port=8009
worker.elm.host=192.168.200.158
worker.elm.lbfactor=15
worker.catkin.type=lb
worker.catkin.balanced_workers=oak,elm
worker.catkin.sticky_session=1


Traffic is forwarded to a Tomcat server called "Oak" on 192.168.200.1, or a Tomcat server called "Elm" on 192.168.200.158, with that latter getting 3 forwards for every one passed to Oak.

The "sticky_session" is worth comment. Rather than randomly forwarding tarffic to either server, httpd will forward users who already have sessions established to the same system right through their session. That way, a multiple page process (such as an on line ordering system) can easily be implemented without the need for a lot of extra code to share work-in-progress data between the various Tomcat server.

In order for sticky sessions to work, you need to configure your jvmRoute in Tomcat to reflect the server name

########################################

########################################

mod_proxy Configuration

########################################

Proxy forwarding to a Java Server

Here's an example of a proxied request from Apache httpd on to a server (probably Apache Tomcat) that's running the ajp protocol on port 5090:

ProxyPass /harry ajp://192.168.200.215:5090/latmjdemo
ProxyPassReverse /harry ajp://192.168.200.215:5090/latmjdemo


That's code to be added to the end of your httpd.conf file!

Proxy forwarding to a group of Java Servers

It gets even better ... mod_proxy_balancer lets you define a group of Java servers which you can forward your traffic on to - ideal on a busy site where the background task that's running in Java is a resource hog and needs to be shared between systems. Here's an example of what you would add to httpd.conf:


BalancerMember ajp://192.168.200.215:5090/latmjdemo
BalancerMember ajp://192.168.200.214:5009/latmjdemo

ProxyPass /prince balancer://catbox/


In this example, any references to the web resources on the server under the /prince directory will be forwarded to one of two other machines, on port 5090, and will be directed to the "latmjdemo" web application on there.

More flexibility in forwarding to a group of Servers

The example above uses the default "round robin" scheduler - but there are other facilities available too to help you tune your forwarding. Here's a further example:


BalancerMember ajp://192.168.200.219:5009/latmjdemo loadfactor=1
BalancerMember ajp://192.168.200.218:5009/latmjdemo loadfactor=3
BalancerMember ajp://192.168.200.215:5009/latmjdemo status=+h
ProxySet lbmethod=bytraffic
ProxySet stickysession=JSESSIONID

ProxyPass /corgi balancer://kennel/


In this example, we are forwarding to 2 systems, in a ratio of 1 : 3 and we're allocating traffic based on the traffic quantities coming back from each server rather than the number of requests (so queries that generate a lot of traffic count for more). An extra machine has been designated as "hot swap" if neither of the others is available. Once a visitor is allocated to a particular machine for his forward, he'll continue to be forwarded to that same system while his JSESSIONID cookie remains live.

Some other notes about mod_proxy and family in Apache 2.2:

• ProxyPassMatch is available, which lets you specify a pattern (Regular Expression) for your forwarding - for example, if you wanted to forward all you image requests to an image server:
ProxyPassMatch ^/(.*\.jpg)$ http://images.wellho.net/$1

• mod_rewrite IS aware of mod_proxy_balancer, so that you can rewrite your requests as we do in many parts of our site, and then forward them on to other systems through an appropriate balancer.

• As from Apache 2.2.9, ProxyPassReverse is also mod_proxy_balancer aware.

########################################

Tuesday, February 16, 2010

Thread dumps using Commandline

Generic approach would be kill -3 on any unix/linux box ,output would be in std_out file. What if you need to take 4 or 5 thread dumps and std_out file is so huge that you need to use your unix skills to extract those thread dump output from this logs .

You can use the following methods for taking the threaddumps from commandline

#############
Jboss
#############

/jboss/bin/twiddle.sh invoke "jboss.system:type=ServerInfo" listThreadDump > /tmp/threadump.out


#############
Weblogic
#############

1. Source the environment variable.

Example: source /opt/bea/10.0/user_projects/domains/supportapps/bin/setDomainEnv.sh

2. Invoke wlst with following command and connect to the admin server in offline mode

$ java weblogic.WLST

connect ('Admin_Console_user_id','Password','t3://console_url')


Example:
connect ('weblogic','weblogic','t3://supportapps.blogspot.com:7001')

3. Take Thread Dump

threadDump('true', 'file name', 'server_name')

Example:
threadDump('true', 'supportapps.out', 'server1')

#############
Websphere
#############
Generating thread dump/java core using WSAdmin prompt .You can generate Thread Dump or Java core manually using the following

WSAdmin prompt

Using wasadmin prompt,

wsadmin >

set objectName [$AdminControl queryNames WebSphere:type=JVM,process=server1,node=appsrv01_node,*]

$AdminControl invoke $objectName generateHeapDump

$AdminControl invoke $objectName dumpThreads



Once the thread dump is generated you can find out the location of the thread dump from native_stderr.log file. This is

sample of the messages from my native_stderr.log


JVMDUMP007I JVM Requesting Java Dump using '/opt/AppServer/profiles/AppSrv01/javacore.20090705.212408.5480.0001.txt'
JVMDUMP010I Java Dump written to /opt/AppServer/profiles/AppSrv01/javacore.20090705.212408.5480.0001.txt



100% CPU Usage on Solaris caused by webpshere process

Problem


How to determine which thread(s) is consuming the CPU cycles when a Java process has high CPU usage for an extended period of time.


This technote uses the data gathered from technote # 1115625, titled: "MustGather: 100% CPU Usage on Solaris".


Cause If the Application Server causes a spike in CPU usage for several minutes, this technote can help you identify the Java code that is causing the problem.


SolutionUsing the files attached to this technote, the following 3 steps demonstrate how to find the problem thread and the corresponding Java code.


1. Analyze the prstat information to determine the lwp(light weight process) consuming CPU.

The following prstat was generated with the following command:
"prstat -mvL 1 1" . Use of different prstat parameters will give different output but can be used in a similar fashion as described below.

PID USRNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROC/LWPID
16365 root 36 53 0.0 0.0 0.0 0.0 18 0.0 0 178 13K 0 prstat/1
16310 root 46 0.0 0.1 0.0 0.0 4.3 45 5.0 0 58 8 0 java/30
16310 root 5.8 0.2 0.0 0.0 0.0 0.0 94 0.0 0 11 56 0 java/11
16310 root 2.6 0.1 0.0 0.0 0.0 0.0 97 0.0 0 6 18 0 java/5
5158 root 0.5 0.1 0.0 0.0 0.0 0.0 99 0.0 49 30 1K 19 .netscape.bi/1
16310 root 0.3 0.0 0.0 0.0 0.0 0.0 100 0.0 2 1 11 0 java/23
16310 root 0.3 0.0 0.0 0.0 0.0 0.0 100 0.0 5 1 7 0 java/13
16310 root 0.3 0.0 0.0 0.0 0.0 0.0 100 0.0 1 0 2 0 java/3
16310 root 0.3 0.0 0.0 0.0 0.0 0.0 100 0.0 0 0 2 0 java/17
16310 root 0.2 0.0 0.0 0.0 0.0 0.0 100 0.0 4 2 6 0 java/16
16310 root 0.2 0.0 0.0 0.0 0.0 0.0 100 0.0 0 1 1 0 java/18
16310 root 0.1 0.1 0.0 0.0 0.0 0.0 99 0.5 99 0 87 0 java/1
16310 root 0.2 0.0 0.0 0.0 0.0 0.0 100 0.0 3 0 12 0 java/28
16310 root 0.2 0.0 0.0 0.0 0.0 0.0 100 0.0 0 0 1 0 java/19
290 root 0.1 0.1 0.0 0.0 0.0 0.0 100 0.0 21 0 132 0 Xsun/1
Total: 90 processes, 233 lwps, load averages: 1.00, 0.84, 0.66

In the above prstat output, the third and fourth columns provide the amount of time the
process has spent in user and system mode. Ignoring the prstat command the most CPU time is being consumed by LWPID=30.

2. Use the LWPID of 30to find the thread in the pstack output. The following is a snippet from the pstack output:

----------------- lwp# 30/ thread# 50 --------------------
fe753aa8 ???????? (0, 5265c00, fa, 43a85d79, fe74e170, e04803fc)
fb1025b4 ???????? (f60748, e04819b8, fe74e170, f60748, fe763ca0, 16)
.....

fe505288 _start (fe74e170, e1ef5d10, 0, 5, 1, fe401000) + 20
ff36b6e0 _thread_start(f25078, 0, 0, 0, 0, 0) + 40
---------------------------------------------------------

Look for "_thread_start" at the bottom of the thread stack. The first number inside the ( ) is
the "tid". In this case the tid = f25078.


3. Finally, search for f25078in the thread dump output. For WebSphere 5.0.x & 5.1 this is the file native_stdout.log. In the following snippet of the thread dump you will see the tid of f25078.

"Servlet.Engine.Transports : 0" daemon prio=5 tid=0xf25078nid=0x32 runnable [0xe0480000..0xe04819d8]
at java.lang.System.currentTimeMillis(Native Method)
at java.util.Date.(Date.java:161)
at org.apache.jsp._wtime._jspService(_wtime.java:96)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service....
....

Alternatively, you may use the thread# 50 from the pstack output to correlate the prstat and the thread dump. This is the decimal representation of the thread's "nid" in the thread dump. Using the example above, since decimal 50 is 0x32, thread# 50 can be used to find the thread by locating "nid=0x32" in the thread dumps. This is the only method that works if the application is using the alternate threading libraries. To determine which library is being used, please refer to section "Determining which library is currently in use" at link: http://www-1.ibm.com/support/docview.wss?uid=swg21107291



Analyzing the thread stack for this tid will help lead you to the code causing the high CPU usage. In this case the issue most likely comes from the JSP:
_wtime._jspService(_wtime.java:96)