public void poll(IDictionary <string, ProcessData> processData, bool allProcesses) { var threadInfoTable = ThreadTables.makeThreadInfoTable(); long threadInfoTableCount = 0; ICollection <Process> processList; if (allProcesses) { processList = Process.GetProcesses(); } else { processList = new List <Process>(); foreach (string processName in processData.Keys) { processList.AddRange(Process.GetProcessesByName(processName)); } } pollProcessList(processList, processData, threadInfoTable, ref threadInfoTableCount); if (threadInfoTableCount > 0) { OutputSerializer.Write(threadInfoTable, false); } }
protected void addInfoToTable(Process process, DataTable table, int threadId, long ticks, DateTime pollCycleTimeStamp, DateTime startTimeStamp, bool threadLevel, IO_COUNTERS ioCounters) { ThreadInfo threadInfo = new ThreadInfo(); threadInfo.processId = process.Id; threadInfo.threadId = threadId; threadInfo.cpuTime = ticks; threadInfo.pollTimeStamp = DateTime.UtcNow; threadInfo.pollCycleTimeStamp = pollCycleTimeStamp; threadInfo.startTimeStamp = startTimeStamp; threadInfo.host = HostName; threadInfo.threadLevel = threadLevel; threadInfo.process = StringUtil.ReplaceSubString(process.ProcessName, "^(control-|run-)"); threadInfo.readOperationCount = ioCounters.ReadOperationCount; threadInfo.writeOperationCount = ioCounters.WriteOperationCount; threadInfo.otherOperationCount = ioCounters.OtherOperationCount; threadInfo.readTransferCount = ioCounters.ReadTransferCount; threadInfo.writeTransferCount = ioCounters.WriteTransferCount; threadInfo.otherTransferCount = ioCounters.OtherTransferCount; // When on process level add threadCount as well if (threadId == -1) { threadInfo.threadCount = process.Threads.Count; threadInfo.workingSet = process.WorkingSet64; } ThreadTables.addToTable(table, threadInfo); }