public Stats(ConfRoot conf, DbStore database, BotManager botManager, DedicatedTaskScheduler scheduler) { this.conf = conf; this.database = database; this.botManager = botManager; uploadParamEnabled = true; runtimeLastTrack = Tools.Now; ticker = scheduler.CreateTimer(TrackPoint, CheckInterval, false); meta = database.GetMetaData(StatsTable); trackEntries = database.GetCollection <StatsData>(StatsTable); trackEntries.EnsureIndex(x => x.Id, true); trackEntries.EnsureIndex(x => x.Time); accEntries = database.GetCollection <StatsData>(StatsTableAcc); accEntries.EnsureIndex(x => x.Id, true); if (meta.Version != StatsVersion || meta.CustomData is null) { statsPoints = new StatsMeta { LastSend = Tools.Now, }; meta.Version = StatsVersion; UpdateMeta(); } else { statsPoints = JsonConvert.DeserializeObject <StatsMeta>(meta.CustomData, JsonSettings) ?? new StatsMeta(); // Upgrade steps here } overallStats = accEntries.FindById(OverallId) ?? new StatsData { Id = OverallId }; }
public SystemMonitor(DedicatedTaskScheduler scheduler) { _ = scheduler.CreateTimer(CreateSnapshot, TimeSpan.FromSeconds(1), true); }