Red Hat Training

A Red Hat training course is available for Red Hat JBoss Operations Network

22.2. Changing Server Configuration Before Importing

Metrics schedules and server configuration are applied through synchronizers. Synchronizers control what elements are imported into the JBoss ON server and how to apply them to the server. The synchronizer has a default template which applies configuration changes to every import operation.
The synchronizer configuration can be changed to change what settings are imported into the target server.
The first part of the script would export the XML archive, as before.
//log into the first server
rhq.login('rhqadmin','rhqadmin','server1.example.com','7080');

//export the settings
var ex = SynchronizationManager.exportAllSubsystems();
rhqadmin@localhost:7080$ saveBytesToFile(ex.exportFile, 'export.xml.gz');

// log out of the first server
rhq.logout()
The XML file contains the full configuration information, so just checking that file can give you an idea of what settings to change.
On the second server, change the synchronizer settings.
  1. Get the default definition.
    rhqadmin@localhost:7080$ var systemSettingsImportConfigurationDefinition = SynchronizationManager.getImportConfigurationDefinition('org.rhq.enterprise.server.sync.SystemSettingsSynchronizer')
  2. Create a new configuration instance.
    rhqadmin@localhost:7080$ var configurationObject = systemSettingsImportConfigurationDefinition.configurationDefinition.defaultTemplate.createConfiguration()
    
    rhqadmin@localhost:7080$ var systemSettingsImportConfiguration = new ImportConfiguration(systemSettingsImportConfigurationDefinition.synchronizerClassName, configurationObject)
  3. Change the settings.
    For example, this edits the server synchronizer so that it imports only the database settings for storing monitoring data.
    rhqadmin@localhost:7080$ configurationObject.getSimple('propertiesToImport').setValue('CAM_DATA_PURGE_1H, CAM_DATA_PURGE_6H, CAM_DATA_PURGE_1D, CAM_DATA_MAINTENANCE')
    For the metrics template synchronizer, define which metric schedules to import per resource type, based on a properties list or a properties map. For example:
    rhqadmin@localhost:7080$ configurationObject.getSimple('updateAllSchedules').setBooleanValue(true)
    rhqadmin@localhost:7080$ var updateList = new PropertyList('metricUpdateOverrides')
    rhqadmin@localhost:7080$ var update = new PropertyMap('metricUpdateOverride')
    rhqadmin@localhost:7080$ update.put(new PropertySimple('metricName', 'MCBean|ServerInfo|*|freeMemory'))
    rhqadmin@localhost:7080$ update.put(new PropertySimple('resourceTypeName', 'JBossAS Server'))
    rhqadmin@localhost:7080$ update.put(new PropertySimple('resourceTypePlugin', 'JBossAS5'))
    rhqadmin@localhost:7080$ update.put(new PropertySimple('updateSchedules', 'true'))
    
    rhqadmin@localhost:7080$ updateList.add(update)
    
    rhqadmin@localhost:7080$ configurationObject.put(updateList)
After changing the synchronizer settings, then import the configuration.
rhqadmin@localhost:7080$ var configsToImport = new java.util.ArrayList()
rhqadmin@localhost:7080$ configsToImport.add(systemSettingsImportConfiguration);
rhqadmin@localhost:7080$ configsToImport.add(metricTemplatesImportConfiguration);
rhqadmin@localhost:7080$ SynchronizationManager.importAllSubsystems(ex, configToImport);