Exporting the schema script using wsadmin
You can export the create schema script for a monitor model and run the script at a later time. You can use wsadmin to export the scripts by running a Jython or Jacl script. The example in this topic uses Jython.
About this task
Procedure
- Open a command prompt, and change directories to the Monitor_Profile_Home/bin.
- Type the following command: wsadmin -lang jython -wsadmin_classpath WAS_home/plugins/com.ibm.wbimonitor.lifecycle.spi.jar -f path_to_export_script
Example
The following sample script shows how to export the create schema script to a file.
#
# Export the create schema script for a monitor model
#
from java.lang import String
from java.io import FileWriter
from com.ibm.wbimonitor.lifecycle.spi import LifecycleVersionDate
from com.ibm.wbimonitor.lifecycle.spi.mbeans import LifecycleServicesMBeanFactory
print AdminControl.trace( 'com.ibm.wbimonitor.*=all=enabled' )
# get the MBean
ls_mbean = LifecycleServicesMBeanFactory.getMBean( AdminControl.getAdminClient() )
print 'LifecycleServicesMBean.getMonitorVersion=' + ls_mbean.getMonitorVersion()
# specify the model ID and version
modelID = 'Vacation_Process_Modeler_WPS_E2E_Project_Processes_v1'
versionDate = LifecycleVersionDate.parse( '2009-08-25T22:33:11' )
# specify the output file for the script
exportFile = "C:/Temp/createSchema.ddl"
# get the schema script
schemaScript = ls_mbean.getCreateSchemaScript( modelID, versionDate )
if schemaScript == None:
print 'Schema script is null'
sys.exit()
schemaScriptStr = String(schemaScript)
# write the schema script
out = FileWriter(exportFile);
out.write(schemaScriptStr);
out.flush();
out.close();