AdminContol and AdminConfig are two key scripting objects that any WAS administrator must know by heart.
The objects are available from wsadmin WAS administration tool.
AdminConfig provides an interface to the WAS configuration repository available under profile_root/config. All AdminConfig services are provided by the Deployment Manager (assuming you're connecting remotely); there is no dependency on node agents.
AdminControl provides an interface to JMX managed beans (MBeans) in your WAS environment. In general, MBeans are only available for the resources that are running. For example, if an application server is down, the corresponding MBean will not be available.
AdminConfig and AdminContol could complement each other nicely, especially when you need to find out the status of "things" in a WAS cell. To illustrate the point, here is a simple script that prints the status of all application servers within a cell:
""" List all application servers in a cell and print their status (up or down) """ # Get the string with config ids of all serves server_confids=AdminConfig.list("Server") #Iterate over all servers - config ids are separated by \n for server_confid in server_confids.split("\n"): server_confid=server_confid.strip() # obtain the type - types are APPLICATION_SERVER, DEPLOYMENT_MANAGER, NODE_AGENT, WEB_SERVER server_type=AdminConfig.showAttribute(server_confid, "serverType") # we are only interested in application servers if server_type == "APPLICATION_SERVER": # obtain the name of the server server_name=AdminConfig.showAttribute(server_confid, "name") print "Checking the state of the server %s of type %s" % (server_name, server_type) #Now we can try to get the mbean of the server. We could've used AdminConfig.getObjectName() as #a shortcut, but for the sake of the example we'll use AdminControl explicitly # Query to search for mbeans - note the wildcard at the end to match the rest of mbean parameters # Note that we're simplifying a little bit since we're ignoring node names - # server names may not be unique within cell server_query="type=Server,name=%s,*" % server_name server_mbean=AdminControl.queryNames( server_query ) # AdminContol returns None if there is no running mbean for this server if server_mbean: print "Server is up" else: print "Server is down!"
This post is part of the series on WebSphere Application Server administration. Please subscribe to this blog if you'd like to receive updates.
– Some AdminTask methods also interact with the configuration, and some with MBeans
– Since AdminConfig deals, almost exclusively, with the configuration, it is available in “local mode” (i.e., when “-conntype none” is specified as a wsadmin command line option)
Oh yeah, if a nodeagent is “stopped” or unresponsive, not of its managed nodes can be contacted/manipulated using MBeans.