Exemple #1
0
        private static void CreatePerfCounterCollector()
        {
            CounterCollectorInfo info = new CounterCollectorInfo("MyCounters");

            info.SampleInterval = TimeSpan.FromSeconds(1.0d);
            info.LogFileFormat  = LogFileFormat.CommaSeparated;
            info.OutputPath     = Environment.CurrentDirectory;

            info.CounterNames.Add(new CounterName()
            {
                Category = "Process", Counter = "Thread Count", Instance = "explorer"
            });
            info.CounterNames.Add(new CounterName()
            {
                Category = "System", Counter = "System Calls/sec"
            });
            info.CounterNames.Add(new CounterName()
            {
                Category = "Processor", Counter = "Interrupts/sec", Instance = "_Total"
            });

            ICollectorSet collector = info.Create();

            collector.Start();

            Thread.Sleep(5000);

            collector.Stop();

            collector.Delete();
        }
Exemple #2
0
        private static void CreateTraceCollector()
        {
            TraceCollectorInfo info = new TraceCollectorInfo("MyTraces");

            info.BufferSizeInKB = 64;
            info.Segmented      = true;
            info.MaxDuration    = TimeSpan.FromSeconds(1.0d);
            info.OutputPath     = Environment.CurrentDirectory;

            // Microsoft-Windows-Kernel-Process
            Guid providerId = new Guid("{22FB2CD6-0E7B-422B-A0C7-2FAD1FD0E716}");

            info.Providers.Add(new ProviderInfo(providerId)
            {
                Level = 5
            });

            ICollectorSet collector = info.Create();

            collector.Start();

            Thread.Sleep(5000);

            collector.Stop();

            collector.Delete();
        }
Exemple #3
0
        private static void CreatePerfCounterAlert()
        {
            CounterAlertInfo info = new CounterAlertInfo("MyAlert");

            info.SampleInterval = TimeSpan.FromSeconds(2.0d);

            CounterName counterName = new CounterName()
            {
                Category = "Process", Counter = "% Processor Time", Instance = "notepad"
            };

            info.Thresholds.Add(new CounterThreshold()
            {
                Name = counterName, Condition = ThresholdCondition.Below, Value = 5.0d
            });

            ICollectorSet collector = info.Create();

            collector.Start();

            Thread.Sleep(5000);

            collector.Stop();

            collector.Delete();
        }
Exemple #4
0
        public Alert(string name, double lowerBound, double upperBound)
        {
            CounterAlertInfo info = new CounterAlertInfo("AlertSample");
            info.SampleInterval = TimeSpan.FromSeconds(3.0d);

            CounterName counterName = new CounterName() { Category = "Process", Counter = "IO Data Operations/sec", Instance = "AlertSample.App#1" };
            info.Thresholds.Add(new CounterThreshold() { Name = counterName, Condition = ThresholdCondition.Below, Value = lowerBound });
            info.Thresholds.Add(new CounterThreshold() { Name = counterName, Condition = ThresholdCondition.Above, Value = upperBound });

            this.collector = info.Create();
        }
Exemple #5
0
        public Alert(string name, double lowerBound, double upperBound)
        {
            CounterAlertInfo info = new CounterAlertInfo("AlertSample");

            info.SampleInterval = TimeSpan.FromSeconds(3.0d);

            CounterName counterName = new CounterName()
            {
                Category = "Process", Counter = "IO Data Operations/sec", Instance = "AlertSample.App#1"
            };

            info.Thresholds.Add(new CounterThreshold()
            {
                Name = counterName, Condition = ThresholdCondition.Below, Value = lowerBound
            });
            info.Thresholds.Add(new CounterThreshold()
            {
                Name = counterName, Condition = ThresholdCondition.Above, Value = upperBound
            });

            this.collector = info.Create();
        }