示例#1
0
 internal MonitoredLogSet(PerformanceLogSet counterSet, TimeSpan?restartInterval)
 {
     this.counterSet      = counterSet;
     this.restartInterval = restartInterval;
     this.lastRestart     = DateTime.MinValue;
     this.failureCount    = 0;
 }
示例#2
0
 public void AddPerflog(PerformanceLogSet performanceLog, TimeSpan?restartInterval)
 {
     lock (this.performanceLogListLock)
     {
         PerformanceLogMonitor.MonitoredLogSet item = new PerformanceLogMonitor.MonitoredLogSet(performanceLog, restartInterval);
         this.monitoredSets.Add(item);
     }
 }
 public static void StopCounterSet(string counterSetName)
 {
     try
     {
         IRegisteredTask task = PerformanceLogSet.GetTask(counterSetName);
         task.Stop(0);
     }
     catch (FileNotFoundException)
     {
     }
 }
 public void StopLog(bool synchronous)
 {
     try
     {
         Logger.LogInformationMessage("Stopping counter set name {0}", new object[]
         {
             this.counterSetName
         });
         PerformanceLogSet.StopCounterSet(this.counterSetName);
         this.ConstructDataCollectorSet();
     }
     catch (COMException ex)
     {
         if (-2144337918 != ex.ErrorCode && -2144337660 != ex.ErrorCode)
         {
             throw;
         }
     }
 }
示例#5
0
 private void CheckPerflogStatus()
 {
     lock (this.performanceLogListLock)
     {
         foreach (PerformanceLogMonitor.MonitoredLogSet monitoredLogSet in this.monitoredSets)
         {
             try
             {
                 if (monitoredLogSet.LastRestart == DateTime.MinValue)
                 {
                     monitoredLogSet.CounterSet.StopLog(true);
                     monitoredLogSet.CounterSet.CreateLogSettings();
                 }
                 PerformanceLogSet.PerformanceLogSetStatus status = monitoredLogSet.CounterSet.Status;
                 bool flag2 = status != PerformanceLogSet.PerformanceLogSetStatus.Running;
                 if (status == PerformanceLogSet.PerformanceLogSetStatus.DoesNotExist)
                 {
                     monitoredLogSet.CounterSet.CreateLogSettings();
                 }
                 if (!flag2 && monitoredLogSet.RestartInterval != null && DateTime.UtcNow - monitoredLogSet.LastRestart > monitoredLogSet.RestartInterval)
                 {
                     monitoredLogSet.CounterSet.StopLog(true);
                     flag2 = true;
                 }
                 if (flag2)
                 {
                     monitoredLogSet.CounterSet.StartLog(false);
                     monitoredLogSet.LastRestart = DateTime.UtcNow;
                 }
                 monitoredLogSet.FailureCount = 0;
             }
             catch (Exception ex)
             {
                 Logger.LogWarningMessage("Check PerflogStatus hit exception {0} for performance log set {1}", new object[]
                 {
                     ex,
                     monitoredLogSet.CounterSet.CounterSetName
                 });
                 if (5 <= monitoredLogSet.FailureCount)
                 {
                     Logger.LogEvent(MSExchangeDiagnosticsEventLogConstants.Tuple_PerformanceLogError, new object[]
                     {
                         ex,
                         monitoredLogSet.CounterSet.CounterSetName
                     });
                     throw;
                 }
                 monitoredLogSet.FailureCount++;
                 if (!(ex is ArgumentException) && !(ex is COMException))
                 {
                     throw;
                 }
                 string text = Path.Combine(Environment.GetEnvironmentVariable("windir"), "System32\\Tasks\\Microsoft\\Windows\\PLA", monitoredLogSet.CounterSet.CounterSetName);
                 Logger.LogWarningMessage("PerflogStatus deleting logset info at '{0}'", new object[]
                 {
                     text
                 });
                 PerformanceLogSet.DeleteTask(monitoredLogSet.CounterSet.CounterSetName);
                 if (File.Exists(text))
                 {
                     File.Delete(text);
                 }
             }
         }
     }
 }