Link to home
Start Free TrialLog in
Avatar of k_satish22
k_satish22

asked on

Jython Script for Recycle

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.
Avatar of HonorGod
HonorGod
Flag of United States of America image

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!
Avatar of k_satish22
k_satish22

ASKER

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.
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?
OS - AIX
Installed Product
--------------------------------------------------------------------------------
Name                     IBM WebSphere Application Server - ND
Version                  7.0.0.13
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
Hello HonorGod,

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

Thank You so much for your help
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...
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?
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.
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?

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.

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).
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.
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?
Yes exactly that is my requirement.
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)?
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.
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

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
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...
Q: What do you want displayed if a nodeagent is found to be inactive or unreachable?
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.
ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial