Reputation: 385
Is there any way to stop webserver on particular node using wsadmin? Using
print AdminConfig.list('WebServer')
I got the list of all webservers with coresponding nodes
webserver1(cells/dmgrCell01/nodes/01Node01/servers/webserver1|server.xml#WebServer_0000000000)
webserver2(cells/dmgrCell01/nodes/01Node02/servers/webserver2|server.xml#WebServer_1111111111)
webserver3(cells/dmgrCell01/nodes/01Node03/servers/webserver3|server.xml#WebServer_2222222222)
According to IBM I need to define variable this way:
na = AdminControl.queryNames('type=NodeAgent,node=mynode,*')
so using type WebServer:
webserver = AdminControl.queryNames('type=WebServer,node=mynode,*')
but I got empty value
How to build this query?
Upvotes: 2
Views: 221
Reputation: 617
To stop a server you need to invoke
the stop command passing the correct MBean.
If AdminControl.queryNames(...)
returns an empty string it means that the MBean cannot be found using the AdminControl
module (which manages only the running resources).
This could be caused by 2 major reasons:
Try to build your query like this, then let me know:
server = AdminControl.queryNames('WebSphere:cell=myCell,node=myNode,name=myServer,type=WebServer,*')
# Empty string ==> Server stopped
if server:
AdminControl.invoke(server, 'stop')
If you have the configuration ID of the resource, you can use the AdminConfig.getObjectName(...)
to retrieve the running MBean corresponding to the resource configuration ID:
# Get the configuration id from the configuration path
configuration_id = AdminConfig.getid("/Cell:myCell/WebServer:myServer/")
server = AdminConfig.getObjectName(configuration_id)
# Empty string ==> Server stopped
if server:
AdminControl.invoke(server, 'stop')
Upvotes: 1
Reputation: 629
Let's say you have deployed the webserver1 on Node01, you can run the following query command at wsadmin command prompt and test it.
webserver=AdminControl.queryNames("node="+AdminControl.getNode( )+",type=WebServer,*" )
once the above command executes, it will store the result into the variable webserer
. To check the content of the variable you can simply use webserver
and hit enter, that's it ! it will show you the MBean content.
Upvotes: 0