Esempio n. 1
0
 private SystemMonitor()
 {
     EventController.RegisterEventHandler(this);
     if (Settings.Current[Constants.BASE_PATH_NAME] == null)
     {
         Settings.Current[Constants.BASE_PATH_NAME] = Constants.DEFAULT_BASE_BATH;
     }
     _drivesMonitored   = SystemInformation.Current.Drives;
     _values            = new Dictionary <SystemMetricTypes, object>();
     _callMonitor       = new CallEventMonitor();
     _eventMonitor      = new EventMonitor();
     _connectionMonitor = new ConnectionEventMonitor();
     if (ModuleController.Current.IsModuleEnabled("ESL"))
     {
         ModuleController.Current.InvokeModuleMethod("ESL", "RegisterEvent", new NameValuePair[] { new NameValuePair("eventName", CallEventMonitor.CREATE_EVENT_NAME) }, false);
         ModuleController.Current.InvokeModuleMethod("ESL", "RegisterEvent", new NameValuePair[] { new NameValuePair("eventName", CallEventMonitor.DESTROY_EVENT_NAME) }, false);
         ModuleController.Current.InvokeModuleMethod("ESL", "RegisterEvent", new NameValuePair[] { new NameValuePair("eventName", HeartbeatEventMonitor.EVENT_NAME) }, false);
     }
     EventController.RegisterEventHandler(_callMonitor);
     EventController.RegisterEventHandler(_eventMonitor);
     EventController.RegisterEventHandler(new HeartbeatEventMonitor());
     cpus = new List <WrappedPerformanceCounter>();
     for (int x = 0; x < Environment.ProcessorCount; x++)
     {
         cpus.Add(new WrappedPerformanceCounter("Processor", "% Processor Time", x.ToString()));
     }
     memory                 = new WrappedPerformanceCounter("Process", "Working Set", "_Total");
     processes_cpu          = new List <WrappedPerformanceCounter>();
     processes_mem          = new List <WrappedPerformanceCounter>();
     processes_threads      = new WrappedPerformanceCounter("Process", "Thread Count", "_Total");
     current_process_thread = new WrappedPerformanceCounter("Process", "Thread Count", "_Current");
     current_process_cpu    = new WrappedPerformanceCounter("Process", "% Processor Time", "_Current");
     current_process_mem    = new WrappedPerformanceCounter("Process", "Working Set", "_Current");
     foreach (Process p in Process.GetProcesses())
     {
         if (p.ProcessName != "Idle")
         {
             processes_cpu.Add(new WrappedPerformanceCounter("Process", "% Processor Time", p.ProcessName));
             processes_mem.Add(new WrappedPerformanceCounter("Process", "Working Set", p.ProcessName));
         }
     }
     networks = new List <WrappedPerformanceCounter>();
     foreach (string str in new PerformanceCounterCategory("Network Interface").GetInstanceNames())
     {
         networks.Add(new WrappedPerformanceCounter("Network Interface", "Bytes Recieved/sec", str));
         networks.Add(new WrappedPerformanceCounter("Network Interface", "Bytes Sent/sec", str));
     }
     EventController.RegisterEventHandler(this);
 }
 private SystemMonitor()
 {
     EventController.RegisterEventHandler(this);
     if (Settings.Current[Constants.BASE_PATH_NAME] == null)
         Settings.Current[Constants.BASE_PATH_NAME] = Constants.DEFAULT_BASE_BATH;
     _drivesMonitored = SystemInformation.Current.Drives;
     _values = new Dictionary<SystemMetricTypes, object>();
     _callMonitor = new CallEventMonitor();
     _eventMonitor = new EventMonitor();
     _connectionMonitor = new ConnectionEventMonitor();
     if (ModuleController.Current.IsModuleEnabled("ESL"))
     {
         ModuleController.Current.InvokeModuleMethod("ESL", "RegisterEvent", new NameValuePair[]{new NameValuePair("eventName",CallEventMonitor.CREATE_EVENT_NAME)},false);
         ModuleController.Current.InvokeModuleMethod("ESL", "RegisterEvent", new NameValuePair[] { new NameValuePair("eventName", CallEventMonitor.DESTROY_EVENT_NAME) }, false);
         ModuleController.Current.InvokeModuleMethod("ESL", "RegisterEvent", new NameValuePair[] { new NameValuePair("eventName", HeartbeatEventMonitor.EVENT_NAME) }, false);
     }
     EventController.RegisterEventHandler(_callMonitor);
     EventController.RegisterEventHandler(_eventMonitor);
     EventController.RegisterEventHandler(new HeartbeatEventMonitor());
     cpus = new List<WrappedPerformanceCounter>();
     for (int x = 0; x < Environment.ProcessorCount; x++)
     {
         cpus.Add(new WrappedPerformanceCounter("Processor", "% Processor Time", x.ToString()));
     }
     memory = new WrappedPerformanceCounter("Process", "Working Set", "_Total");
     processes_cpu = new List<WrappedPerformanceCounter>();
     processes_mem = new List<WrappedPerformanceCounter>();
     processes_threads = new WrappedPerformanceCounter("Process", "Thread Count", "_Total");
     current_process_thread = new WrappedPerformanceCounter("Process", "Thread Count", "_Current");
     current_process_cpu = new WrappedPerformanceCounter("Process", "% Processor Time", "_Current");
     current_process_mem = new WrappedPerformanceCounter("Process", "Working Set", "_Current");
     foreach (Process p in Process.GetProcesses())
     {
         if (p.ProcessName != "Idle")
         {
             processes_cpu.Add(new WrappedPerformanceCounter("Process", "% Processor Time", p.ProcessName));
             processes_mem.Add(new WrappedPerformanceCounter("Process", "Working Set", p.ProcessName));
         }
     }
     networks = new List<WrappedPerformanceCounter>();
     foreach (string str in new PerformanceCounterCategory("Network Interface").GetInstanceNames())
     {
         networks.Add(new WrappedPerformanceCounter("Network Interface", "Bytes Recieved/sec", str));
         networks.Add(new WrappedPerformanceCounter("Network Interface", "Bytes Sent/sec", str));
     }
     EventController.RegisterEventHandler(this);
 }