예제 #1
0
        public ICollectorSet Create()
        {
            // Data collector set is the core abstraction for collecting diagnostic data.
            DataCollectorSet dcs = new DataCollectorSet();

            // Create a data collector for a perf counter alert.
            IAlertDataCollector dc = (IAlertDataCollector)dcs.DataCollectors.CreateDataCollector(DataCollectorType.plaAlert);

            dc.name = this.Name + "_DC";
            dcs.DataCollectors.Add(dc);

            // Set sample interval, if present.
            if (this.SampleInterval.HasValue)
            {
                dc.SampleInterval = (uint)this.SampleInterval.Value.TotalSeconds;
            }

            // Set collector to create an event log entry when threshold is reached.
            dc.EventLog = true;

            // Build up the list of alert thresholds.
            string[] alertThresholds = new string[this.Thresholds.Count];
            for (int i = 0; i < this.Thresholds.Count; ++i)
            {
                alertThresholds[i] = this.Thresholds[i].ToString();
            }

            dc.AlertThresholds = alertThresholds;

            // Now actually create (or modify existing) the set.
            dcs.Commit(this.Name, null, CommitMode.plaCreateOrModify);

            // Return an opaque wrapper with which the user can control the session.
            return(new CollectorSetWrapper(dcs));
        }
예제 #2
0
        public ICollectorSet Create()
        {
            // Data collector set is the core abstraction for collecting diagnostic data.
            DataCollectorSet dcs = new DataCollectorSet();

            // Create a data collector for a perf counter alert.
            IAlertDataCollector dc = (IAlertDataCollector)dcs.DataCollectors.CreateDataCollector(DataCollectorType.plaAlert);
            dc.name = this.Name + "_DC";
            dcs.DataCollectors.Add(dc);

            // Set sample interval, if present.
            if (this.SampleInterval.HasValue)
            {
                dc.SampleInterval = (uint)this.SampleInterval.Value.TotalSeconds;
            }

            // Set collector to create an event log entry when threshold is reached.
            dc.EventLog = true;

            // Build up the list of alert thresholds.
            string[] alertThresholds = new string[this.Thresholds.Count];
            for (int i = 0; i < this.Thresholds.Count; ++i)
            {
                alertThresholds[i] = this.Thresholds[i].ToString();
            }

            dc.AlertThresholds = alertThresholds;

            // Now actually create (or modify existing) the set.
            dcs.Commit(this.Name, null, CommitMode.plaCreateOrModify);

            // Return an opaque wrapper with which the user can control the session.
            return new CollectorSetWrapper(dcs);
        }
예제 #3
0
        public ICollectorSet Create()
        {
            // Data collector set is the core abstraction for collecting diagnostic data.
            DataCollectorSet dcs = new DataCollectorSet();

            // Set base folder to place output files.
            dcs.RootPath = this.OutputPath;

            // Create a data collector for traces.
            ITraceDataCollector dc = (ITraceDataCollector)dcs.DataCollectors.CreateDataCollector(DataCollectorType.plaTrace);

            dc.name = this.Name + "_DC";
            dcs.DataCollectors.Add(dc);

            // Set output file name to use a pattern, as described at
            // http://msdn.microsoft.com/en-us/library/windows/desktop/aa372131(v=vs.85).aspx .
            dc.FileName              = this.Name;
            dc.FileNameFormat        = AutoPathFormat.plaPattern;
            dc.FileNameFormatPattern = @"\-yyyyMMdd\-HHmmss";

            // Set various values (if present)
            SetValue(dc, this.BufferSizeInKB, (d, v) => d.BufferSize     = v);
            SetValue(dc, this.Circular, (d, v) => d.LogCircular          = v);
            SetValue(dc, this.FlushTimer, (d, v) => d.FlushTimer         = (uint)v.TotalSeconds);
            SetValue(dc, this.MaximumBuffers, (d, v) => d.MaximumBuffers = v);
            SetValue(dc, this.MinimumBuffers, (d, v) => d.MinimumBuffers = v);

            SetValue(dcs, this.MaxDuration, (d, v) => d.SegmentMaxDuration = (uint)v.TotalSeconds);
            SetValue(dcs, this.MaxSizeInMB, (d, v) => d.SegmentMaxSize     = (uint)v);
            SetValue(dcs, this.Segmented, (d, v) => d.Segment = v);

            // Build up the list of providers.
            foreach (ProviderInfo providerInfo in this.Providers)
            {
                TraceDataProvider provider = dc.TraceDataProviders.CreateTraceDataProvider();
                dc.TraceDataProviders.Add(provider);

                provider.Guid = providerInfo.Id;
                AddValue(provider.KeywordsAll, providerInfo.KeywordsAll);
                AddValue(provider.KeywordsAny, providerInfo.KeywordsAny);
                AddValue(provider.Level, providerInfo.Level);
            }

            // Now actually create (or modify existing) the set.
            dcs.Commit(this.Name, null, CommitMode.plaCreateOrModify);

            // Return an opaque wrapper with which the user can control the session.
            return(new CollectorSetWrapper(dcs));
        }
예제 #4
0
        public ICollectorSet Create()
        {
            // Data collector set is the core abstraction for collecting diagnostic data.
            DataCollectorSet dcs = new DataCollectorSet();

            // Set base folder to place output files.
            dcs.RootPath = this.OutputPath;

            // Create a data collector for perf counters.
            IPerformanceCounterDataCollector dc = (IPerformanceCounterDataCollector)dcs.DataCollectors.CreateDataCollector(DataCollectorType.plaPerformanceCounter);

            dc.name = this.Name + "_DC";
            dcs.DataCollectors.Add(dc);

            // Set output file name to use a pattern, as described at
            // http://msdn.microsoft.com/en-us/library/windows/desktop/aa372131(v=vs.85).aspx .
            dc.FileName              = this.Name;
            dc.FileNameFormat        = AutoPathFormat.plaPattern;
            dc.FileNameFormatPattern = @"\-yyyyMMdd\-HHmmss";

            // Set sample interval, if present.
            if (this.SampleInterval.HasValue)
            {
                dc.SampleInterval = (uint)this.SampleInterval.Value.TotalSeconds;
            }

            // Set log file format, if present.
            if (this.LogFileFormat.HasValue)
            {
                dc.LogFileFormat = (FileFormat)this.LogFileFormat.Value;
            }

            // Build up the list of performance counters.
            string[] counterNames = new string[this.CounterNames.Count];
            for (int i = 0; i < this.CounterNames.Count; ++i)
            {
                counterNames[i] = this.CounterNames[i].ToString();
            }

            dc.PerformanceCounters = counterNames;

            // Now actually create (or modify existing) the set.
            dcs.Commit(this.Name, null, CommitMode.plaCreateOrModify);

            // Return an opaque wrapper with which the user can control the session.
            return(new CollectorSetWrapper(dcs));
        }
예제 #5
0
        public ICollectorSet Create()
        {
            // Data collector set is the core abstraction for collecting diagnostic data.
            DataCollectorSet dcs = new DataCollectorSet();

            // Set base folder to place output files.
            dcs.RootPath = this.OutputPath;

            // Create a data collector for perf counters.
            IPerformanceCounterDataCollector dc = (IPerformanceCounterDataCollector)dcs.DataCollectors.CreateDataCollector(DataCollectorType.plaPerformanceCounter);
            dc.name = this.Name + "_DC";
            dcs.DataCollectors.Add(dc);

            // Set output file name to use a pattern, as described at
            // http://msdn.microsoft.com/en-us/library/windows/desktop/aa372131(v=vs.85).aspx .
            dc.FileName = this.Name;
            dc.FileNameFormat = AutoPathFormat.plaPattern;
            dc.FileNameFormatPattern = @"\-yyyyMMdd\-HHmmss";

            // Set sample interval, if present.
            if (this.SampleInterval.HasValue)
            {
                dc.SampleInterval = (uint)this.SampleInterval.Value.TotalSeconds;
            }

            // Set log file format, if present.
            if (this.LogFileFormat.HasValue)
            {
                dc.LogFileFormat = (FileFormat)this.LogFileFormat.Value;
            }

            // Build up the list of performance counters.
            string[] counterNames = new string[this.CounterNames.Count];
            for (int i = 0; i < this.CounterNames.Count; ++i)
            {
                counterNames[i] = this.CounterNames[i].ToString();
            }

            dc.PerformanceCounters = counterNames;

            // Now actually create (or modify existing) the set.
            dcs.Commit(this.Name, null, CommitMode.plaCreateOrModify);

            // Return an opaque wrapper with which the user can control the session.
            return new CollectorSetWrapper(dcs);
        }
예제 #6
0
 public void StartLog(bool synchronous)
 {
     try
     {
         Logger.LogInformationMessage("Starting counter set name {0}", new object[]
         {
             this.counterSetName
         });
         DataCollectorSet dataCollectorSet = this.ConstructDataCollectorSet();
         dataCollectorSet.start(synchronous);
     }
     catch (COMException ex)
     {
         if (-2147216609 != ex.ErrorCode)
         {
             throw;
         }
     }
 }
예제 #7
0
        public void CreateLogSettings()
        {
            Logger.LogInformationMessage("Creating counter set name {0}", new object[]
            {
                this.counterSetName
            });
            DataCollectorSet dataCollectorSet = this.ConstructDataCollectorSet();

            try
            {
                if (dataCollectorSet.Status != null)
                {
                    dataCollectorSet.Stop(true);
                    dataCollectorSet.Delete();
                }
            }
            catch (Exception)
            {
            }
            dataCollectorSet.Commit(this.counterSetName, null, 3);
        }
        public ISessionController Create()
        {
            // Data collector set is the core abstraction for collecting diagnostic data.
            DataCollectorSet dcs = new DataCollectorSet();

            // Create a data collector for traces.
            ITraceDataCollector dc = (ITraceDataCollector)dcs.DataCollectors.CreateDataCollector(DataCollectorType.plaTrace);

            dc.name = this.Name;
            dcs.DataCollectors.Add(dc);

            // We need to set real-time mode and the session name
            dc.StreamMode  = StreamMode.plaRealTime;
            dc.SessionName = this.Name;

            // Set various values (if present)
            SetValue(dc, this.BufferSizeInKB, (d, v) => d.BufferSize     = v);
            SetValue(dc, this.FlushTimer, (d, v) => d.FlushTimer         = (uint)v.TotalSeconds);
            SetValue(dc, this.MaximumBuffers, (d, v) => d.MaximumBuffers = v);
            SetValue(dc, this.MinimumBuffers, (d, v) => d.MinimumBuffers = v);

            // Build up the list of providers.
            foreach (ProviderInfo providerInfo in this.Providers)
            {
                TraceDataProvider provider = dc.TraceDataProviders.CreateTraceDataProvider();
                dc.TraceDataProviders.Add(provider);

                provider.Guid = providerInfo.Id;
                AddValue(provider.KeywordsAll, providerInfo.KeywordsAll);
                AddValue(provider.KeywordsAny, providerInfo.KeywordsAny);
                AddValue(provider.Level, providerInfo.Level);
            }

            // Now actually create (or modify existing) the set.
            // We explicitly specify the 'Session' namespace for real-time collectors.
            dcs.Commit("Session\\" + this.Name, null, CommitMode.plaCreateOrModify);

            // Return an opaque wrapper with which the user can control the session.
            return(new CollectorSetWrapper(dcs));
        }
예제 #9
0
 public void DeleteLogSettings()
 {
     if (this.Status != PerformanceLogSet.PerformanceLogSetStatus.DoesNotExist)
     {
         try
         {
             this.StopLog(true);
             Logger.LogInformationMessage("Deleting counter set name {0}", new object[]
             {
                 this.counterSetName
             });
             DataCollectorSet dataCollectorSet = this.ConstructDataCollectorSet();
             dataCollectorSet.Delete();
         }
         catch (COMException ex)
         {
             if (-2144337918 != ex.ErrorCode)
             {
                 throw;
             }
         }
     }
 }
예제 #10
0
 public CollectorSetWrapper(DataCollectorSet dcs)
 {
     this.dcs = dcs;
 }
예제 #11
0
 public CollectorSetWrapper(DataCollectorSet dcs)
 {
     this.dcs = dcs;
 }