Red Hat Training

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

22.2. インポート前のサーバー設定の変更

メトリクススケジュールとサーバー設定は、同期を使用して適用さ ます。Synchronizers は JBoss ON サーバーにインポートされる要素と、それらをサーバーに適用する方法を制御します。同期には、すべてのインポート操作に設定変更を適用するデフォルトテンプレートがあります。
同期ャの設定を変更して、ターゲットサーバーにインポートされる設定を変更できます。
スクリプトの最初の部分は、以前と同様に XML アーカイブをエクスポートします。
//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()
XML ファイルには設定情報がすべて含まれているため、ファイルを確認するだけで、変更する設定がわかります。
2 つ目のサーバーで、同期機能の設定を変更します。
  1. デフォルトの定義を取得します。
    rhqadmin@localhost:7080$ var systemSettingsImportConfigurationDefinition = SynchronizationManager.getImportConfigurationDefinition('org.rhq.enterprise.server.sync.SystemSettingsSynchronizer')
  2. 新しい設定インスタンスを作成します。
    rhqadmin@localhost:7080$ var configurationObject = systemSettingsImportConfigurationDefinition.configurationDefinition.defaultTemplate.createConfiguration()
    
    rhqadmin@localhost:7080$ var systemSettingsImportConfiguration = new ImportConfiguration(systemSettingsImportConfigurationDefinition.synchronizerClassName, configurationObject)
  3. 設定を変更します。
    たとえば、これによりサーバー同期が編集され、監視データを格納するためのデータベース設定のみがインポートされます。
    rhqadmin@localhost:7080$ configurationObject.getSimple('propertiesToImport').setValue('CAM_DATA_PURGE_1H, CAM_DATA_PURGE_6H, CAM_DATA_PURGE_1D, CAM_DATA_MAINTENANCE')
    メトリクステンプレート同期の場合、プロパティーリストまたはプロパティーマップに基づいて、リソースタイプごとにインポートするメトリクススケジュールを定義します。例:
    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)
同期機能の設定を変更したら、設定をインポートします。
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);