3

Please find the below code

runningServer1 = AdminControl.completeObjectName("type=Server,node=nodename,process=processname,*")
print "server running --->",runningServer1
if len(runningServer1) == 0:

    print "Error: Server not running...",process_name

The ouput is that the

"Error : Server not running..."

though my server is running and I am able to launch the application. And also the runningServer1 variable is not printed , why is it that I am unable to get an object for the server?

More information about my question which I posted in IBM forums below

https://www.ibm.com/developerworks/forums/thread.jspa?threadID=374216

Cœur
  • 37,241
  • 25
  • 195
  • 267
crackerplace
  • 5,305
  • 8
  • 34
  • 42
  • 1
    Are the node and process names right? What is returned by queryNames("type=Server,*")? Are you running base or ND? – Brett Kail Jun 16 '11 at 22:16
  • @bkail I am a newbie to python and I think we dont have a node agent and hence its as standalone server.Also I got to know that We cannot start or stop through jython scripts if ther is no node agent.But What I dint understand is that Wy the server shows as not running even though everythngs right . – crackerplace Jun 20 '11 at 06:22
  • I am able to launch the Apps.The only running server as hsown is server1 which is the default one. – crackerplace Jun 20 '11 at 07:07

1 Answers1

1

bkail is on the right track. You need to make sure your search string is correct. Use:

print AdminControl.queryNames('type=Server,*')

in an interactive wsadmin.sh session to list all of the running servers in your cell. Then use:

'type=Server,name=JVM_NAME,*'

for your search string. Where JVM_NAME is determined from the ouput from the queryNames you just ran.

Also, I'd avoid AdminControl.completeObjectName. I'm not sure of the implications, but this snippet from the doc leads me to think it may not do what you think it does:

Use the completeObjectName command to create a string representation of a complete ObjectName value that is based on a fragment. This command does not communicate with the server to find a matching ObjectName value. If the system finds several MBeans that match the fragment, the command returns the first one.

Here's how IBM does it in WAS_ROOT/scriptLibraries/servers/V70/AdminServerManagement.py (lines 814-815):

runningServer = AdminControl.queryNames("type=Server,node="+nodeName+",name="+serverName+",*")
if (len(runningServer) > 0 and AdminControl.getAttribute(runningServer, "state") == "STARTED"):
    ...

In my experience, AdminControl.queryNames will only return running servers. So, depending on your needs just checking the return value of len(runningServer) may be sufficient. Also, in true IBM fashion there is nothing in the docs that list the possible return values of AdminControl.getAttribute(runningServer, "state"). I've only been able to find references to 'STARTED'.

che2cbs
  • 369
  • 1
  • 4
  • STOPPING is probably the only other useful state (perhaps not to query directly, but you could receive it if registered as a notification listener). – Brett Kail Jun 18 '11 at 13:31
  • @che2cbs please find my question which I posted here https://www.ibm.com/developerworks/forums/thread.jspa?threadID=374216 You will understand the whole issue..... – crackerplace Jun 20 '11 at 07:23
  • @whokares: I'm not sure I understand the whole issue. Your code works fine in my setup. Follow bkail's advice and verify the object string. – che2cbs Jun 20 '11 at 14:14
  • @che2cbs ..The point is that the same code works fine in my system tooo .. the output is that the running server is server1.But in my box we have even other jvms configured for our application and they dont have any node agent.We use the command ./startServer.sh servername to start the respective jvm.These servers are not listed as running.I dont know why.Might be it has sthng to do with the configuration .. i think ours is a base configuration of was6 server... – crackerplace Jun 21 '11 at 05:50
  • @che2cbs When i do the queryName(type ='server'),the output is just the server1 ... which is the default standalone server – crackerplace Jun 21 '11 at 06:01
  • @whokares: I think I know what's going on, but I need a bit more info. Are all of your servers running under the same node? Ie, are they all under the same profile directory? If so, are your missing servers listed under Servers->Server Types->Generic Servers in the WAS Admin Console? – che2cbs Jun 21 '11 at 17:56
  • @che2cbs yaaa .. all servers are running under same node and same profile ... And I almost got the reason ...Whwn I use ./wsadmin.sh -user user - password pwd ..its connecting to server1 by default and hence only server1 is listed when i execute the script.As I mentioned our servers are standalone servers .. and to answer ur point ..yes all my servers are listed in admin console .. the ibm thread in my question has the answers incase u need furthr info .. – crackerplace Jun 22 '11 at 06:40
  • @whokares: after reading your devworks thread I think I understand where you're coming from. You should seriously consider configuring a node agent and running your standalone JVMs as generic servers. This will at least give you access to some of the management capabilities inside WAS. – che2cbs Jun 22 '11 at 13:28