Solved

Jython Script for Recycle

Posted on 2011-09-08
23
1,050 Views
Last Modified: 2013-12-11
Hello Team,

I am looking for a script which can do following actions
1. Stop all the JVM's running in a cell excluding DMGR.
2. Need to check if all the JVM's are down or not if some JVM are running script should kill the JVM's and do one more Check.
3. Start all the JVM's.
0
Comment
Question by:k_satish22
  • 13
  • 10
23 Comments
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
Including the NodeAgents?

If you really want to stop, and  restart the cell, is there a particular reason for "waiting" until each AppServer is actually stopped?

This would really delay (and complicate) the process.

There is a much easier, and fast technique, which would be to:

- Identify, and locate each Application Server
- Invoke the "restart" method on the AppServer MBean

Please let me know what you need.

Thanks!
0
 

Author Comment

by:k_satish22
Comment Utility
Yes including the nodeagent also. If the JVM generates the javacores and the JVM is unresponsive it should kill the process too. If it is not possible using the jython script even shell script is okay for me.
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
What operating system(s)?

What version(s) of WebSphere?
- Execute: D:\IBM\WebSphere\AppServer\bin\versionInfo
           or: /opt/IBM/WebSphere/AppServer/bin/versionInfo.sh

What is displayed in the "Installed Product" section?
0
 

Author Comment

by:k_satish22
Comment Utility
OS - AIX
Installed Product
--------------------------------------------------------------------------------
Name                     IBM WebSphere Application Server - ND
Version                  7.0.0.13
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
Here's a challenge, at least for a Jython script

- When a wsadmin script is executing, and the connection is to the Deployment
  Manager, should a problem exist with a node agent (e.g., it is either stopped,
  or not responding to requests), then every Application Server on that node
  is incommunicado, and the script that is executing is unable to access every
  AppServer under (associated with) that nodeagent.

Q: What would you think about a Python script that executes outside of
    (totally separate from) wsadmin?

Request:
  Please execute the following command to verify that python is installed, and
is available:

# python -V

  The response should be something like:

Python w.x.y

  where
     w == Major version number (e.g., 2 or 3)
     x == Minor version number
     y == Release number
0
 

Author Comment

by:k_satish22
Comment Utility
Hello HonorGod,

We don't have pyton on our servers. Is there any alternative like ksh script?

Thank You so much for your help
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
Q: Is there any alternative like ksh script?
A: Always... ;-)
    It's simply a matter of finding out what tools are available...

Let me see what I can figure out...
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
You do realize that you're going to make me work, right? ;-)

This is a non-trivial task (which of course makes it more interesting).

Q: If a nodeagent, and/or server is inactive, should it be left as stopped, or started?
0
 

Author Comment

by:k_satish22
Comment Utility
Yes. But I need this script :)

If the nodeagent or server is inactive or running as rouge process script need to kill the process and start it.
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
While I was working on it, I realized that we have a potential problem...

In order to start a nodeagent that is stopped, we need to execute the startNode command script on the nodeagent machine.

Do you only have one nodeagent, and is it on the same machine as your DM?

Does this make sense?

Option:
  If a nodeagent is active, a wsadmin script can locate the nodeagent MBean identifier, and use it to invoke the MBean restart method.

Is it possible that the restart could fail, or hang?

Yes, but this isn't likely.  How often have you had a stopNode or stopServer command script fail?
0
 

Author Comment

by:k_satish22
Comment Utility

In few environments we have DMGR and Node agent on the same servers and in few environments DMGR and Node agents on separate servers.

Our Architecture  is One ND  and multiple Nodes.

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
ok, so you do realize that from the DM machine, the "startNode.sh" can not be run to start a node agent on a remote machine.... right?!?

Unless, of course, you have some kind of mechanism for this kind of "remote execution" (hopefully using a secure connection between the machines).
0
 

Author Comment

by:k_satish22
Comment Utility
We have a ssh setup from one of our server to all the servers in the network. I am want run this script from that servers. It is also having WAS running on it.
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
Let's take a look at what this requires for a remote AppServer (including a nodeagent)

- Assuming that the specified AppServer (and it's nodeagent) are active, then the
  Jython script we're talking about using will execute while connected to the DM.

- The recycle script will need to locate and identify each AppServer [doable]
- obtain it's process id (pid) [doable]
- tell the AppServer to stop [doable]
> Once this "stop" request completes, then the script will need to use some kind of
  command to verify that the pid has, in fact, stopped
  e.g., something like  http://bashcurescancer.com/run_remote_commands_with_ssh.html

  > If that results in a "false" (i.e., process still exists), we'll need to use this
  > technique to send a "kill -9" for that process.

  > Once the "stop" is complete, then the command to be issued (i.e., either
  > startNode.sh or startServer.sh with the proper parameters (e.g., profileName)
  > needs to be executed, and the results need to be verified / logged (i.e.,
  > either success or failure.

Does this sound like what you want?
0
 

Author Comment

by:k_satish22
Comment Utility
Yes exactly that is my requirement.
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
ok, how do you want to do this?

We could have some kind of shell script that takes parameters, and uses them to execute the specified command (e.g., startNode or startServer) on the specified remote machine.

Another possibility would be to have the required commands in something like a properties file which the jython could load as part of it's initialization process.

One challenge:

- How do you want to secure the necessary information (i.e., any userid & password)?
0
 

Author Comment

by:k_satish22
Comment Utility
I would like to go with first option. As of now my team only will have access to the directory where we place the script with may contain clear text user ID and password. We will think about the security issue later.
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
ok, in order to "verify" that a remote server has stopped, we'll have to be able to do something like execute a command something like this, and pass the results back for verification...

The number is the process id of a WebSphere AppServer process.

Does this make sense?

Can you:
- Use this command to list all of the WebSphere java processes:

  ps -ef | grep [j]ava

- pick one of the processes ids, and see if you can use an ssh command to issue the command shown below for that process id.
ps -ef | grep "28106 .*[j]ava"

Open in new window

0
 

Author Comment

by:k_satish22
Comment Utility
wasadmin@bforge02:wasadmin$  ssh wasadmin@dmgr1.e57.acsenterprise.com 'ps -ef | grep "1802688 .*[j]ava"'
wasadmin 1802688       1   0   Sep 18      -  8:48 /opt/app/IBM/WebSphere/AppDmgr70/java/bin/java -Declipse.security -Dwas.status.socket=53881 -Dosgi.install.area=/opt/app/IBM/WebSphere/AppDmgr70 -Dosgi.configuration.area=/opt/app/IBM/WebSphere/AppDmgr70/profiles/AppDmgr01/configuration -Djava.awt.headless=true -Dosgi.framework.extensions=com.ibm.cds,com.ibm.ws.eclipse.adaptors -Xshareclasses:name=webspherev70_%g,groupAccess,nonFatal -Xscmx50M -Xbootclasspath/p:/opt/app/IBM/WebSphere/AppDmgr70/java/jre/lib/ext/ibmorb.jar:/opt/app/IBM/WebSphere/AppDmgr70/java/jre/lib/ext/ibmext.jar -classpath /opt/app/IBM/WebSphere/AppDmgr70/profiles/AppDmgr01/properties:/opt/app/IBM/WebSphere/AppDmgr70/properties:/opt/app/IBM/WebSphere/AppDmgr70/lib/startup.jar:/opt/app/IBM/WebSphere/AppDmgr70/lib/bootstrap.jar:/opt/app/IBM/WebSphere/AppDmgr70/lib/jsf-nls.jar:/opt/app/IBM/WebSphere/AppDmgr70/lib/lmproxy.jar:/opt/app/IBM/WebSphere/AppDmgr70/lib/urlprotocols.jar:/opt/app/IBM/WebSphere/AppDmgr70/deploytool/itp/batchboot.jar:/opt/app/IBM/WebSphere/AppDmgr70/deploytool/itp/batch2.jar:/opt/app/IBM/WebSphere/AppDmgr70/java/lib/tools.jar -Dibm.websphere.internalClassAccessMode=allow -Xms50m -Xmx256m -Dws.ext.dirs=/opt/app/IBM/WebSphere/AppDmgr70/java/lib:/opt/app/IBM/WebSphere/AppDmgr70/profiles/AppDmgr01/classes:/opt/app/IBM/WebSphere/AppDmgr70/classes:/opt/app/IBM/WebSphere/AppDmgr70/lib:/opt/app/IBM/WebSphere/AppDmgr70/installedChannels:/opt/app/IBM/WebSphere/AppDmgr70/lib/ext:/opt/app/IBM/WebSphere/AppDmgr70/web/help:/opt/app/IBM/WebSphere/AppDmgr70/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime -Dderby.system.home=/opt/app/IBM/WebSphere/AppDmgr70/derby -Dcom.ibm.itp.location=/opt/app/IBM/WebSphere/AppDmgr70/bin -Djava.util.logging.configureByServer=true -Duser.install.root=/opt/app/IBM/WebSphere/AppDmgr70/profiles/AppDmgr01 -Djavax.management.builder.initial=com.ibm.ws.management.PlatformMBeanServerBuilder -Dwas.install.root=/opt/app/IBM/WebSphere/AppDmgr70 -Dpython.cachedir=/opt/app/IBM/WebSphere/AppDmgr70/profiles/AppDmgr01/temp/cachedir -Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManager -Dserver.root=/opt/app/IBM/WebSphere/AppDmgr70/profiles/AppDmgr01 -Dcom.ibm.security.jgss.debug=off -Dcom.ibm.security.krb5.Krb5Debug=off -Djava.security.auth.login.config=/opt/app/IBM/WebSphere/AppDmgr70/profiles/AppDmgr01/properties/wsjaas.conf -Djava.security.policy=/opt/app/IBM/WebSphere/AppDmgr70/profiles/AppDmgr01/properties/server.policy com.ibm.wsspi.bootstrap.WSPreLauncher -nosplash -application com.ibm.ws.bootstrap.WSLauncher com.ibm.ws.runtime.WsServer /opt/app/IBM/WebSphere/AppDmgr70/profiles/AppDmgr01/config APPCell01 dmgr1Node01 dmgr
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
That is superb.

So, we can use this technique to verify that:
- A process of the specified process id is active (or not), and
- if it is active, that it is a WebSphere AppServer process!

One moment please... ;-)  ok, it's going to take me more than "a moment", but let's see what we can do to make this happen...
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
Q: What do you want displayed if a nodeagent is found to be inactive or unreachable?
0
 

Author Comment

by:k_satish22
Comment Utility
We need to check if any rough process running as node agent. If the process exists we need to kill it and start the node agent.
0
 
LVL 41

Accepted Solution

by:
HonorGod earned 500 total points
Comment Utility
ok, I know that this isn't complete.

What it is trying to do is locate each node (other than the DM node),
Locate the node agent
Stop each server in this node
Stop the node agent in this node.

If this is how you would like to proceed, let me know.
recycleCell.py
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Apache Solr Search how to Highlight 4 252
Tomcat Memory Allocations 5 247
classpath 4 114
web service Rest Client creation 4 73
This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
Upgrading Tomcat – There are a couple of methods to upgrade Tomcat is to use The Apache Installer is to download and unzip and run the services.bat remove|install Tomcat6 Because of the App that we are working with, we can only use Tomcat 6.…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now