internal static ScheduledTask CreateDatabaseMaintenanceTask(
            ISubscriptionManager subscriptionManager)
        {
            string   empty = string.Empty;
            DateTime dateTime;

            try
            {
                empty    = SettingsDAL.Get("SWNetPerfMon-Settings-Archive Time");
                dateTime = DateTime.FromOADate(double.Parse(empty));
            }
            catch (Exception ex)
            {
                dateTime = DateTime.MinValue.Date.AddHours(2.0).AddMinutes(15.0);
                ScheduledTaskFactory.log.ErrorFormat("DB maintenance time setting is not set or is not correct. Setting value is {0}. \nException: {1}", (object)empty, (object)ex);
            }
            ScheduledTaskInExactTime task = new ScheduledTaskInExactTime("DatabaseMaintenance", new TimerCallback(ScheduledTaskFactory.RunDatabaseMaintenace), (object)null, dateTime);

            if (subscriptionManager != null)
            {
                SubscriptionId subscriptionId;
                ((SubscriptionId) ref subscriptionId).\u002Ector("Core", typeof(ScheduledTaskFactory).FullName, (Scope)0);
                SubscriberConfiguration subscriberConfiguration1 = new SubscriberConfiguration();
                subscriberConfiguration1.set_SubscriptionQuery("SUBSCRIBE CHANGES TO Orion.Settings WHEN SettingsID = 'SWNetPerfMon-Settings-Archive Time'");
                SubscriberConfiguration       subscriberConfiguration2 = subscriberConfiguration1;
                SettingsArchiveTimeSubscriber archiveTimeSubscriber    = new SettingsArchiveTimeSubscriber(task);
                subscriptionManager.Subscribe(subscriptionId, (ISubscriber)archiveTimeSubscriber, subscriberConfiguration2);
            }
            else
            {
                ScheduledTaskFactory.log.Error((object)"SubscribtionProvider is not initialized.");
            }
            return((ScheduledTask)task);
        }
        // Token: 0x060003EA RID: 1002 RVA: 0x0001B680 File Offset: 0x00019880
        internal static ScheduledTask CreateDatabaseMaintenanceTask(InformationServiceSubscriptionProviderBase subscribtionProvider)
        {
            string   text = string.Empty;
            DateTime dateTime;

            try
            {
                text     = SettingsDAL.Get("SWNetPerfMon-Settings-Archive Time");
                dateTime = DateTime.FromOADate(double.Parse(text));
            }
            catch (Exception ex)
            {
                dateTime = DateTime.MinValue.Date.AddHours(2.0).AddMinutes(15.0);
                ScheduledTaskFactory.log.ErrorFormat("DB maintenance time setting is not set or is not correct. Setting value is {0}. \nException: {1}", text, ex);
            }
            ScheduledTaskInExactTime scheduledTaskInExactTime = new ScheduledTaskInExactTime("DatabaseMaintenance", new TimerCallback(ScheduledTaskFactory.RunDatabaseMaintenace), null, dateTime);

            if (subscribtionProvider != null)
            {
                SettingsArchiveTimeSubscriber settingsArchiveTimeSubscriber = new SettingsArchiveTimeSubscriber(scheduledTaskInExactTime);
                subscribtionProvider.Subscribe("SUBSCRIBE CHANGES TO Orion.Settings WHEN SettingsID = 'SWNetPerfMon-Settings-Archive Time'", settingsArchiveTimeSubscriber, new SubscriptionOptions
                {
                    Description = "SettingsArchiveTimeSubscriber"
                });
            }
            else
            {
                ScheduledTaskFactory.log.Error("SubscribtionProvider is not initialized.");
            }
            return(scheduledTaskInExactTime);
        }
Ejemplo n.º 3
0
 // Token: 0x060006FD RID: 1789 RVA: 0x0002C610 File Offset: 0x0002A810
 public static Intervals GetSettingsPollingIntervals()
 {
     return(new Intervals
     {
         RediscoveryInterval = int.Parse(SettingsDAL.Get("SWNetPerfMon-Settings-Default Rediscovery Interval")),
         NodePollInterval = int.Parse(SettingsDAL.Get("SWNetPerfMon-Settings-Default Node Poll Interval")),
         VolumePollInterval = int.Parse(SettingsDAL.Get("SWNetPerfMon-Settings-Default Volume Poll Interval")),
         NodeStatPollInterval = int.Parse(SettingsDAL.Get("SWNetPerfMon-Settings-Default Node Stat Poll Interval")),
         VolumeStatPollInterval = int.Parse(SettingsDAL.Get("SWNetPerfMon-Settings-Default Volume Stat Poll Interval"))
     });
 }
Ejemplo n.º 4
0
        public static void CheckOrionProductTeamBlog()
        {
            HttpWebResponse httpWebResponse = WebRequestHelper.SendHttpWebRequest(BusinessLayerSettings.Instance.OrionProductTeamBlogUrl);

            if (httpWebResponse == null)
            {
                return;
            }
            using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
                BlogItemDAL.StoreBlogItems(ProductBlogSvcWrapper.GetBlogItems((RssBlogItems) new XmlSerializer(typeof(RssBlogItems)).Deserialize((TextReader)streamReader)), Convert.ToInt32(SettingsDAL.Get("ProductsBlog-StoredPostsCount")));
        }
        public ScheduledJob CreateDiscoveryJob(
            DiscoveryConfiguration configuration,
            IDiscoveryPluginFactory pluginFactory)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            Engine engine = this.engineDAL.GetEngine(((DiscoveryConfigurationBase)configuration).get_EngineId());
            DiscoveryPollingEngineType?pollingEngineType = OrionDiscoveryJobFactory.GetDiscoveryPollingEngineType(configuration.get_EngineID(), this.engineDAL);
            int result;

            if (!int.TryParse(SettingsDAL.Get("SWNetPerfMon-Settings-SNMP MaxReps"), out result))
            {
                result = 5;
            }
            OrionDiscoveryJobDescription discoveryJobDescription1 = new OrionDiscoveryJobDescription();

            discoveryJobDescription1.set_ProfileId(((DiscoveryConfigurationBase)configuration).get_ProfileId());
            discoveryJobDescription1.set_EngineId(((DiscoveryConfigurationBase)configuration).get_EngineId());
            discoveryJobDescription1.set_HopCount(configuration.get_HopCount());
            discoveryJobDescription1.set_IcmpTimeout(configuration.get_SearchTimeout());
            DiscoveryCommonSnmpConfiguration snmpConfiguration = new DiscoveryCommonSnmpConfiguration();

            snmpConfiguration.set_MaxSnmpReplies(result);
            snmpConfiguration.set_SnmpRetries(configuration.get_SnmpRetries());
            snmpConfiguration.set_SnmpTimeout(configuration.get_SnmpTimeout());
            snmpConfiguration.set_SnmpPort(configuration.get_SnmpPort());
            snmpConfiguration.set_PreferredSnmpVersion(configuration.get_PreferredSnmpVersion());
            discoveryJobDescription1.set_SnmpConfiguration(snmpConfiguration);
            discoveryJobDescription1.set_DisableICMP(configuration.get_DisableICMP());
            discoveryJobDescription1.set_PreferredPollingMethod(((CoreDiscoveryPluginConfiguration)((DiscoveryConfigurationBase)configuration).GetDiscoveryPluginConfiguration <CoreDiscoveryPluginConfiguration>()).get_PreferredPollingMethod());
            discoveryJobDescription1.set_VulnerabilityCheckDisabled(SettingsDAL.GetCurrentInt("SWNetPerfMon-Settings-VulnerabilityCheckDisabled", 0) == 1);
            discoveryJobDescription1.set_MaxThreadsInDetectionPhase(SettingsDAL.GetCurrentInt("Discovery-MaxThreadsInDetectionPhase", 5));
            discoveryJobDescription1.set_MaxThreadsInInventoryPhase(SettingsDAL.GetCurrentInt("Discovery-MaxThreadsInInventoryPhase", 5));
            discoveryJobDescription1.set_PreferredDnsAddressFamily(SettingsDAL.GetCurrentInt("SWNetPerfMon-Settings-Default Preferred AddressFamily DHCP", 4));
            discoveryJobDescription1.set_TagFilter(configuration.get_TagFilter());
            discoveryJobDescription1.set_DefaultProbes(configuration.get_DefaultProbes());
            OrionDiscoveryJobDescription discoveryJobDescription2 = discoveryJobDescription1;
            List <DiscoveryPluginInfo>   discoveryPluginInfos     = DiscoveryPluginFactory.GetDiscoveryPluginInfos();
            IList <IDiscoveryPlugin>     plugins     = pluginFactory.GetPlugins((IList <DiscoveryPluginInfo>)discoveryPluginInfos);
            List <DiscoveryPluginInfo>   pluginInfos = new List <DiscoveryPluginInfo>();
            IDictionary <IDiscoveryPlugin, DiscoveryPluginInfo> pairsPluginAndInfo = DiscoveryPluginHelper.CreatePairsPluginAndInfo((IEnumerable <IDiscoveryPlugin>)plugins, (IEnumerable <DiscoveryPluginInfo>)discoveryPluginInfos);
            bool flag1 = RegistrySettings.IsFreePoller();

            using (IEnumerator <IDiscoveryPlugin> enumerator = ((IEnumerable <IDiscoveryPlugin>)plugins).GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    IDiscoveryPlugin current = enumerator.Current;
                    if (flag1 && !(current is ISupportFreeEngine))
                    {
                        OrionDiscoveryJobFactory.log.DebugFormat("Discovery plugin {0} is not supported on FPE machine", (object)current);
                    }
                    else if (!((DiscoveryConfigurationBase)configuration).get_ProfileId().HasValue&& !(current is IOneTimeJobSupport))
                    {
                        OrionDiscoveryJobFactory.log.DebugFormat("Plugin {0} is not supporting one time job and it's description woun't be added.", (object)((object)current).GetType().FullName);
                    }
                    else
                    {
                        if (configuration.get_TagFilter() != null && configuration.get_TagFilter().Any <string>())
                        {
                            if (!(current is IDiscoveryPluginTags idiscoveryPluginTags))
                            {
                                OrionDiscoveryJobFactory.log.DebugFormat("Discovery job for tags requested, however plugin {0} doesn't support tags, skipping.", (object)current);
                                continue;
                            }
                            if (!configuration.get_TagFilter().Intersect <string>(idiscoveryPluginTags.get_Tags() ?? Enumerable.Empty <string>(), (IEqualityComparer <string>)StringComparer.InvariantCultureIgnoreCase).Any <string>())
                            {
                                OrionDiscoveryJobFactory.log.DebugFormat("Discovery job for tags [{0}], however plugin {1} doesn't support any of the tags requested, skipping.", (object)string.Join(",", (IEnumerable <string>)configuration.get_TagFilter()), (object)current);
                                continue;
                            }
                        }
                        if (configuration.get_IsAgentJob() && (!(current is IAgentPluginJobSupport pluginJobSupport) || !((IEnumerable <string>)configuration.get_AgentPlugins()).Contains <string>(pluginJobSupport.get_PluginId())))
                        {
                            OrionDiscoveryJobFactory.log.DebugFormat("Plugin {0} is not contained in supported agent plugins and will not be used.", (object)((object)current).GetType().FullName);
                        }
        // Token: 0x0600037A RID: 890 RVA: 0x00015B20 File Offset: 0x00013D20
        public ScheduledJob CreateDiscoveryJob(DiscoveryConfiguration configuration, IDiscoveryPluginFactory pluginFactory)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            Engine engine = this.engineDAL.GetEngine(configuration.EngineId);
            DiscoveryPollingEngineType?discoveryPollingEngineType = OrionDiscoveryJobFactory.GetDiscoveryPollingEngineType(configuration.EngineID, this.engineDAL);
            int maxSnmpReplies;

            if (!int.TryParse(SettingsDAL.Get("SWNetPerfMon-Settings-SNMP MaxReps"), out maxSnmpReplies))
            {
                maxSnmpReplies = 5;
            }
            OrionDiscoveryJobDescription orionDiscoveryJobDescription = new OrionDiscoveryJobDescription
            {
                ProfileId         = configuration.ProfileId,
                EngineId          = configuration.EngineId,
                HopCount          = configuration.HopCount,
                IcmpTimeout       = configuration.SearchTimeout,
                SnmpConfiguration = new DiscoveryCommonSnmpConfiguration
                {
                    MaxSnmpReplies       = maxSnmpReplies,
                    SnmpRetries          = configuration.SnmpRetries,
                    SnmpTimeout          = configuration.SnmpTimeout,
                    SnmpPort             = configuration.SnmpPort,
                    PreferredSnmpVersion = configuration.PreferredSnmpVersion
                },
                DisableICMP                = configuration.DisableICMP,
                PreferredPollingMethod     = configuration.GetDiscoveryPluginConfiguration <CoreDiscoveryPluginConfiguration>().PreferredPollingMethod,
                VulnerabilityCheckDisabled = (SettingsDAL.GetCurrentInt("SWNetPerfMon-Settings-VulnerabilityCheckDisabled", 0) == 1),
                MaxThreadsInDetectionPhase = SettingsDAL.GetCurrentInt("Discovery-MaxThreadsInDetectionPhase", 5),
                MaxThreadsInInventoryPhase = SettingsDAL.GetCurrentInt("Discovery-MaxThreadsInInventoryPhase", 5),
                PreferredDnsAddressFamily  = SettingsDAL.GetCurrentInt("SWNetPerfMon-Settings-Default Preferred AddressFamily DHCP", 4),
                TagFilter     = configuration.TagFilter,
                DefaultProbes = configuration.DefaultProbes
            };
            List <DiscoveryPluginInfo> discoveryPluginInfos = DiscoveryPluginFactory.GetDiscoveryPluginInfos();
            IList <IDiscoveryPlugin>   plugins = pluginFactory.GetPlugins(discoveryPluginInfos);
            List <DiscoveryPluginInfo> list    = new List <DiscoveryPluginInfo>();
            IDictionary <IDiscoveryPlugin, DiscoveryPluginInfo> dictionary = DiscoveryPluginHelper.CreatePairsPluginAndInfo(plugins, discoveryPluginInfos);
            bool flag = RegistrySettings.IsFreePoller();

            foreach (IDiscoveryPlugin discoveryPlugin in plugins)
            {
                if (flag && !(discoveryPlugin is ISupportFreeEngine))
                {
                    OrionDiscoveryJobFactory.log.DebugFormat("Discovery plugin {0} is not supported on FPE machine", discoveryPlugin);
                }
                else if (configuration.ProfileId == null && !(discoveryPlugin is IOneTimeJobSupport))
                {
                    OrionDiscoveryJobFactory.log.DebugFormat("Plugin {0} is not supporting one time job and it's description woun't be added.", discoveryPlugin.GetType().FullName);
                }
                else
                {
                    if (configuration.TagFilter != null && configuration.TagFilter.Any <string>())
                    {
                        IDiscoveryPluginTags discoveryPluginTags = discoveryPlugin as IDiscoveryPluginTags;
                        if (discoveryPluginTags == null)
                        {
                            OrionDiscoveryJobFactory.log.DebugFormat("Discovery job for tags requested, however plugin {0} doesn't support tags, skipping.", discoveryPlugin);
                            continue;
                        }
                        if (!configuration.TagFilter.Intersect(discoveryPluginTags.Tags ?? Enumerable.Empty <string>(), StringComparer.InvariantCultureIgnoreCase).Any <string>())
                        {
                            OrionDiscoveryJobFactory.log.DebugFormat("Discovery job for tags [{0}], however plugin {1} doesn't support any of the tags requested, skipping.", string.Join(",", configuration.TagFilter), discoveryPlugin);
                            continue;
                        }
                    }
                    if (configuration.IsAgentJob)
                    {
                        IAgentPluginJobSupport agentPluginJobSupport = discoveryPlugin as IAgentPluginJobSupport;
                        if (agentPluginJobSupport == null || !configuration.AgentPlugins.Contains(agentPluginJobSupport.PluginId))
                        {
                            OrionDiscoveryJobFactory.log.DebugFormat("Plugin {0} is not contained in supported agent plugins and will not be used.", discoveryPlugin.GetType().FullName);
                            continue;
                        }
                    }
                    if (discoveryPollingEngineType != null && !OrionDiscoveryJobFactory.IsDiscoveryPluginSupportedForDiscoveryPollingEngineType(discoveryPlugin, discoveryPollingEngineType.Value, dictionary))
                    {
                        if (OrionDiscoveryJobFactory.log.IsDebugEnabled)
                        {
                            OrionDiscoveryJobFactory.log.DebugFormat(string.Format("Plugin {0} is not supported for polling engine {1}", discoveryPlugin.GetType().FullName, configuration.EngineID), Array.Empty <object>());
                        }
                    }
                    else
                    {
                        DiscoveryPluginJobDescriptionBase discoveryPluginJobDescriptionBase = null;
                        Exception ex = null;
                        try
                        {
                            discoveryPluginJobDescriptionBase = discoveryPlugin.GetJobDescription(configuration);
                        }
                        catch (Exception ex2)
                        {
                            discoveryPluginJobDescriptionBase = null;
                            ex = ex2;
                        }
                        if (discoveryPluginJobDescriptionBase == null)
                        {
                            string text = "Plugin " + discoveryPlugin.GetType().FullName + " was not able found valid job description.";
                            if (ex != null)
                            {
                                OrionDiscoveryJobFactory.log.Warn(text, ex);
                            }
                            else
                            {
                                OrionDiscoveryJobFactory.log.Warn(text);
                            }
                        }
                        else
                        {
                            orionDiscoveryJobDescription.DiscoveryPluginJobDescriptions.Add(discoveryPluginJobDescriptionBase);
                            DiscoveryPluginInfo item = dictionary[discoveryPlugin];
                            list.Add(item);
                        }
                    }
                }
            }
            JobDescription jobDescription = new JobDescription
            {
                TypeName = typeof(OrionDiscoveryJob).AssemblyQualifiedName,
                JobDetailConfiguration = this.GetOrionDiscoveryJobDescriptionString(orionDiscoveryJobDescription, list, configuration.UseJsonFormat),
                JobNamespace           = "orion",
                ResultTTL       = TimeSpan.FromMinutes(10.0),
                TargetNode      = new HostAddress(IPAddressHelper.ToStringIp(engine.IP), 4),
                LegacyEngine    = engine.ServerName.ToLowerInvariant(),
                EndpointAddress = (configuration.IsAgentJob ? configuration.AgentAddress : null),
                SupportedRoles  = 7
            };

            jobDescription.Timeout = OrionDiscoveryJobFactory.GetDiscoveryJobTimeout(configuration);
            ScheduledJob scheduledJob;

            if (configuration.CronSchedule != null)
            {
                bool   flag2 = false;
                string text2 = configuration.CronSchedule.CronExpression;
                if (string.IsNullOrWhiteSpace(text2))
                {
                    DateTime t = configuration.CronSchedule.StartTime.ToLocalTime();
                    if (t < DateTime.Now)
                    {
                        OrionDiscoveryJobFactory.log.InfoFormat("Profile (ID={0}) with past Once(Cron) schedule. We should not create job for it.", configuration.ProfileID);
                        return(null);
                    }
                    text2 = string.Format("{0} {1} {2} {3} *", new object[]
                    {
                        t.Minute,
                        t.Hour,
                        t.Day,
                        t.Month
                    });
                    flag2 = true;
                }
                scheduledJob              = new ScheduledJob(jobDescription, text2, "net.pipe://localhost/orion/core/scheduleddiscoveryjobsevents2", configuration.ProfileID.ToString());
                scheduledJob.RunOnce      = flag2;
                scheduledJob.TimeZoneInfo = TimeZoneInfo.Local;
                if (!flag2)
                {
                    scheduledJob.Start = configuration.CronSchedule.StartTime.ToUniversalTime();
                    DateTime?endTime  = configuration.CronSchedule.EndTime;
                    DateTime maxValue = DateTime.MaxValue;
                    if ((endTime == null || (endTime != null && endTime.GetValueOrDefault() != maxValue)) && configuration.CronSchedule.EndTime != null)
                    {
                        scheduledJob.End = configuration.CronSchedule.EndTime.Value.ToUniversalTime();
                    }
                }
            }
            else if (!configuration.ScheduleRunAtTime.Equals(DateTime.MinValue))
            {
                scheduledJob = new ScheduledJob(jobDescription, configuration.ScheduleRunAtTime, "net.pipe://localhost/orion/core/scheduleddiscoveryjobsevents2", configuration.ProfileID.ToString());
            }
            else
            {
                scheduledJob = new ScheduledJob(jobDescription, configuration.ScheduleRunFrequency, "net.pipe://localhost/orion/core/scheduleddiscoveryjobsevents2", configuration.ProfileID.ToString());
            }
            return(scheduledJob);
        }