Script permettant de lister l'arborescence d'un WebSphere 6.1, 7 ou 8 de tout les composants démarrés.

L'exemple ci-dessous est executé sur un WebSphere 7.0.0.21.

  • Script arbor.sh de lancement du JYTHON pour un UNIX.

  • #!/bin/sh
    
    DMGR_HOST=arecibo
    DMGR_PORT=14160
    DMGR_USER=admwas
    DMGR_PASSWORD=DTCauFondAgauche
    WEBSPHERE_ROOT_PATH=/apps/WebSphere/profiles7/dmgr
    SCRIPTS_ROOT_PATH=/SCRIPTS/JYTHON
    
    export DMGR_HOST
    export DMGR_PORT
    export WEBSPHERE_ROOT_PATH
    export SCRIPTS_ROOT_PATH
    
    
    ## si l'environement n'est pas configurer correctement
    #$WEBSPHERE_ROOT_PATH/bin/wsadmin.sh -user $DMGR_USER -password $DMGR_PASSWORD  -lang jython -host $DMGR_HOST -port $DMGR_PORT -f $SCRIPTS_ROOT_PATH/arbor.py
    
    ## si l'environement est bien configuré
    $WEBSPHERE_ROOT_PATH/bin/wsadmin.sh -lang jython -f $SCRIPTS_ROOT_PATH/arbor.py
    

  • Script arbor.bat lancement du JYTHON pour un WINDOWS.

  • set DMGR_HOST=arecibo
    set DMGR_PORT=14160
    set WEBSPHERE_ROOT_PATH=D:\Websphere\profiles61\dmgr
    set MANAGE_ROOT_PATH=D:\SCRIPTS\JYTHON
    
    
    %WEBSPHERE_ROOT_PATH%\bin\wsadmin.bat  -user LOCAL_wasadmin -password wasadmin  -lang jython -host %DMGR_HOST% -port %DMGR_PORT% -f %MANAGE_ROOT_PATH%\arbor.py  
    
    @echo on
    :Usage
    echo "Mauvaise commande."
    

  • Execution du script sur un linux (root)

  • root@arecibo:/ # ./arbor.sh
    WASX7209I: Connected to process "dmgr" on node areciboManager using SOAP connector;  The type of process is: DeploymentManager
    
    #######################################################################################
    #  Cellule : areciboNetwork
    #  Node agent (DMGR) : areciboManager
    #  Nom du serveur (DMGR) : arecibo
    #  Version Websphere du (DMGR) : 7.0.0.21
    #  Os du serveur (DMGR) : J2EEServer
    #  Type du noeud (DMGR) : Server
    #  Nom du serveur (DMGR) : dmgr
    #  Node agent areciboManager (dmgr) : Server J2EEServer 7.0.0.21
    #######################################################################################
    
    
    arecibo (arecibo)
       |
       +--> appli-profde21-servlet_server (arecibo)
    root@arecibo:/ #
    

  • Script arbor.py

  • cells = AdminConfig.list("Cell").split(lineSeparator)
    #print "Number of cells: %s" % (len(cells))
    for cell in cells:
    	cname = AdminConfig.showAttribute(cell, "name")
    	sec = AdminConfig.list("Security", cell)
    	enabled = AdminConfig.showAttribute(sec, "enabled")
    	#print cname + "-- security enabled: " + enabled
    
    
    
    
    
    
    nodes = AdminConfig.list('Node')
    nodes1 = nodes.split(lineSeparator)
    
    
    
    print "  "
    print "#######################################################################################"
    wsadminNode = AdminControl.getNode()
    wsadminSvr = AdminControl.queryNames("node="+wsadminNode+",type=Server,*")
    wsadminSvrON = AdminControl.makeObjectName(wsadminSvr)
    wsadminVers = wsadminSvrON.getKeyProperty('version')
    wsadminTypeJava = wsadminSvrON.getKeyProperty('j2eeType')
    wsadminType = wsadminSvrON.getKeyProperty('type')
    wsadminName = wsadminSvrON.getKeyProperty('name')
    
    idnoeud = AdminConfig.getid("/Node:" + wsadminNode + "/")
    hostnamenoeud = AdminConfig.showAttribute(idnoeud, 'hostName')
    
    print "#  Cellule : " + cname 
    print "#  Node agent (DMGR) : " + wsadminNode 
    print "#  Nom du serveur (DMGR) : " + hostnamenoeud 
    print "#  Version Websphere du (DMGR) : " + wsadminVers
    print "#  Os du serveur (DMGR) : " + wsadminTypeJava
    print "#  Type du noeud (DMGR) : " + wsadminType
    print "#  Nom du serveur (DMGR) : " + wsadminName
    print "#  Node agent " + wsadminNode + " (" + wsadminName + ") : " + wsadminType + " " + wsadminTypeJava + " " + wsadminVers  
    print "#######################################################################################"
    print "  "
    
    
    
    
    for node in nodes1:
            node_name = AdminConfig.showAttribute(node, 'name')
            servers = AdminConfig.list('Server', node)
    	idnoeud = AdminConfig.getid("/Node:" + node_name + "/") 
    	hostnamenoeud = AdminConfig.showAttribute(idnoeud, 'hostName')
    	if node_name != wsadminNode:
    		print "     "
    		print node_name + " (" + hostnamenoeud + ")" 
            servers1 = servers.split(lineSeparator)
            for server in servers1:
                    serv_name = AdminConfig.showAttribute(server, 'name')
                    serv_type = AdminConfig.showAttribute(server, 'serverType')
    		if serv_type == 'APPLICATION_SERVER':	
    			print "   |" 
    			print "   +--> " + serv_name + " (" + node_name + ") " 
    			serverId = AdminConfig.getid("/Server:" + serv_name + "/")
    			s1pdefs = AdminConfig.list('JavaProcessDef', serverId).split("\n")
    
    			apps = AdminControl.queryNames("type=Application,cell=" + cname + ",node=" + node_name + ",process=" + serv_name + ",*")
    			appsList = apps.split(lineSeparator)
    			for app in appsList:
    				if len(app) != 0:	
                      			aname = AdminControl.getAttribute(app, "name")
                      			print "   |          +--> %s" % (aname)
    
    
    			#print s1pdefs
    			for pid in s1pdefs:
    				process = AdminConfig.showAttribute(pid, 'processType') 
    				#print process
    				if AdminConfig.showAttribute(pid, 'processType') == 'Servant':
    					jvms = AdminConfig.list('JavaVirtualMachine', pid).split("\n")
    					#print jvms