public static void CollectMemoryDumps(bool iisMemDumps, bool osMemDumps) { List <string> processList = new List <string>(); if (iisMemDumps && osMemDumps) { processList.AddRange(new List <string>() { "w3wp", "deployment_controller", "deployment_service", "scheduler", "log_service" }); } else if (!iisMemDumps && osMemDumps) { processList.AddRange(new List <string>() { "deployment_controller", "deployment_service", "scheduler", "log_service" }); } else if (iisMemDumps && !osMemDumps) { processList.AddRange(new List <string>() { "w3wp" }); } else { return; } string memoryDumpsPath = Path.Combine(_tempFolderPath, "MemoryDumps"); Directory.CreateDirectory(memoryDumpsPath); CmdLineCommand command; ThreadDumpCollector dc = new ThreadDumpCollector(5000); Dictionary <string, string> processDict = new Dictionary <string, string> { { "log_service", "LogServer.exe" }, { "deployment_service", "DeployService.exe" }, { "deployment_controller", "CompilerService.exe" }, { "scheduler", "Scheduler.exe" }, { "w3wp", "w3wp.exe" } }; try { foreach (string processTag in processList) { FileLogger.TraceLog("Collecting " + processTag + " memory dumps... "); string processName = processDict[processTag]; List <int> pids = dc.GetProcessIdsByName(processName); foreach (int pid in dc.GetProcessIdsByFilename(processName)) { string pidSuf = pids.Count > 1 ? "_" + pid : ""; string filename = "memdump_" + processTag + pidSuf + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".dmp"; FileLogger.TraceLog(" - PID " + pid + " - "); command = new CmdLineCommand("procdump64.exe -ma " + pid + " /accepteula " + "\"" + Path.Combine(memoryDumpsPath, filename) + "\""); command.Execute(); } } } catch (Exception e) { FileLogger.LogError("Failed to get memory dump: ", e.Message + e.StackTrace); } }
public static void CollectMemoryDumpsProgram(bool getIisMemDumps, bool getOsMemDumps) { FileLogger.TraceLog(string.Format("Initiating collection of thread dumps...(IIS memory dumps: {0} ; OutSystems Services memory dumps: {1})", getIisMemDumps, getOsMemDumps)); CollectMemoryDumps(getIisMemDumps, getOsMemDumps); }
private static void CollectThreadDumps(bool iisThreads, bool osThreads) { List <string> processList = new List <string>(); if (iisThreads && osThreads) { processList.AddRange(new List <string>() { "w3wp", "deployment_controller", "deployment_service", "scheduler", "log_service" }); } else if (!iisThreads && osThreads) { processList.AddRange(new List <string>() { "deployment_controller", "deployment_service", "scheduler", "log_service" }); } else if (iisThreads && !osThreads) { processList.AddRange(new List <string>() { "w3wp" }); } else { return; } string threadDumpsPath = Path.Combine(_tempFolderPath, "ThreadDumps"); Directory.CreateDirectory(threadDumpsPath); ThreadDumpCollector dc = new ThreadDumpCollector(5000); Dictionary <string, string> processDict = new Dictionary <string, string> { { "log_service", "LogServer.exe" }, { "deployment_service", "DeployService.exe" }, { "deployment_controller", "CompilerService.exe" }, { "scheduler", "Scheduler.exe" }, { "w3wp", "w3wp.exe" } }; try { foreach (string processTag in processList) { FileLogger.TraceLog("Collecting " + processTag + " thread dumps... "); string processName = processDict[processTag]; List <int> pids = dc.GetProcessIdsByName(processName); foreach (int pid in dc.GetProcessIdsByFilename(processName)) { string pidSuf = pids.Count > 1 ? "_" + pid : ""; string filename = "threads_" + processTag + pidSuf + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".log"; using (TextWriter writer = new StreamWriter(File.Create(Path.Combine(threadDumpsPath, filename)))) { writer.WriteLine(DateTime.Now.ToString()); writer.WriteLine(dc.GetThreadDump(pid)); } } } } catch (Exception e) { FileLogger.LogError("Failed to get thread dump: ", e.Message + e.StackTrace); } }
public static void CollectThreadDumpsProgram(bool getIisThreadDumps, bool getOsThreadDumps) { FileLogger.TraceLog(string.Format("Initiating collection of thread dumps...(IIS thread dumps: {0} ; OutSystems Services thread dumps: {1})", getIisThreadDumps, getOsThreadDumps)); CollectThreadDumps(getIisThreadDumps, getOsThreadDumps); // evaluate if this method is really necessary }