コード例 #1
0
        public void Begin(IDbLogger connection)
        {
            var counters = new[]
                {
                    new KeyValuePair<string, PerformanceCounter>("CpuTime", new PerformanceCounter("Processor", "% Processor Time", "_Total")),
                    new KeyValuePair<string, PerformanceCounter>("FreeSpace", new PerformanceCounter("LogicalDisk", "% Free Space", "_Total")),
                    new KeyValuePair<string, PerformanceCounter>("MemoryInUse", new PerformanceCounter("Memory", "% Committed Bytes In Use"))
                };

            counters.Select(counter => counter.Value.NextValue());

            _disposable = Observable.Interval(TimeSpan.FromSeconds(5)).Subscribe(l =>
                {
                    foreach (var counter in counters)
                    {
                        var jsonData = new Counter
                            {
                                MachineName = Environment.MachineName,
                                Name = string.Format("{0}_{1}_{2}", counter.Value.CategoryName, counter.Value.CounterName, counter.Value.InstanceName),
                                StatName = counter.Key,
                                Value = counter.Value.NextValue(),
                                Date = _time.Now
                            };

                        connection.LogCounter(jsonData);
                    }
                });
        }
コード例 #2
0
ファイル: IDbLogger.cs プロジェクト: naeemkhedarun/nosey
 public void LogCounter(Counter counter)
 {
     _counterCollection.Insert(counter);
 }
コード例 #3
0
ファイル: IDbLogger.cs プロジェクト: naeemkhedarun/nosey
 public void LogCounter(Counter counter)
 {
     try
     {
         _connection.Post(new IndexCommand("counter", "machine"), _serializer.Serialize(counter));
     }
     catch (Exception)
     {
     }
 }