https://blogs.perficient.com/2016/03/08/jump-start-wsadmin-scripting-using-jython/
https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/rxml_admincontrol.html
Was Admin tool supports two scripting languages
Jacl
Jython
Five objects are available when you use scripts
Admincontrol : Use to run operational commands
AdminConfig : Use to run configurational commands to create or modify WebSphere Application Server Configurational elements
AdminApp : Use to administer applications
AdminTask: Use to run administrative commands
Help: Use to Obtain general help
The scripts use these objects to communicate with MBeans that run in WebSphere Application Server processes. MBeans are Java™ objects that represent Java Management Extensions (JMX) resources. JMX is an optional package addition to Java 2 Platform Standard Edition (J2SE). JMX is a technology that provides a simple and standard way to manage Java objects.
Apart from the five we have different object options like
AdminClusterManagement
AdminNodeManagement
AdminApplication
Wasserver restart srcript
http://kerolasa.github.io/was/index.html
http://www.mtitek.com/tutorials/websphere/wsadmin_jython.php#sec_id_6
https://blogs.perficient.com/2016/03/08/jump-start-wsadmin-scripting-using-jython/
https://bugs.jython.org/issue1792
**********************************************************
/opt/WebSphere/AppServer/profiles/Custom01/bin/wsadmin.sh -l jython
print AdminTask.help()
print AdminConfig.help()
print AdminTask.help('-commands')
print AdminApp.help('uninstall')
https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/rxml_taskoptions.html#rxml_taskoptions__cmd61
BPM
https://www.ibm.com/support/knowledgecenter/SS8JB4_19.x/com.ibm.wbpm.ref.doc/topics/rwesb_modifySCAImportWSBinding.html
*************************************************************************
To get the command assistance then need to do the following
- Enable "log command assistance commands" and "Enable command assistance notifications"
System administration --> Console Preferences -->
Enable Command assistance notifications and
Log command assistance commands
- App needs to be deployed manually
- Restart the servers
- Confirm the applications are working
to stop and start the DMGR
/opt/Webspehere/AppServer/profiles/Dmgr01/bin/stopManager.sh
/opt/Webspehere/AppServer/profiles/Dmgr01/bin/startManager.sh
Log location for the commands
Path : /opt/Websphere/AppServer/profiles/Dmgr01/logs/dmgr/
Filename : commandAssistanceJythonCommands_username.log
https://xebia.com/blog/websphere-scripting-with-wsadmin-containment-paths-configuration-ids-and-object-names/
******************************************************************************
Environment
AdminConfig.create('Property', '(cells/D-A-WND51Cell01/nodes/D-A-WAS51Node01/servers/uitserver1|server.xml#JavaVirtualMachine_1573168132392)', '[[validationExpression ""] [name "gov.nv.dwss.nvkids.config.file"] [description ""] [value "/
opt/nvkidsconfig/uit_app.properties"] [required "false"]]')
AdminConfig.save()
Implicit Bean property setting
AdminConfig.create('Property', '(cells/D-A-WND51Cell01/nodes/D-A-WAS51Node01/servers/uitserver1|server.xml#JavaVirtualMachine_1573168132392)', '[[validationExpression ""] [name "com.ibm.ws.cdi.enableImplicitBeanArchives"] [descript
ion ""] [value "false"] [required "false"]]')
AdminConfig.save()
JVM settings
AdminTask.setJVMProperties('[-nodeName D-A-WAS52Node01 -serverName nodeagent -classpath "" -bootClasspath "" -verboseModeClass false -verboseModeGarbageCollection true -verboseModeJNI false -initialHeapSize 2048 -maximumHeapSize 2048 -ru
nHProf false -hprofArguments -debugMode false -debugArgs "-Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777" -executableJarFileName -genericJvmArguments "-Djava.awt.headless=true" -dis
ableJIT false]')
AdminConfig.save()
JDBC Provider
AdminTask.createJDBCProvider('[-scope Cluster=trg-cluster -databaseType DB2 -providerType "DB2 Universal JDBC Driver Provider" -implementationType "Connection pool data source" -name "DB2 Universal JDBC Driver Provider" -description "One
-phase commit DB2 JCC provider that supports JDBC 3.0. Data sources that use this provider support only 1-phase commit processing, unless you use driver type 2 with the application server for z/OS. If you use the application server for z
/OS, driver type 2 uses RRS and supports 2-phase commit processing." -classpath [${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar ${UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar ]
-nativePath [${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH} ] ]')
AdminConfig.save()
Datasource
AdminTask.createDatasource('"DB2 Universal JDBC Driver Provider(cells/D-A-WND51Cell01/clusters/trg-cluster|resources.xml#JDBCProvider_1585776307324)"', '[-name nvkids_devservice -jndiName jdbc/nvkids_devservice -dataStoreHelperClassName com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper -containerManagedPersistence true -componentManagedAuthenticationAlias D-A-WND51CellManager01/dev_appuser -configureResourceProperties [[databaseName java.lang.String NVDEV01] [driverType java.lang.Integer 4] [serverName java.lang.String 10.147.5.31] [portNumber java.lang.Integer 50001]]]')
AdminConfig.save()
To associate the username and password
AdminConfig.modify('(cells/D-A-WND51Cell01/clusters/uit-cluster|resources.xml#DataSource_1583366517934)', '[[name "nvkids_devservice"] [authDataAlias "D-A-WND51CellManager01/dev_appuser"] [datasourceHelperClassname "com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper"] [description "DB2 JCC data source using the IBM Data Server Driver for JDBC and SQLJ. IBM Data Server Driver is the next generation of the DB2 Universal JCC driver. This data source type is configurable in version 7.0 and later nodes."] [category ""] [jndiName "jdbc/nvkids_devservice"]]')
To update the application
AdminApp.update('DefaultApplication.ear', 'app', '[ -operation update -contents /opt/IBM/WebSphere905/AppServer/installableApps/DefaultApplication.ear -nopreCompileJSPs -installed.ear.destination $(APP_INSTALL_ROOT)/was90cell -distributeApp -nouseMetaDataFromBinary -nodeployejb -createMBeansForResources -noreloadEnabled -nodeployws -validateinstall warn -noprocessEmbeddedConfig -filepermission .*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755 -noallowDispatchRemoteInclude -noallowServiceRemoteInclude -asyncRequestDispatchType DISABLED -nouseAutoLink -noenableClientModule -clientMode isolated -novalidateSchema -MapModulesToServers [[ "Default Web Application" DefaultWebApplication.war,WEB-INF/web.xml WebSphere:cell=was90cell,cluster=testCluster+WebSphere:cell=was90cell,node=was90node01,server=webserver1 ]]]' )
To set schema and currentFunctionPath
AdminConfig.modify('(cells/D-A-WND51Cell01/clusters/sit-cluster|resources.xml#J2EEResourceProperty_1597320001204)', '[[name "currentSchema"] [type "java.lang.String"] [description "Identifies the default schema name used to qualify unqualified database object references where applicable in dynamically prepared SQL statements. Unless currentSchema is used, the default schema name is the authorization id of the current session user."] [value "NVKIDS"] [required "false"]]')
Adminconfig.save()
AdminConfig.modify('(cells/D-A-WND51Cell01/clusters/sit-cluster|resources.xml#J2EEResourceProperty_1597320001200)', '[[name "currentFunctionPath"] [type "java.lang.String"] [description "Specifies the value for the CURRENT FUNCTION PATH special register of the DB2 server."] [value "SYSIBM,SYSFUN,SYSPROC,SYSIBMADM,NVKIDS"] [required "false"]]')
Adminconfig.save()
To stop cluster
AdminControl.invoke('WebSphere:name=sit-cluster,process=dmgr,platform=common,node=D-A-WND51CellManager01,version=9.0.0.11,type=Cluster,mbeanIdentifier=sit-cluster,cell=D-A-WND51Cell01,spec=1.0', 'stop')
Application stop
If we want to stop 8 application then we need to form 16 statements when we have 2 servers
AdminControl.invoke('WebSphere:name=ApplicationManager,process=sitserver1,platform=proxy,node=D-A-WAS51Node01,version=9.0.0.11,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=D-A-WND51Cell01,spec=1.0', 'stopApplication', '[sit-caseinitiation-api-ear]')
AdminControl.invoke('WebSphere:name=ApplicationManager,process=sitserver2,platform=proxy,node=D-A-WAS52Node01,version=9.0.0.11,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=D-A-WND51Cell01,spec=1.0', 'stopApplication', '[sit-caseinitiation-api-ear]')
Application start
If we want to start application then we need to form 16 statements when we have 2 servers
ON Node1
AdminControl.invoke('WebSphere:name=ApplicationManager,process=devserver1,platform=proxy,node=D-A-WAS51Node01,version=9.0.0.11,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=D-A-WND51Cell01,spec=1.0', 'startApplication',
'[nvkids-customer-0_0_1_war]')
On Node2
AdminControl.invoke('WebSphere:name=ApplicationManager,process=devserver2,platform=proxy,node=D-A-WAS52Node01,version=9.0.0.11,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=D-A-WND51Cell01,spec=1.0', 'startApplication',
'[nvkids-customer-0_0_1_war]')
Ripple start the servers
AdminControl.invoke('WebSphere:name=sit-cluster,process=dmgr,platform=common,node=D-A-WND51CellManager01,version=9.0.0.11,type=Cluster,mbeanIdentifier=sit-cluster,cell=D-A-WND51Cell01,spec=1.0', 'rippleStart')
Shared library
nvkidssharedlibrary
AdminConfig.create('Library', AdminConfig.getid('/Cell:D-A-WND51Cell01/ServerCluster:dev-cluster/'), '[[nativePath "/opt/nvkidssharedlibrary/dev/apilibrary/"] [name "nvkidsapilibrary"] [isolatedClassLoader false] [description "Shared library is used for easeofuse-api, childsupport-api, casemangement-api, locate-api, fincancial-api "] [classPath "/opt/nvkidssharedlibrary/dev/apilibrary/"]]')
AdminConfig.save()
nvkidseurekalibrary
AdminConfig.create('Library', AdminConfig.getid('/Cell:D-A-WND51Cell01/ServerCluster:dev-cluster/'), '[[nativePath "/opt/nvkidssharedlibrary/dev/eurekalibrary/"] [name "nvkidseurekalibrary"] [isolatedClassLoader false] [description "Shared library used for Server-discovery"] [classPath "/opt/nvkidssharedlibrary/dev/eurekalibrary/"]]')
AdminConfig.save()
nvkidszuullibrary
AdminConfig.create('Library', AdminConfig.getid('/Cell:D-A-WND51Cell01/ServerCluster:dev-cluster/'), '[[nativePath "/opt/nvkidssharedlibrary/dev/zuullibrary/"] [name "nvkidszuullibrary"] [isolatedClassLoader false] [description "Shared library is used for Server proxy"] [classPath "/opt/nvkidssharedlibrary/dev/zuullibrary/"]]')
AdminConfig.save()
****************************************************
To list the cells present in WASServer
AdminConfig.list("Cell")
AdminControl.getCell()
To list the Nodes in WASServer
AdminTask.listNodes()
To list the Application Server in WASServer
AdminTask.listServers('[-serverType APPLICATION_SERVER ]')
To list ServerCluster in WASServer
AdminConfig.list('ServerCluster', AdminConfig.getid( '/Cell:NV-DEVWASNDCell01/'))
AdminConfig.list("ServerCluster")
********************************************
AdminConfig.help('list') --> to know parameters of list
AdminConfig.types() --> Different types
************************************
To increase the SOAP time out (when deploying 11 ears we are getting this error to avoid it use the below option to increase the timeout from 3 mins to 1 hour
java.net.SocketTimeoutException: Read timed out error occurs if soap timeout value is not enough to complete the deployment activity. By default it is 180 seconds (i.e 3 mins). I would suggest to increase this value to 3600 seconds (i.e 1 hour) then execute the script and see if that helps. This value should be increased in soap.client.props file for property com.ibm.SOAP.requestTimeout, it is located under WAS_HOME/profiles/dmgr_profile/properties directory. If not, please capture same set of data and provide us. We did not receive wsadmin.traceout file located under WAS_HOME/profiles/dmgr/logs
***********************************
To analyzae the java heap
https://www.ibm.com/support/pages/java-core-debugging-using-ibm-thread-and-monitor-dump-analyzer-java
**************************************
https://www.ibm.com/docs/en/was/9.0.5?topic=scripting-updating-installed-applications-using-wsadmin-tool
find . -xdev -type f -ls | sort -nrk7 | head -100
wstemp/ and temp/ on DMGR profile delete
***********************************************************
to connect to the wsadmin script
/opt/IBM/WebSphere/AppServer/profiles/DMG01/bin/wsadmin.sh -l jython
To list the clusters on the was server
print (AdminConfig.list("ServerCluster"))
or
print AdminClusterManagement.listClusters()
To list the application on the WAS server
print AdminApp.list()
To uninstall application on WAS server
AdminApp.uninstall('sbx-supporting-api-ear')
AdminConfig.save()
to Stop Cluster use the below command
AdminClusterManagement.stopSingleCluster("NVKidsCluster")
to start Cluster use the below command
AdminClusterManagement.startSingleCluster("NVKidsCluster")
to know the status of the cluster
cluster=AdminControl.completeObjectName('cell=DMG01Cell,type=Cluster,name=NVKidsCluster,*')
AdminControl.getAttribute(cluster,'state')
To stop all clusters on the server
AdminClusterManagement.stopAllClusters()
to start all clusters on the server
AdminClusterManagement.startAllClusters()
to stop specific application under the cluster use the below
AdminApplication.stopApplicationOnCluster('prd-easeofuse-api-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-caseinitiation-api-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-casemanagement-api-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-childsupport-api-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-enforcement-api-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-establishment-api-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-financial-api-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-locate-api-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-server-proxy-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-supporting-api-ear','NVKidsCluster')
AdminApplication.stopApplicationOnCluster('prd-server-discovery-ear','NVKidsCluster')
To start specific application under the cluster use the below
AdminApplication.startApplicationOnCluster('prd-server-discovery-ear','NVKidsCluster')
AdminApplication.startApplicationOnCluster('prd-easeofuse-api-ear','NVKidsCluster')