Esempio n. 1
0
        static List <PerformanceCounter> ReportList(CounterSet cset, List <string> instances)
        {
            List <string>             counters  = cset.Counters;
            List <PerformanceCounter> pcounters = new List <PerformanceCounter> ();

            foreach (string instance in instances)
            {
                for (int i = 0; i < counters.Count; i += 2)
                {
                    try {
                        PerformanceCounter counter = new PerformanceCounter(counters [i], counters [i + 1], instance);
                        pcounters.Add(counter);
                    } catch (Exception e) {
                        //Console.WriteLine (e.Message);
                    }
                }
            }
            return(pcounters);
        }
        protected virtual void OnSetSelected(object sender, System.EventArgs e)
        {
            instances_store.Clear();
            CounterSet cset = cfg.sets [counterset.Active];

            csetn = cset.Name;
            try
            {
                // we take just the first counter category into consideration
                // to retrieve an instance
                PerformanceCounterCategory cat = new PerformanceCounterCategory(cset.Counters [0]);
                foreach (string s in cat.GetInstanceNames())
                {
                    instances_store.AppendValues(s);
                }
            }
            catch
            {
            }
        }
Esempio n. 3
0
 static List<PerformanceCounter> ReportList(CounterSet  cset, List<string> instances)
 {
     List<string> counters = cset.Counters;
     List<PerformanceCounter> pcounters = new List<PerformanceCounter> ();
     foreach (string instance in instances) {
         for (int i = 0; i < counters.Count; i += 2) {
             try {
                 PerformanceCounter counter = new PerformanceCounter (counters [i], counters [i + 1], instance);
                 pcounters.Add (counter);
             } catch (Exception e) {
                 //Console.WriteLine (e.Message);
             }
         }
     }
     return pcounters;
 }