private Dictionary <string, string> getProcessMemoryUsage(Connection wmiConnection) { Win32_Process p = new Win32_Process(wmiConnection); IList <Dictionary <string, string> > mUsed = p.GetPropertyValues(); //List<string> memoryUsed = new List<string>(); Dictionary <string, string> memoryUsed = new Dictionary <string, string>(); string memUse = string.Empty; string parentPID = string.Empty; foreach (Dictionary <string, string> processInfo in mUsed) { if (processInfo.ContainsValue("javaw.exe")) { processInfo.TryGetValue("ParentProcessId", out parentPID); if (parentPID != null && parentPID != string.Empty) { string parentPName = string.Empty; string pid = string.Empty; bool isCSDMProcess = false; foreach (Dictionary <string, string> processInfo1 in mUsed) { processInfo1.TryGetValue("Caption", out parentPName); processInfo1.TryGetValue("ProcessId", out pid); if (parentPName == "DM.exe" && pid == parentPID) { isCSDMProcess = true; break; } } if (isCSDMProcess) { processInfo.TryGetValue("PageFileUsage", out memUse); } if (memUse != string.Empty && isCSDMProcess) { string strCommandLine = string.Empty; processInfo.TryGetValue("CommandLine", out strCommandLine); if (strCommandLine.Contains("derbyrun.jar")) { memoryUsed.Add(memUsagepList.derby, memUse); } if (strCommandLine.Contains("pas_server") || strCommandLine.Contains("pas_client")) { memoryUsed.Add(memUsagepList.jetty, memUse); } } } } if (processInfo.ContainsValue("CSAcqDmn.exe")) { processInfo.TryGetValue("PageFileUsage", out memUse); if (memUse != string.Empty) { memoryUsed.Add(memUsagepList.deamon, memUse); } } } return(memoryUsed); }
private Dictionary<string, string> getProcessMemoryUsage(Connection wmiConnection) { Win32_Process p = new Win32_Process(wmiConnection); IList<Dictionary<string, string>> mUsed = p.GetPropertyValues(); //List<string> memoryUsed = new List<string>(); Dictionary<string, string> memoryUsed = new Dictionary<string, string>(); string memUse = string.Empty; string parentPID = string.Empty; foreach (Dictionary<string, string> processInfo in mUsed) { if (processInfo.ContainsValue("javaw.exe")) { processInfo.TryGetValue("ParentProcessId", out parentPID); if (parentPID != null && parentPID != string.Empty) { string parentPName = string.Empty; string pid = string.Empty; bool isCSDMProcess = false; foreach (Dictionary<string, string> processInfo1 in mUsed) { processInfo1.TryGetValue("Caption", out parentPName); processInfo1.TryGetValue("ProcessId", out pid); if (parentPName == "DM.exe" && pid == parentPID) { isCSDMProcess = true; break; } } if (isCSDMProcess) processInfo.TryGetValue("PageFileUsage", out memUse); if (memUse != string.Empty && isCSDMProcess) { string strCommandLine = string.Empty; processInfo.TryGetValue("CommandLine", out strCommandLine); if (strCommandLine.Contains("derbyrun.jar")) memoryUsed.Add(memUsagepList.derby, memUse); if (strCommandLine.Contains("pas_server") || strCommandLine.Contains("pas_client")) memoryUsed.Add(memUsagepList.jetty, memUse); } } } if (processInfo.ContainsValue("CSAcqDmn.exe")) { processInfo.TryGetValue("PageFileUsage", out memUse); if (memUse != string.Empty) { memoryUsed.Add(memUsagepList.deamon, memUse); } } } return memoryUsed; }