Access official resources from Carbon Black experts
USE das GO IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'dbo.SchedulerInitialize') and OBJECTPROPERTY(id, N'IsProcedure') = 1) DROP PROCEDURE dbo.SchedulerInitialize GO CREATE PROCEDURE dbo.SchedulerInitialize as begin -- initialize archive DECLARE @enable_archive NVARCHAR(1024); SET @enable_archive = (SELECT value FROM dbo.shepherd_configs WHERE name = 'EnableArchive') if (lower(@enable_archive) = 'true' or @enable_archive = '1') begin if (0 = (SELECT enabled FROM dbo.scheduled_tasks WITH (nolock) WHERE task = 'ArchiveGetEvents')) begin UPDATE dbo.scheduled_tasks SET enabled = 1, task_param = (SELECT MAX(event_id) FROM dbo.events WITH (nolock)) WHERE task = 'ArchiveGetEvents' end end else UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'ArchiveGetEvents' -- initialize export declare @enable_export nvarchar(1024); set @enable_export = (select value from dbo.shepherd_configs WITH (NOLOCK) where name = 'EnableExport') if (lower(@enable_export) = 'true' or @enable_export = '1') begin if ((0 = (select enabled from dbo.scheduled_tasks with(nolock) where task = 'ExportGetEvents')) AND ('5' = (SELECT value FROM dbo.shepherd_configs WITH(NOLOCK) WHERE name = 'NetworkTraceFlags'))) begin update dbo.scheduled_tasks set enabled = 1 where task = 'ExportGetEvents' end end else update dbo.scheduled_tasks set enabled = 0 where task = 'ExportGetEvents' -- initialize metadata declare @enable_metadata nvarchar(1024); set @enable_metadata = (select value from dbo.shepherd_configs WITH (NOLOCK) where name = 'EnableMetadata') if (lower(@enable_metadata) = 'true' or @enable_metadata = '1') begin if ((0 = (select enabled from dbo.scheduled_tasks with(nolock) where task = 'MetadataTrace')) AND ('5' = (SELECT value FROM dbo.shepherd_configs WITH(NOLOCK) WHERE name = 'NetworkTraceFlags'))) begin update dbo.scheduled_tasks set enabled = 1 where task = 'MetadataTrace' end end else update dbo.scheduled_tasks set enabled = 0 where task = 'MetadataTrace' -- initialize syslog DECLARE @enable_syslog NVARCHAR(1024); SET @enable_syslog = (SELECT value FROM dbo.shepherd_configs WHERE name = 'EnableSyslog') if (lower(@enable_syslog) = 'true' or @enable_syslog = '1') begin if (0 = (SELECT enabled FROM dbo.scheduled_tasks WITH (nolock) WHERE task = 'SyslogGetEvents')) begin UPDATE dbo.scheduled_tasks SET enabled = 1, task_param = (SELECT MAX(event_id) FROM dbo.events WITH (nolock)) WHERE task = 'SyslogGetEvents' end end else UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'SyslogGetEvents' -- initialize external events processing (if it is configured) DECLARE @offload_events NVARCHAR(1024); SET @offload_events = (SELECT value FROM dbo.shepherd_configs WHERE name = 'OffloadEvents') if (lower(@offload_events) = 'true' or @offload_events = '1') begin if (0 = (SELECT enabled FROM dbo.scheduled_tasks WITH (nolock) WHERE task = 'ExternalDBGetEvents')) begin UPDATE dbo.scheduled_tasks SET enabled = 1, task_param = (SELECT MAX(event_id) FROM dbo.events WITH (nolock)) WHERE task = 'ExternalDBGetEvents' end end else UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'ExternalDBGetEvents' -- initialize alert processing (if alerts are configured) DECLARE @alerts_enabled INTEGER; SET @alerts_enabled = (SELECT top 1 alert_id FROM dbo.alerts WITH (nolock) WHERE enabled = 1 and deleted = 0) if (@alerts_enabled is not null) begin UPDATE dbo.scheduled_tasks SET enabled = 1 WHERE task = 'AlertExecute' end else UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'AlertExecute' UPDATE dbo.scheduled_tasks SET enabled = dbo.NotificationsEnabled(0) WHERE task = 'AlertGetNotifications' -- initialize backup processing (if it is configured) DECLARE @backupmode NVARCHAR(1024); SET @backupmode = (SELECT value FROM dbo.shepherd_configs WHERE name = 'BackupMode') if (lower(@backupmode) = '1') begin if (0 = (SELECT enabled FROM dbo.scheduled_tasks WITH (nolock) WHERE task = 'ProcessBackupRequest')) begin UPDATE dbo.scheduled_tasks SET enabled = 1 WHERE task = 'ProcessBackupRequest' end DECLARE @newTimeout int SELECT @newTimeout = ISNULL((SELECT CONVERT(int, VALUE) FROM dbo.shepherd_configs WHERE name = 'BackupConsecutiveFailureCount'), 1) if (@newTimeout = 0) begin SET @newTimeout = 1 end -- on failure increase delay before next attempt UPDATE dbo.scheduled_tasks SET delay_before_next_exec = @newTimeout * @newTimeout * 60 WHERE task = 'ProcessBackupRequest' end else UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'ProcessBackupRequest' -- initialize Analysis (for all providers) IF EXISTS (SELECT antibody_analysis_provider_id FROM dbo.antibody_analysis_providers WITH (nolock) WHERE available=1 AND analysis_enabled=1 AND notifications_enabled=1) UPDATE dbo.scheduled_tasks SET enabled = 1 WHERE task IN ('ProcessAnalyzeFiles', 'CleanupOldAnalysisFiles', 'CleanupOldNotificationFiles') ELSE UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task IN ('ProcessAnalyzeFiles', 'CleanupOldAnalysisFiles', 'CleanupOldNotificationFiles') -- initialize PAN IF EXISTS (SELECT antibody_analysis_provider_id FROM dbo.antibody_analysis_providers WITH (nolock) WHERE antibody_analysis_provider_id=2 AND available=1 AND notifications_enabled=1) UPDATE dbo.scheduled_tasks SET enabled = 1 WHERE task = 'ProcessPANConnector' ELSE UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'ProcessPANConnector' IF EXISTS (SELECT antibody_analysis_provider_id FROM dbo.antibody_analysis_providers WITH (nolock) WHERE antibody_analysis_provider_id=4 AND available=1 AND notifications_enabled=1) UPDATE dbo.scheduled_tasks SET enabled = 1 WHERE task = 'ProcessSCEPConnector' ELSE UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'ProcessSCEPConnector' IF EXISTS (SELECT value FROM dbo.shepherd_configs WHERE name = 'NotificationAddressLookupWaitTimeSec' AND value > 0) BEGIN UPDATE dbo.scheduled_tasks SET enabled = 1 WHERE task = 'ProcessDNSLookup' END ELSE UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'ProcessDNSLookup' IF SERVERPROPERTY('productversion')>'12' begin UPDATE dbo.scheduled_tasks SET enabled = 1 WHERE task = 'FlushTranLog' AND enabled = 0 end else UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'FlushTranLog' AND enabled = 1 -- Unified Management IF EXISTS (SELECT value FROM dbo.shepherd_configs WITH(NOLOCK) WHERE name = 'UM_ValidateRules' AND value IN ('true','1')) AND EXISTS (SELECT value FROM dbo.shepherd_configs WITH(NOLOCK) WHERE name = 'UM_Mode' AND CONVERT(INT,value) > 0) AND EXISTS (SELECT id FROM dbo.API_UnifiedServer where state in (2,4)) -- connected and error UPDATE dbo.scheduled_tasks SET enabled = 1 WHERE task = 'UMValidateRules' ELSE UPDATE dbo.scheduled_tasks SET enabled = 0 WHERE task = 'UMValidateRules' end GO
Copyright © 2005-2023 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.