Beispiel #1
0
        private static void StartReporting(HackShieldService serv)
        {
            if (!FeatureMatrix.IsEnable("ServiceReporter"))
            {
                return;
            }
            int interval = ServiceReporterSettings.GetInterval("HackShieldService", 60);

            ServiceReporter.Instance.Initialize("HackShieldService");
            ServiceReporter.Instance.AddGathering("Stat", new ServiceReporter.GatheringDelegate <int>(serv.OnGatheringStat));
            ServiceReporter.Instance.Start(interval * 1000);
        }
Beispiel #2
0
 public void Initialize(string serviceName)
 {
     try
     {
         this.ServiceName                     = serviceName;
         this.GameCode                        = FeatureMatrix.GameCode;
         this.ServerCode                      = FeatureMatrix.ServerCode;
         this.RowNumber                       = 0;
         this.MachineIP                       = this.GetMachineIP();
         this.Proc                            = Process.GetCurrentProcess();
         this.ProcessID                       = this.Proc.Id;
         this.CpuUsage                        = new CpuUsage();
         this.FileWatcher.Path                = Directory.GetCurrentDirectory();
         this.FileWatcher.Filter              = "ServiceCore.dll.config";
         this.FileWatcher.NotifyFilter        = (NotifyFilters.LastWrite | NotifyFilters.LastAccess);
         this.FileWatcher.Changed            += this.SettingChanged;
         this.FileWatcher.EnableRaisingEvents = true;
         ((Hierarchy)LogManager.GetRepository()).Root.AddAppender(this);
         int interval  = ServiceReporterSettings.GetInterval(this.ServiceName + ".Perf", 60);
         int interval2 = ServiceReporterSettings.GetInterval(this.ServiceName + ".Log", 60);
         this.AddPerfSubject("Perf", interval * 1000, new ServiceReporter.GatheringDelegate <int>(this.OnGathringPerf));
         this.AddLogSubject("Log", interval2 * 1000, new ServiceReporter.GatheringDelegate <int>(this.OnGatheringLog));
         int interval3 = ServiceReporterSettings.GetInterval(this.ServiceName + ".Stat", 60);
         this.AddSubject("Stat", null, interval3 * 1000);
         int interval4 = ServiceReporterSettings.GetInterval("ProfileScope", 3600);
         this.AddProfileScopeSubject("ProfileScope", interval4 * 1000, new ServiceReporter.GatheringDelegate <double>(this.OnGatheringProfileScope));
         this.InitTime = DateTime.Now;
         if (!Directory.Exists("csv"))
         {
             Directory.CreateDirectory("csv");
         }
         this.WritePreds();
     }
     catch (Exception ex)
     {
         Log <ServiceReporter> .Logger.Error("ServiceReporter.Initialize() FAILED!", ex);
     }
 }
Beispiel #3
0
        private void SettingChanged(object sender, FileSystemEventArgs e)
        {
            try
            {
                Log <ServiceReporter> .Logger.Info("ServiceReporter.SettingChanged()");

                ConfigurationManager.RefreshSection("ServiceReporterSettings");
                foreach (ServiceReporter.SubjectEntry subjectEntry in this.Subjects)
                {
                    int num = ServiceReporterSettings.GetInterval(this.ServiceName + subjectEntry.SubjName, subjectEntry.GatheringInterval) * 1000;
                    num = Math.Max(num, 1000);
                    subjectEntry.GatheringInterval = num;
                }
                this.Stop();
                int num2 = ServiceReporterSettings.GetInterval(this.ServiceName, 60) * 1000;
                if (num2 > 1)
                {
                    this.Start(num2);
                }
            }
            catch (Exception)
            {
            }
        }