示例#1
0
        public CounterListViewModel GetCounterList()
        {
            var viewModel  = new CounterListViewModel();
            var dictionary = PerfMon.CounterDictionary.ReadFromFile(@"C:\temp\Counters\index.dat");

            foreach (var counter in dictionary)
            {
                var path   = string.Format(@"c:\temp\counters\{0}.dat", counter.CounterId);
                var header = NWhisper.Whipser.Info(path);
                viewModel.Counters.Add(new CounterListViewModel.Counter()
                {
                    CounterId = counter.CounterId,
                    Hostname  = counter.Hostname,
                    PerformanceCounterCategory = counter.PerformanceCounterCategory,
                    PerformanceCounterName     = counter.PerformanceCounterName,
                    PerformanceCounterInstance = counter.PerformanceCounterInstance,
                    Path         = path,
                    MaxRetention = header.MaxRetention,
                });
            }
            viewModel.Counters =
                viewModel.Counters
                .OrderBy(x => x.Hostname)
                .ThenBy(x => x.PerformanceCounterCategory)
                .ThenBy(x => x.PerformanceCounterInstance)
                .ThenBy(x => x.PerformanceCounterName)
                .ToList();
            return(viewModel);
        }
示例#2
0
 public CounterListViewModel GetCounterList()
 {
     var viewModel = new CounterListViewModel();
     var dictionary = PerfMon.CounterDictionary.ReadFromFile(@"C:\temp\Counters\index.dat");
     foreach (var counter in dictionary)
     {
         var path = string.Format(@"c:\temp\counters\{0}.dat", counter.CounterId);
         var header = NWhisper.Whipser.Info(path);
         viewModel.Counters.Add(new CounterListViewModel.Counter()
         {
             CounterId = counter.CounterId,
             Hostname = counter.Hostname,
             PerformanceCounterCategory = counter.PerformanceCounterCategory,
             PerformanceCounterName = counter.PerformanceCounterName,
             PerformanceCounterInstance = counter.PerformanceCounterInstance,
             Path = path,
             MaxRetention = header.MaxRetention,
         });
     }
     viewModel.Counters =
         viewModel.Counters
             .OrderBy(x => x.Hostname)
             .ThenBy(x => x.PerformanceCounterCategory)
             .ThenBy(x => x.PerformanceCounterInstance)
             .ThenBy(x => x.PerformanceCounterName)
             .ToList();
     return viewModel;
 }