Beispiel #1
0
        // a snapshot combines a bunch of process-level things with a set of counters
        public static Dictionary <string, object> MakeSnapshot(CounterResponse counters)
        {
            var p = Process.GetCurrentProcess();

            var dict = new Dictionary <string, object>();

            dict["PartitionKey"] = "ProcessMonitor";
            dict["RowKey"]       = DateTime.Now.ToUniversalTime().Ticks.ToString();

            // add general info

            dict["HostName"] = System.Net.Dns.GetHostName();
            dict["ProcName"] = p.ProcessName;
            dict["ProcId"]   = System.Diagnostics.Process.GetCurrentProcess().Id;

            // add process info

            dict["ThreadCount"]     = p.Threads.Count;
            dict["TotalProcTime"]   = p.TotalProcessorTime.Ticks;
            dict["TotalUserTime"]   = p.UserProcessorTime.Ticks;
            dict["PagedMemSize"]    = p.PagedMemorySize64;
            dict["NonPagedMemSize"] = p.NonpagedSystemMemorySize64;
            dict["PrivateMemSize"]  = p.PrivateMemorySize64;
            dict["VirtMemSize"]     = p.VirtualMemorySize64;
            dict["PeakWorkingSet"]  = p.PeakWorkingSet64;
            dict["MinWorkingSet"]   = p.MinWorkingSet;

            // add counter info

            if (counters == null)
            {
                counters = Counters.GetCounters();
            }

            foreach (var key in counters.counter_objects.Keys)              // prime the pump
            {
                var counter = counters.counter_objects[key];
                try
                { counter.NextValue(); }
                catch
                { }
            }

            HttpUtils.Wait(1);

            foreach (var key in counters.counter_objects.Keys)             // now read values
            {
                var counter = counters.counter_objects[key];
                try
                {
                    dict[key] = counter.NextValue();
                }
                catch (Exception e)
                {
                    GenUtils.PriorityLogMsg("exception", string.Format("MakeSnapshotDict: {0}/{1}/{2}", key, counter.CategoryName, counter.CounterName), e.Message + e.StackTrace);
                }
            }

            return(dict);
        }
Beispiel #2
0
 public void ReloadCounters()
 {
     GenUtils.LogMsg("info", "Monitor.ReloadCounters", null);
     this.counters = Counters.GetCounters();
     this.priority_log_triggers = GetPriorityLogTriggers(this.ts);
 }
Beispiel #3
0
        // a snapshot combines a bunch of process-level things with a set of counters
        public static Dictionary<string, object> MakeSnapshot(CounterResponse counters)
        {
            var p = Process.GetCurrentProcess();

            var dict = new Dictionary<string, object>();

            dict["PartitionKey"] = "ProcessMonitor";
            dict["RowKey"] = DateTime.Now.ToUniversalTime().Ticks.ToString();

            // add general info

            dict["HostName"] = System.Net.Dns.GetHostName();
            dict["ProcName"] = p.ProcessName;
            dict["ProcId"] = System.Diagnostics.Process.GetCurrentProcess().Id;

            // add process info

            dict["ThreadCount"] = p.Threads.Count;
            dict["TotalProcTime"] = p.TotalProcessorTime.Ticks;
            dict["TotalUserTime"] = p.UserProcessorTime.Ticks;
            dict["PagedMemSize"] = p.PagedMemorySize64;
            dict["NonPagedMemSize"] = p.NonpagedSystemMemorySize64;
            dict["PrivateMemSize"] = p.PrivateMemorySize64;
            dict["VirtMemSize"] = p.VirtualMemorySize64;
            dict["PeakWorkingSet"] = p.PeakWorkingSet64;
            dict["MinWorkingSet"] = p.MinWorkingSet;

            // add counter info

            if (counters == null)
                counters = Counters.GetCounters();

            foreach (var key in counters.counter_objects.Keys)  // prime the pump
            {
                var counter = counters.counter_objects[key];
                try
                { counter.NextValue(); }
                catch
                { }
            }

            HttpUtils.Wait(1);

            foreach (var key in counters.counter_objects.Keys) // now read values
            {
                var counter = counters.counter_objects[key];
                try
                {
                    dict[key] = counter.NextValue();
                }
                catch (Exception e)
                {
                    GenUtils.PriorityLogMsg("exception", string.Format("MakeSnapshotDict: {0}/{1}/{2}", key, counter.CategoryName, counter.CounterName), e.Message + e.StackTrace);
                }
            }

            return dict;
        }
Beispiel #4
0
 public void ReloadCounters()
 {
     GenUtils.LogMsg("status", "Monitor.ReloadCounters", null);
     this.counters = Counters.GetCounters();
     this.priority_log_triggers = GetPriorityLogTriggers(this.ts);
 }