Python script

Thiruvarangam
Thiruvarangam used Ask the Experts™
on
trying to execute
http://oracledbasupport.co.uk/wp-content/2010/09/check-was_py.txt

and getting this error


WASX7303I: The following options are passed to the scripting environment and are available as argument that is stored in the argv variable: "[-i, heapsize, -s, PIP.Server1, -n, seiadsapq01]"
WASX7017E: Exception received while running file "/tmp/check-was.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<string>", line 44, in ?
ImportError: no module named re
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
HonorGodSoftware Engineer

Commented:
It looks like you are trying to execute a wsadmin Jython script on version 6.0 of the WebSphere Application Server.  I don't think that the re module existed in the 6.0 environment.

Execute the versionInfo command (shell) script in the AppServer/bin directory

e.g., something like:

./versionInfo.sh

And look for the "Installed Product" section.

Commented:
It is trying to import the regular expression module "re" and can't find it. If you have a regular expression lib with a other name you can modify the script with

import <your regular expression module> as re

Open in new window


Author

Commented:
Yeah its
Version                  6.0.2.43

can u alter the script for me so it works on this version?
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

HonorGodSoftware Engineer

Commented:
Please attach the script.

Author

Commented:
please find it . i need urgently please look into it
check-was.py
HonorGodSoftware Engineer

Commented:
The Jython support in wsadmin 6.0 is pitiful... this is going to take some work... ;-(
HonorGodSoftware Engineer

Commented:
Do you have access to a version 6.1 Application Server installation?

If so, we can copy some files from it to your 6.0 environment to minimize the changes that need to be made to the script.

Author

Commented:
No We dont have anything else than 6.0 :( sorry for that . can  u modify it so it works on 6.0?
HonorGodSoftware Engineer

Commented:
Probably, but with a non-trivial amount of work.

However, if I provide 3 python files from a 6.1 optionalLibraries\jython\Lib directory, then it is MUCH easier.

- Under your AppServer directory, you should find an optionalLibraries directory/folder.
- If it doesn't contain a "jython" directory, create one
- under the jython directory, create a Lib directory
- unzip the contents of the attached zip file to this directory

  And try the attached version of check_was.  Let me know how it goes.
wsadmin-60.jython-Libs.zip
check-was.09.py
HonorGodSoftware Engineer

Commented:
by the way, can you add the "IBM WebSphere" zone to this question?   I don't know if you can add it after the fact, or not.  Thanks

Author

Commented:
Hi
i updated the modules what you gave , when i try to run the script i am getting the below error


check_was: Unknown node: nodeagent

check_was: Unknown server: server1

But the mentioned jvm and nodeagent have exact names as given and its up and running

Any idea how to fix ?
HonorGodSoftware Engineer

Commented:
nodeagent is not a node name.

You can list the nodes using the following:

The output will be a list of the configuration IDs for each of the configured nodes.
The name of each node should exist before the open parenthesis. e.g.,

----------------------------------------------------------------------
myCellManager02(cells/myCell02/nodes/myCellManager02|node.xml#Node_1)
myNode03(cells/myCell02/nodes/myNode03|node.xml#Node_1)
----------------------------------------------------------------------

Which shows that this configuration has 2 nodes, the one for the Deployment Manager (i.e., "myCellManager02"), and another node (i.e., "myNode03").

So, you should use the nodeName for the node containing the server in which you are interested.

Does that make sense?
./wsadmin.sh -lang jython -conntype none -c "print AdminConfig.list( 'Node' )"

Open in new window

Author

Commented:
Hi Please help me how to run the command


wsadmin>print AdminConfig.list( 'Server')
WC_EN_LIVE_1(cells/endev-cell/nodes/usculenwas07d-node/servers/WC_EN_LIVE_1|server.xml#Server_1306761199441)
WC_EN_LIVE_2(cells/endev-cell/nodes/usculenwas06d-node/servers/WC_EN_LIVE_2|server.xml#Server_1306761199783)
dmgr(cells/endev-cell/nodes/usculenwcs01d-dm-node/servers/dmgr|server.xml#Server_1)
nodeagent(cells/endev-cell/nodes/usculenwas06d-node/servers/nodeagent|server.xml#Server_1306751793619)
nodeagent(cells/endev-cell/nodes/usculenwas07d-node/servers/nodeagent|server.xml#Server_1306753434963)
nodeagent(cells/endev-cell/nodes/usculenwcs01d-node/servers/nodeagent|server.xml#Server_1306747298257)
server1(cells/endev-cell/nodes/usculenwcs01d-node/servers/server1|server.xml#Server_1306461390118)
webserver1(cells/endev-cell/nodes/usculenwcs01d-node/servers/webserver1|server.xml#Server_1306748668816)
wsadmin>[wasadmin@usculenwas06d bin]$ cd ../optionalLibraries/jython/
[wasadmin@usculenwas06d jython]$ /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -f checkwas.py -i heapsize -s server1
WASX7209I: Connected to process "dmgr" on node usculenwcs01d-dm-node using SOAP connector;  The type of process is: DeploymentManager
Script file checkwas.py is in the wrong language and will not be executed; language used is jacl
[wasadmin@usculenwas06d jython]$ /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -f checkwas.py -i heapsize -s server1 -lang jython
WASX7209I: Connected to process "dmgr" on node usculenwcs01d-dm-node using SOAP connector;  The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as argument that is stored in the argv variable: "[-i, heapsize, -s, server1]"
check_was: Unknown server: server1
HonorGodSoftware Engineer

Commented:
ok, let's take a look at this in pieces...

This interactive wsadmin sessions shows us the configured servers:
----------------------------------------------------------------------
wsadmin>print AdminConfig.list( 'Server')
WC_EN_LIVE_1(cells/endev-cell/nodes/usculenwas07d-node/servers/WC_EN_LIVE_1|server.xml#Server_1306761199441)
WC_EN_LIVE_2(cells/endev-cell/nodes/usculenwas06d-node/servers/WC_EN_LIVE_2|server.xml#Server_1306761199783)
dmgr(cells/endev-cell/nodes/usculenwcs01d-dm-node/servers/dmgr|server.xml#Server_1)
nodeagent(cells/endev-cell/nodes/usculenwas06d-node/servers/nodeagent|server.xml#Server_1306751793619)
nodeagent(cells/endev-cell/nodes/usculenwas07d-node/servers/nodeagent|server.xml#Server_1306753434963)
nodeagent(cells/endev-cell/nodes/usculenwcs01d-node/servers/nodeagent|server.xml#Server_1306747298257)
server1(cells/endev-cell/nodes/usculenwcs01d-node/servers/server1|server.xml#Server_1306461390118)
webserver1(cells/endev-cell/nodes/usculenwcs01d-node/servers/webserver1|server.xml#Server_1306748668816)
wsadmin>
----------------------------------------------------------------------

From this, it we can find the following hierarchy of item, and their names:

----------------------------------------------------------------------
Cell: endev-cell
  Node: usculenwcs01d-dm-node
    Server: dmgr
  Node: usculenwcs01d-node
    Server: nodeagent
    Server: server1
    Server: webserver1
  Node: usculenwas06d-node
    Server: nodeagent
    Server: WC_EN_LIVE_2
  Node: usculenwas07d-node
    Server: nodeagent
    Server: WC_EN_LIVE_1
----------------------------------------------------------------------

From this, it appears that you need to add a parameter to specify the node name for the server that you are trying to observe:

wsadmin.sh -f checkwas.py -i heapsize -n usculenwcs01d-node -s server1 -lang jython

By the way, if you are using WebSphere Application Server Version 7, the fact that the name of the script to be executed has an extension of .py will be understood by wsadmin that the language will be Jython, so that pair (i.e., "-lang jython") is optional.

Author

Commented:
no luck

[wasadmin@usculenwas06d jython]$ /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -f checkwas.py -i heapsize -n usculenwas06d-node -s WC_EN_LIVE_2  -lang jython
WASX7209I: Connected to process "dmgr" on node usculenwcs01d-dm-node using SOAP connector;  The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as argument that is stored in the argv variable: "[-i, heapsize, -n, usculenwas06d-node, -s, WC_EN_LIVE_2]"
check_was: Unknown node: usculenwas06d-node

check_was: Unknown server: WC_EN_LIVE_2

Author

Commented:
other server it gives

WASX7209I: Connected to process "dmgr" on node seiadsaps using SOAP connector;  The type of process is: DeploymentManager
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:331)
        at com.ibm.ws.bootstrap.WSLauncher.run(WSLauncher.java:219)
        at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.NoClassDefFoundError: org/python/core/PyException
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:141)
        at com.ibm.bsf.BSFManager.getLangFromFilename(Unknown Source)
        at com.ibm.ws.scripting.AbstractShell.executeScript(AbstractShell.java:834)
        at com.ibm.ws.scripting.AbstractShell.run(AbstractShell.java:1746)
        at com.ibm.ws.scripting.WasxShell.main(WasxShell.java:923)
HonorGodSoftware Engineer

Commented:
We must be running into something related to the Jython provided with WebSphere version 6.0...

Please copy the following into a file named findNode.py

Then execute the following:

/opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -conntype none -lang jython -profile findNode.py -c "print findNode( 'usculenwas06d-node' )"

and let me know the result.

Thanks
#---------------------------------------------------------------------
# Name: splitlines()
# Role: Replacement for the string.splitlines() routine that is broken
#       in V 6.0
#---------------------------------------------------------------------
def splitlines( str ) :
  return str.replace( '\r', '' ).split( '\n' )

#---------------------------------------------------------------------
# Name: findNode()
# Role: Try to find the specified nodeName
#---------------------------------------------------------------------
def findNode( nodeName ) :
  result = None
  for node in splitlines( AdminConfig.list( 'Node' ) ) :
    if AdminConfig.showAttribute( node, 'name' ) == nodeName :
      result = node
      break
  return result

Open in new window

Author

Commented:
Please find the outputs
[wasadmin@usculenwas06d jython]$ /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -conntype none -lang jython -profile -f findNode.py -c "print findNode( was06d-node' )"
WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.
WASX7013E: Cannot determine scripting language for file: "-f" -- please specify "-lang" option on the command line.
WASX7411W: Ignoring the following provided option: [findNode.py]
WASX7015E: Exception running command: "findNode( 'usculenwas06d-node' )"; exception information:
 com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<input>", line 1, in ?
NameError: findNode

[wasadmin@usculenwas06d jython]$ /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -conntype none -lang jython -profile findNode.py -c "print findNode( 'usculenwas06d-node' )"
WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.
WASX7011E: Cannot find file "findNode.py"
WASX7015E: Exception running command: "findNode( 'usculenwas06d-node' )"; exception information:
 com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<input>", line 1, in ?
NameError: findNode

HonorGodSoftware Engineer

Commented:
Where did you put the findNode.py?  In the current directory?

If not, you need to provide the full path to the findNode.py file, e.g., if findNode.py is in /temp/Jython/scripts, then the wsadmin command would look something like:

/opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -conntype none -lang jython -profile /temp/Jython/scripts/findNode.py -c "print findNode( 'usculenwas06d-node' )"

Open in new window

Author

Commented:
Please see this

[wasadmin@usculenwas06d scripts]$ pwd
/tmp/Jython/scripts
[wasadmin@usculenwas06d scripts]$ ls -rlt
total 4
-rwxrwxrwx 1 wasadmin was 738 Jun  8 13:53 findNode.py
[wasadmin@usculenwas06d scripts]$ /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -conntype none -lang jython -profile /temp/Jython/scripts/findNode.py -c "print findNode( 'usculenwas06d-node' )"
WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.
WASX7011E: Cannot find file "/temp/Jython/scripts/findNode.py"
WASX7015E: Exception running command: "findNode( 'usculenwas06d-node' )"; exception information:
 com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<input>", line 1, in ?
NameError: findNode

[wasadmin@usculenwas06d scripts]$ ls -lrt /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh
-rwxr-xr-x 1 wasadmin was 2619 May 19 16:58 /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh
[wasadmin@usculenwas06d scripts]$


HonorGodSoftware Engineer

Commented:
You first show that findNode.py can be found at:  

/tmp/Jython/scripts/findNode.py

But, you specify the location as

/temp/Jython/scripts/findNode.py

The command should be:


/opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -conntype none -lang jython -profile /tmp/Jython/scripts/findNode.py -c "print findNode( 'usculenwas06d-node' )"

Open in new window

Author

Commented:
OOps sorry

Here is the output

[wasadmin@usculenwas06d scripts]$ /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -conntype none -lang jython -profile /tmp/Jython/scripts/findNode.py -c "print findNode( 'usculenwas06d-node' )"
WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.
WASX7015E: Exception running command: "findNode( 'usculenwas06d-node' )"; exception information:
 com.ibm.websphere.management.exception.ConfigDataNotFoundException: ADMG0001E: Configuration data cells/endev-cell/nodes/usculenwas07d-node|node.xml is not found in document cells/endev-cell/nodes/usculenwas07d-node/node.xml.
HonorGodSoftware Engineer

Commented:
Ah, it would seem that we (i.e., you) have a configuration problem.

Is this with a development, or a production environment?
HonorGodSoftware Engineer

Commented:
by the way, what is the output of:

This will show us the "default" profile, which for a Deployment Manager environment should be the DM profile.
/opt/IBM/WebSphere/AppServer/bin/serverStatus.sh -all

Open in new window

Author

Commented:
[wasadmin@usculenwas06d bin]$ ./serverStatus.sh -all
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/LIVE/logs/serverStatus.log
ADMU0128I: Starting tool with the LIVE profile
ADMU0503I: Retrieving server status for all servers
ADMU0505I: Servers found in configuration:
ADMU0506I: Server name: WC_EN_LIVE_2
ADMU0506I: Server name: nodeagent
ADMU0508I: The Application Server "WC_EN_LIVE_2" is STARTED
ADMU0508I: The Node Agent "nodeagent" is STARTED
[wasadmin@usculenwas06d bin]$
Software Engineer
Commented:
whoa.  Your default profile is not that of your DM?

What happens if you try this?

Substitute the name of your deployment manager profile where you see <DmrgProfileName>
/opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -conntype none -lang jython -profileName <DmgrProfileName> -profile /tmp/Jython/scripts/findNode.py -c "print findNode( 'usculenwas06d-node' )"

Open in new window

Author

Commented:
hi
there is no output of this query
James MurrellProduct Specialist

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial