logo

NJP

Instance Synchronizer

Import · Jun 13, 2024 · article
  • "job" attribute definition
    /////////////////////////////////////////////////////////////////////////////////////////////////////////// // DEFAULT SETTINGS START --> can be overwritten in table specific configuration /////////////////////////////////////////////////////////////////////////////////////////////////////////// bLog: (Optional) Default: false, will add additional logs depending on sLogLevel defined. bTableAutoExtend: (Optional) Default: false, if true will automatically create jobs for each table extending the initial table. Please note that all tables share the same "job" configuration as the initial table. bForceClassQuery: (Optional) Default: false, if true will force strict class query even if on the target the table is not extended (but on the source there are extended tables) bRunIREAgainAfterInsert: false, (Optional), if set to true will run IRE again after insert to populate Multisource CMDB if bKeepSysId and bUseIRE are true, because IRE does not allow to keep the sysid so the script will automatically use regular insert. bDeltaLoad: (Optional) Default: false, if true will add the delta timestamp query from the last job start time bDeltaCompareAttachment: (Optional) Default: false, if true will add a hidden JSON attachment to each record and use the hash to detect changes iDeltaLoadOverlapSeconds: -2, (Optional) Default: -1, seconds where the last load and the new load overlap to take into account database lags when writing (default: -1) bUseDeltaLoadQuery: false, (Optional) Default: false, if true will use sDeltaLoadQuery instead of sQuery during delta load. This is for specific usecases, where you want the same config "in reverse" to catch updates to the state that you exclude. sDeltaLoadQuery: '', (Optional), Default: empty, used in combination with bUseDeltaLoadQuery to provide an alternative query, for example for update only changes sDeltaLoadStartTime: yyyy-MM-dd HH:mm:ss, (Optional), if set will use this time in the initial load as the delta load start time (format is mandatory, will use the system user timezone). aDeltaCompareRemoveFields: ['sys_updated_by', 'sys_updated_on', 'sys_mod_count'], (Optional) Default: [], will remove the fields from the JSON when using bDeltaCompareAttachment sDeltaCompareFileNamePrefix: 'instsync', (Optional, Default: 'instsync', if set will take this as the prefix for the hidden attachment file name sQuery: '', (Optional), default query to be applied against each table to fetch the records aDynamicQuery: [ (Optional), Setting a dynamic is recommened only for initial loads. It ignores the sQuery, iChunkSize, oClassMap, bDeltaLoad, bTableAutoExtend etc. parameters { sTargetType: 'remote', local or remote sTargetTableName: 'table_name', table to query sTargetQuery: 'query_to_be_applied', query to be applied to the table sSourceIdField: 'aggregate_field', field that contains the sys_id of the record to be transferred }, ] aQuerySysIds: ['sys_id_1', 'sys_id_2'], (Optional), same as sQuery "sys_idINsys_id1,sys_id2 but using the dynamic mechanism and storing the condition on the chunk (not the table). iChunkSize: 2000, (Optional)Default: 2000, chunk size to be applied for the rest call iMaxClassSize: 10, (Optional), Default: empty, if set will only take this number of records per table/class bCalculateOnly: true, (Optional), Default: false, if true will set the chunks to completed so they are not actually executed bLogErrorDetails: true, (Optional) Default = false: will log the error details in the error map table bAttachTableJobJSONConfig: false, (Optional) Default: false, will add a JSON attachment with the job config for each table when the table is created bAttachChunkRecordJSONConfig: false, (Optional) Default: false, will add a JSON attachment with the record config for each chunk at runtime of the chunk sync bAttachChunkJobJSONConfig: false, (Optional) Default: false, will add a JSON attachment with the record config for each chunk at runtime of the chunk sync /////////////////////////////////////////////////////////////////////////////////////////////////////////// // MAIN SETTINGS START --> cannot be overwritten in table specific configuration /////////////////////////////////////////////////////////////////////////////////////////////////////////// aTables: ['table_one', 'table_two'], // The tables to be copied. If bTableAutoExtend is true, will take ALL the tables that extend this table (whole hierarchy), so for example you can just specify "aTables: ['cmdb_ci']," and "bTableAutoExtend: true", to copy the whole CMDB. The script will automatically break down the tables in the Job Log Tables so that they are copied individually respecting all the valid fields per table. sTableJSONPrefix: 'TestCMDBSync_', // Optional, default Initial JSON Name, _ as delimiter is automatically added if required. iPriorityDefault: 300, // default priority if no specific priority is defined (default: 1000, max: 100'000) oPriorityClasses: { 25: ['core_company'], 50: ['cmdb_model'], 100: ['cmdb_ci_cluster', 'cmdb_ci_computer'], // computers and extended classes are referenced in other classes, clusters before cluster nodes 200: ['cmdb_ci_apache_web_server', 'cmdb_ci_app_server_jboss',], // principal classes // 300: this is the default, so any table not explicitly mentioned will get this 400: ['cmdb_ci_ip_address'], 500: ['cmdb_ci_network_adapter'], 600: ['alm_asset'] }, // priority classes sRunStartTime: '03:00', // Optional, default 02:00, aRunStartTimes: ['03:00', '15:00'], // Optional, default 02:00, oScheduleCfg: { // Optional: if "schedule" is checked in the configuration and nothing is defined, script will run daily at 02:00 in the morning. sRunStartTime: '03:00', // Optional, default 02:00, aRunStartTimes: ['03:00', '15:00'], // Optional, default 02:00, iRunInterval: 1440, // Optional, will override sRunStartTime and aRunStartTimes and week day specific configuration oWeekendDays: { // Optional, if you need more specific schedules on weekend days iRunInterval: 120, // only one job on SAT/SUN aBlockedHours: [ { sStartTime: '00:00', sEndTime: '21:00' }, // do not run during the day { sStartTime: '22:00', sEndTime: '23:59:59' }, // do not run in the night ], // hours where schedule is not running }, // config for weekend oWeekDays: { // Optional, if you need more specific schedules on week days iRunInterval: 60, aBlockedHours: [ { sStartTime: '06:30', sEndTime: '08:30' }, // do not run in the morning when people login { sStartTime: '20:00', sEndTime: '23:59:59' }, // do not run in the night when other jobs are running ], // hours where schedule is not running }, // config for weekdays } // schedule cfg
View original source

https://www.servicenow.com/community/in-other-news/instance-synchronizer/ba-p/2938648