static OutputUnits makePerfMonGraphs(string file) { Excel.Application excelApp = null; Excel.Workbook workbook = null; Excel.Sheets sheets = null; Excel.Worksheet dataSheet = null; Excel.Worksheet newSheet = null; Excel.ChartObjects xlChart = null; Excel.Range dataY = null; Excel.Chart memChart = null; Excel.Chart diskChart = null; Excel.Chart cpuChart = null; Excel.Chart netChart = null; Excel.Axis xAxis = null; OutputUnits csData = null; bool leaking = false; bool highcpu = false; string exitFile = ""; try { excelApp = new Excel.Application(); string dir = file.Substring(0, file.LastIndexOf("\\") + 1); string fm = file.Substring(0, file.Length - 4).Substring(file.LastIndexOf("\\") + 1); workbook = excelApp.Workbooks.Open(file, 0, false, 6, Type.Missing, Type.Missing, Type.Missing, XlPlatform.xlWindows, ",", true, false, 0, false, false, false); sheets = workbook.Sheets; dataSheet = sheets[1]; dataSheet.Name = "data"; dataSheet.get_Range("A2:A2", Type.Missing).EntireRow.Delete(XlDeleteShiftDirection.xlShiftUp);//garbage row newSheet = (Worksheet)sheets.Add(Type.Missing, dataSheet, Type.Missing, Type.Missing); newSheet.Name = "results"; xlChart = (Excel.ChartObjects)newSheet.ChartObjects(Type.Missing); memChart = xlChart.Add(20, 100, 450, 175).Chart; diskChart = xlChart.Add(20, 280, 450, 175).Chart; cpuChart = xlChart.Add(500, 100, 450, 175).Chart; netChart = xlChart.Add(500, 280, 450, 175).Chart; int rowTotal = dataSheet.UsedRange.Rows.Count; int colTotal = dataSheet.UsedRange.Columns.Count; dataSheet.get_Range("A2", "A" + rowTotal).NumberFormat = "m/d/yyyy h:mm"; string ttime = dataSheet.Cells[2, 1].Value.ToString(); Array availMem = (System.Array)dataSheet.get_Range("C2", "C" + rowTotal).Value; Array cpuTotal = (System.Array)dataSheet.get_Range("D2", "D" + rowTotal).Value; Array diskTotal = (System.Array)dataSheet.get_Range("B2", "B" + rowTotal).Value; dataSheet.Cells[1, colTotal + 1] = "Total LAN (Bytes Total/Sec)"; double[] netties = new double[rowTotal - 1]; for (int i = 2; i <= rowTotal; i++) { if (colTotal > 5) { Array netLine = (System.Array)dataSheet.get_Range(xlStr(5) + i, xlStr(colTotal) + i).Value; double netLineTotal = 0; for (int j = 1; j <= netLine.Length; j++) { netLineTotal += Convert.ToDouble(netLine.GetValue(1, j)); } netties[i - 2] = netLineTotal; dataSheet.Cells[i, colTotal + 1] = netLineTotal; } else { dataSheet.Cells[i, colTotal + 1] = "0"; } } #region BuildCounters double[] mems = ColToDouble(availMem); double[] cpus = ColToDouble(cpuTotal); double[] disks = ColToDouble(diskTotal); //netties[] double avgCPUs = cpus.Average(); PCounter CPU = new PCounter(avgCPUs, cpus.Max(), cpus.Min()); PCounter MEM = new PCounter(mems.Average(), mems.Max(), mems.Min()); PCounter DISK = new PCounter(disks.Average(), disks.Max(), disks.Min()); PCounter NETS = new PCounter(netties.Average(), netties.Max(), netties.Min()); if (avgCPUs > 40) { highcpu = true; } #endregion #region leakCheck double[] eqMB = new double[2]; List <double> memList = new List <double>(); int cX = availMem.Length; for (int i = 1; i < rowTotal - 1; i++) { memList.Add(Convert.ToDouble(availMem.GetValue(i, 1))); } eqMB = LeastSquares(memList); double stdD1 = StandardDev(memList); List <double> memList2 = sigma(memList, stdD1, eqMB); cX = memList2.Count(); eqMB = LeastSquares(memList2); double stdD2 = StandardDev(memList2) * 1.2; List <double> memList3 = sigma(memList2, stdD2, eqMB); eqMB = LeastSquares(memList3); if (eqMB[0] < 0) { leaking = true; newSheet.get_Range("E4", Type.Missing).Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Tomato); } #endregion #region formatting string lan = xlStr(colTotal + 1); newSheet.get_Range("A1", Type.Missing).EntireColumn.ColumnWidth = 12; newSheet.get_Range("A1", Type.Missing).EntireColumn.HorizontalAlignment = XlHAlign.xlHAlignRight; newSheet.get_Range("A2", Type.Missing).EntireRow.HorizontalAlignment = XlHAlign.xlHAlignCenter; newSheet.Cells[4, 5] = eqMB[0]; newSheet.Cells[2, 2] = "Avg"; newSheet.Cells[2, 3] = "Min"; newSheet.Cells[2, 4] = "Max"; newSheet.Cells[2, 5] = "Slope(3Sigma)"; newSheet.Cells[3, 1] = "CPU"; newSheet.Cells[3, 2] = "=AVERAGE(data!D:D)"; newSheet.Cells[3, 3] = "=MIN(data!D:D)"; newSheet.Cells[3, 4] = "=MAX(data!D:D)"; newSheet.Cells[4, 1] = "Avail.RAM"; newSheet.Cells[4, 2] = "=AVERAGE(data!C:C)"; newSheet.Cells[4, 3] = "=MIN(data!C:C)"; newSheet.Cells[4, 4] = "=MAX(data!C:C)"; newSheet.Cells[5, 1] = "LAN Usage"; newSheet.Cells[5, 2] = "=AVERAGE(data!" + lan + ":" + lan + ")"; newSheet.Cells[5, 3] = "=MIN(data!" + lan + ":" + lan + ")"; newSheet.Cells[5, 4] = "=MAX(data!" + lan + ":" + lan + ")"; newSheet.Cells[6, 1] = "Disk Usage"; newSheet.Cells[6, 2] = "=AVERAGE(data!B:B)"; newSheet.Cells[6, 3] = "=MIN(data!B:B)"; newSheet.Cells[6, 4] = "=MAX(data!B:B)"; #endregion #region memChart dataY = dataSheet.Range["C1", "C" + rowTotal]; memChart.SetSourceData(dataY, Type.Missing); memChart.ChartType = XlChartType.xlXYScatterLinesNoMarkers; memChart.HasLegend = false; xAxis = (Axis)memChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); xAxis.MaximumScaleIsAuto = false; xAxis.MaximumScale = rowTotal + 1; xAxis.MinimumScaleIsAuto = false; xAxis.MinimumScale = 0; #endregion #region diskChart dataY = dataSheet.Range["B1", "B" + rowTotal]; diskChart.SetSourceData(dataY, Type.Missing); diskChart.ChartType = XlChartType.xlXYScatterLinesNoMarkers; diskChart.HasLegend = false; xAxis = (Axis)diskChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); xAxis.MaximumScaleIsAuto = false; xAxis.MaximumScale = rowTotal + 1; xAxis.MinimumScaleIsAuto = false; xAxis.MinimumScale = 0; #endregion #region cpuChart dataY = dataSheet.Range["D1", "D" + rowTotal]; cpuChart.SetSourceData(dataY, Type.Missing); cpuChart.ChartType = XlChartType.xlXYScatterLinesNoMarkers; cpuChart.HasLegend = false; xAxis = (Axis)cpuChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); xAxis.MaximumScaleIsAuto = false; xAxis.MaximumScale = rowTotal + 1; xAxis.MinimumScaleIsAuto = false; xAxis.MinimumScale = 0; #endregion #region netChart dataY = dataSheet.Range[xlStr(colTotal + 1) + "1", xlStr(colTotal + 1) + rowTotal]; netChart.SetSourceData(dataY, Type.Missing); netChart.ChartType = XlChartType.xlXYScatterLinesNoMarkers; netChart.HasLegend = false; xAxis = (Axis)netChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); xAxis.MaximumScaleIsAuto = false; xAxis.MaximumScale = rowTotal + 1; xAxis.MinimumScaleIsAuto = false; xAxis.MinimumScale = 0; #endregion string host = Path.GetFileNameWithoutExtension(dir + fm); csData = new OutputUnits(host, ttime + " time chunks: " + (rowTotal - 1), CPU, MEM, NETS, DISK, leaking, highcpu); exitFile = dir + fm; excelApp.DisplayAlerts = false; workbook.SaveAs(@exitFile, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing); workbook.Close(true, Type.Missing, Type.Missing); excelApp.Quit(); //releaseObject(sC); //releaseObject(myChart); } catch { Console.WriteLine("Had issues interacting with your Excel installation...maybe try a restart?"); //using (StreamWriter outfile = File.AppendText("output.txt")) { // outfile.WriteLine("Did have issues interacting with Excel on " + file); //} } finally { releaseObject(xAxis); releaseObject(dataY); releaseObject(diskChart); releaseObject(memChart); releaseObject(cpuChart); releaseObject(netChart); releaseObject(xlChart); releaseObject(newSheet); releaseObject(dataSheet); releaseObject(sheets); releaseObject(workbook); releaseObject(excelApp); } return(csData); }
static OutputUnits makePerfMonGraphs(string file) { Excel.Application excelApp = null; Excel.Workbook workbook = null; Excel.Sheets sheets = null; Excel.Worksheet dataSheet = null; Excel.Worksheet newSheet = null; Excel.ChartObjects xlChart = null; Excel.Range dataY = null; Excel.Chart memChart = null; Excel.Chart diskChart = null; Excel.Chart cpuChart = null; Excel.Chart netChart = null; Excel.Axis xAxis = null; OutputUnits csData = null; bool leaking = false; bool highcpu = false; string exitFile = ""; try { excelApp = new Excel.Application(); string dir = file.Substring(0, file.LastIndexOf("\\") + 1); string fm = file.Substring(0, file.Length - 4).Substring(file.LastIndexOf("\\") + 1); workbook = excelApp.Workbooks.Open(file, 0, false, 6, Type.Missing, Type.Missing, Type.Missing, XlPlatform.xlWindows, ",", true, false, 0, false, false, false); sheets = workbook.Sheets; dataSheet = sheets[1]; dataSheet.Name = "data"; dataSheet.get_Range("A2:A2", Type.Missing).EntireRow.Delete(XlDeleteShiftDirection.xlShiftUp);//garbage row newSheet = (Worksheet)sheets.Add(Type.Missing, dataSheet, Type.Missing, Type.Missing); newSheet.Name = "results"; xlChart = (Excel.ChartObjects)newSheet.ChartObjects(Type.Missing); memChart = xlChart.Add(20, 100, 450, 175).Chart; diskChart = xlChart.Add(20, 280, 450, 175).Chart; cpuChart = xlChart.Add(500, 100, 450, 175).Chart; netChart = xlChart.Add(500, 280, 450, 175).Chart; int rowTotal = dataSheet.UsedRange.Rows.Count; int colTotal = dataSheet.UsedRange.Columns.Count; dataSheet.get_Range("A2", "A" + rowTotal).NumberFormat ="m/d/yyyy h:mm"; string ttime = dataSheet.Cells[2, 1].Value.ToString(); Array availMem = (System.Array)dataSheet.get_Range("C2", "C" + rowTotal).Value; Array cpuTotal = (System.Array)dataSheet.get_Range("D2", "D" + rowTotal).Value; Array diskTotal = (System.Array)dataSheet.get_Range("B2", "B" + rowTotal).Value; dataSheet.Cells[1, colTotal + 1] = "Total LAN (Bytes Total/Sec)"; double[] netties = new double[rowTotal-1]; for (int i = 2; i <= rowTotal; i++) { if (colTotal > 5) { Array netLine = (System.Array)dataSheet.get_Range(xlStr(5)+ i, xlStr(colTotal)+ i).Value; double netLineTotal = 0; for(int j=1;j<=netLine.Length;j++){ netLineTotal += Convert.ToDouble(netLine.GetValue(1,j)); } netties[i - 2] = netLineTotal; dataSheet.Cells[i, colTotal + 1] = netLineTotal; }else{ dataSheet.Cells[i, colTotal + 1] = "0"; } } #region BuildCounters double[] mems = ColToDouble(availMem); double[] cpus = ColToDouble(cpuTotal); double[] disks = ColToDouble(diskTotal); //netties[] double avgCPUs = cpus.Average(); PCounter CPU = new PCounter(avgCPUs, cpus.Max(), cpus.Min()); PCounter MEM = new PCounter(mems.Average(), mems.Max(), mems.Min()); PCounter DISK = new PCounter(disks.Average(), disks.Max(), disks.Min()); PCounter NETS = new PCounter(netties.Average(), netties.Max(), netties.Min()); if (avgCPUs > 40) { highcpu = true; } #endregion #region leakCheck double[] eqMB = new double[2]; List<double> memList = new List<double>(); int cX = availMem.Length; for (int i = 1; i < rowTotal - 1; i++) { memList.Add(Convert.ToDouble(availMem.GetValue(i, 1))); } eqMB = LeastSquares(memList); double stdD1 = StandardDev(memList); List<double> memList2 = sigma(memList, stdD1, eqMB); cX = memList2.Count(); eqMB = LeastSquares(memList2); double stdD2 = StandardDev(memList2)*1.2; List<double> memList3 = sigma(memList2, stdD2, eqMB); eqMB = LeastSquares(memList3); if (eqMB[0] < 0) { leaking = true; newSheet.get_Range("E4", Type.Missing).Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Tomato); } #endregion #region formatting string lan = xlStr(colTotal + 1); newSheet.get_Range("A1", Type.Missing).EntireColumn.ColumnWidth = 12; newSheet.get_Range("A1", Type.Missing).EntireColumn.HorizontalAlignment = XlHAlign.xlHAlignRight; newSheet.get_Range("A2", Type.Missing).EntireRow.HorizontalAlignment = XlHAlign.xlHAlignCenter; newSheet.Cells[4, 5] = eqMB[0]; newSheet.Cells[2, 2] = "Avg"; newSheet.Cells[2, 3] = "Min"; newSheet.Cells[2, 4] = "Max"; newSheet.Cells[2, 5] = "Slope(3Sigma)"; newSheet.Cells[3, 1] = "CPU"; newSheet.Cells[3, 2] = "=AVERAGE(data!D:D)"; newSheet.Cells[3, 3] = "=MIN(data!D:D)"; newSheet.Cells[3, 4] = "=MAX(data!D:D)"; newSheet.Cells[4, 1] = "Avail.RAM"; newSheet.Cells[4, 2] = "=AVERAGE(data!C:C)"; newSheet.Cells[4, 3] = "=MIN(data!C:C)"; newSheet.Cells[4, 4] = "=MAX(data!C:C)"; newSheet.Cells[5, 1] = "LAN Usage"; newSheet.Cells[5, 2] = "=AVERAGE(data!"+lan+":"+lan+")"; newSheet.Cells[5, 3] = "=MIN(data!"+lan+":"+lan+")"; newSheet.Cells[5, 4] = "=MAX(data!" + lan + ":" + lan + ")"; newSheet.Cells[6, 1] = "Disk Usage"; newSheet.Cells[6, 2] = "=AVERAGE(data!B:B)"; newSheet.Cells[6, 3] = "=MIN(data!B:B)"; newSheet.Cells[6, 4] = "=MAX(data!B:B)"; #endregion #region memChart dataY = dataSheet.Range["C1", "C" + rowTotal]; memChart.SetSourceData(dataY, Type.Missing); memChart.ChartType = XlChartType.xlXYScatterLinesNoMarkers; memChart.HasLegend = false; xAxis = (Axis)memChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); xAxis.MaximumScaleIsAuto = false; xAxis.MaximumScale = rowTotal + 1; xAxis.MinimumScaleIsAuto = false; xAxis.MinimumScale = 0; #endregion #region diskChart dataY = dataSheet.Range["B1", "B" + rowTotal]; diskChart.SetSourceData(dataY, Type.Missing); diskChart.ChartType = XlChartType.xlXYScatterLinesNoMarkers; diskChart.HasLegend = false; xAxis = (Axis)diskChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); xAxis.MaximumScaleIsAuto = false; xAxis.MaximumScale = rowTotal + 1; xAxis.MinimumScaleIsAuto = false; xAxis.MinimumScale = 0; #endregion #region cpuChart dataY = dataSheet.Range["D1", "D" + rowTotal]; cpuChart.SetSourceData(dataY, Type.Missing); cpuChart.ChartType = XlChartType.xlXYScatterLinesNoMarkers; cpuChart.HasLegend = false; xAxis = (Axis)cpuChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); xAxis.MaximumScaleIsAuto = false; xAxis.MaximumScale = rowTotal + 1; xAxis.MinimumScaleIsAuto = false; xAxis.MinimumScale = 0; #endregion #region netChart dataY = dataSheet.Range[xlStr(colTotal + 1)+"1", xlStr(colTotal + 1) + rowTotal]; netChart.SetSourceData(dataY, Type.Missing); netChart.ChartType = XlChartType.xlXYScatterLinesNoMarkers; netChart.HasLegend = false; xAxis = (Axis)netChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); xAxis.MaximumScaleIsAuto = false; xAxis.MaximumScale = rowTotal + 1; xAxis.MinimumScaleIsAuto = false; xAxis.MinimumScale = 0; #endregion string host = Path.GetFileNameWithoutExtension(dir + fm); csData = new OutputUnits(host, ttime+" time chunks: "+(rowTotal-1), CPU, MEM, NETS, DISK, leaking, highcpu); exitFile = dir + fm; excelApp.DisplayAlerts = false; workbook.SaveAs(@exitFile, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing); workbook.Close(true, Type.Missing, Type.Missing); excelApp.Quit(); //releaseObject(sC); //releaseObject(myChart); } catch { Console.WriteLine("Had issues interacting with your Excel installation...maybe try a restart?"); //using (StreamWriter outfile = File.AppendText("output.txt")) { // outfile.WriteLine("Did have issues interacting with Excel on " + file); //} } finally { releaseObject(xAxis); releaseObject(dataY); releaseObject(diskChart); releaseObject(memChart); releaseObject(cpuChart); releaseObject(netChart); releaseObject(xlChart); releaseObject(newSheet); releaseObject(dataSheet); releaseObject(sheets); releaseObject(workbook); releaseObject(excelApp); } return csData; }
static void Main(string[] args) { List <string> asyncT = new List <string>(); List <string> errors = new List <string>(); Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Running automatic full reports on all nmon-based files and blg files in this recursive directory..."); Console.WriteLine("Review .\\Output.txt when completed for a detailed report."); string[] zips = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.zip", SearchOption.AllDirectories).ToArray(); if (zips.Count() > 0) { try {//can you .NET4.5? Parallel.ForEach(zips, z => { using (ZipArchive archive = ZipFile.OpenRead(z)) { foreach (ZipArchiveEntry entry in archive.Entries) { string exName = ""; if (entry.FullName.Contains("nmon")) { try {//can you unzip that file? entry.ExtractToFile(Path.Combine(z.Substring(0, z.LastIndexOf('\\')), entry.Name), true); Console.WriteLine("Unzipped " + entry.Name); } catch { errors.Add("Had trouble unzipping this file: " + z); } } else if (entry.Name.Contains(".blg")) { try {//can you unzip that file? //OVERWRITE SAME FOLDER MUHGAWD pls fix string fzName = entry.FullName; int ixf = fzName.IndexOf("/"); exName = fzName.Substring(0, ixf); string nfhx = Path.Combine(z.Substring(0, z.LastIndexOf('\\')), exName); //int inc = 1; while (Directory.Exists(nfhx)) { nfhx += "x"; } //entry.ExtractToDirectory(nfhx); archive.ExtractToDirectory(nfhx); Console.WriteLine("Unzipped " + exName); break; } catch { errors.Add("Had trouble unzipping " + exName + " please check for completion."); } } } } //using (ZipArchive archive = ZipFile.Open(z, ZipArchiveMode.Read)) { // foreach (ZipArchiveEntry entry in archive.Entries) { // if (entry.FullName.Contains("blg")) { // try {//can you unzip that file? // string fzName = entry.FullName; // int ixf = fzName.IndexOf("/"); // string exName = fzName.Substring(0, ixf); // string nfhx = Path.Combine(z.Substring(0, z.LastIndexOf('\\')), exName); // //entry.ExtractToDirectory(nfhx); // archive.ExtractToDirectory(nfhx); // Console.WriteLine("Unzipped " + exName); // } catch { // errors.Add("Had trouble unzipping this file: " + z); // } // } // } //} }); } catch { Console.WriteLine("Your System is not updated to support .NET Framework 4.5, please update!!!"); errors.Add("Your System is not updated to support .NET Framework 4.5, please update!!!"); errors.Add("Could not unzip and process, exiting with errors."); } } string here = Directory.GetCurrentDirectory(); string[] nmonfiles = Directory.GetFiles(here, "*.*", SearchOption.AllDirectories).Where(name => name.Substring(name.LastIndexOf('\\'), name.Length - name.LastIndexOf('\\')).Contains("nmon")).Where(name => !name.Contains(".zip")).ToArray(); string[] blgfiles = Directory.GetFiles(here, "*.blg", SearchOption.AllDirectories); #region perfmons List <string> csvfiles = new List <string>(); if (blgfiles.Count() > 0) { string filterText = @here + @"\CB745.txt"; using (StreamWriter sw = File.CreateText(filterText)) { sw.WriteLine(@"\PhysicalDisk(_Total)\% Disk Time"); sw.WriteLine(@"\Memory\Available MBytes"); sw.WriteLine(@"\Processor(_Total)\% Processor Time "); sw.WriteLine(@"\Network Interface(*)\Bytes Total/sec "); } Console.WriteLine("Relogging Windows PerfMons."); System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = "CMD.exe"; //Parallel.ForEach(blgfiles, blgfile => { foreach (string blgfile in blgfiles) { File.Delete(blgfile.Substring(0, blgfile.Length - 4) + ".csv"); startInfo.Arguments = "/C relog " + blgfile + " -cf " + filterText + " -f csv -o " + blgfile.Substring(0, blgfile.Length - 4) + ".csv"; csvfiles.Add(blgfile.Substring(0, blgfile.Length - 4) + ".csv"); process.StartInfo = startInfo; process.Start(); process.WaitForExit(); //}); } File.Delete(filterText); Console.WriteLine("Windows PerfMons can take a few minutes."); //string temptest = @"T:\Progs\nmon\sherpanalyzer\sherpanalyzer\bin\x64\Debug\JCRE2_DAC1\000001\PerfMonitor.csv"; List <csvfile> AllCSVs = new List <csvfile>(); foreach (string csvf in csvfiles) { csvfile csvTemp = new csvfile(csvf); AllCSVs.Add(csvTemp); } string[] TotalHosts = (from x in AllCSVs select x.hostname).Distinct().ToArray(); var sortedHosts = from x in AllCSVs orderby x.date group x by x.hostname into newgroup orderby newgroup.Key select newgroup; List <string> MergedCSVs = new List <string>(); //List<string> completedFiles = new List<string>(); foreach (var shost in sortedHosts) { List <string> hoststoCombine = new List <string>(); Console.WriteLine("Sherpalyzing- " + shost.Key); foreach (var dda in shost) { hoststoCombine.Add(dda.filelocation); } MergedCSVs.Add(combineCSVs(hoststoCombine, here, shost.Key)); } Parallel.ForEach(MergedCSVs, mcsv => { OutputUnits resultBLG = makePerfMonGraphs(mcsv); asyncT.Add(resultBLG.display()); if (resultBLG.isLeaking) { Console.WriteLine("Possible Memory leak found in " + Path.GetFileNameWithoutExtension(mcsv)); } if (resultBLG.highCPU) { Console.WriteLine("Possible high CPU usage found in " + Path.GetFileNameWithoutExtension(mcsv)); } }); foreach (csvfile mcsv in AllCSVs) { File.Delete(mcsv.filelocation); } foreach (string mcsv in MergedCSVs) { try { File.Delete(mcsv); } catch { Console.WriteLine("FILE IN USE! Excel frozen?"); } } //asyncT.Add("Completed Windows PerfMon analysis. "+System.Environment.NewLine); } else { asyncT.Add("No blg (windows) files were found in this directory."); } #endregion #region nmon if (nmonfiles.Count() < 1) { asyncT.Add("No nmon (redhat) files were found in this directory."); } else { //asyncT.Add("Starting nmon analysis"); Parallel.ForEach(nmonfiles, nmons => { try { //only try; do not. unhandled crashes; doing will cause. asyncT.Add(readSherpa(nmons, true)); } catch { //when someone makes readSherpa crash, tell them there was a bad file in there errors.Add("Had trouble sherpalyzing this file: " + nmons); } }); if (errors.Count == 0) { asyncT.Add("No errors sherpalyzing!"); } else { foreach (string e in errors) { asyncT.Add(e); } } // outputFile(asyncT); Console.WriteLine("Finished"); String graphs = ""; if (args.Length != 0) { Console.WriteLine("Create graphs? (y/n)"); graphs = Console.ReadLine(); } else { Console.WriteLine("Starting automated graph creation."); graphs = "y"; } if (graphs.Length > 0) { if (graphs.Substring(0, 1) == "y" || graphs.Substring(0, 1) == "Y") { Console.WriteLine("Working with Excel in the background."); Console.WriteLine("This may take several minutes..."); string[] CSVs = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.csv", SearchOption.TopDirectoryOnly).ToArray(); int cL = CSVs.Length; int i = 1; Parallel.ForEach(CSVs, csvF => { makeGraphs(csvF); File.Delete(csvF); Console.WriteLine("Completed " + i + " of " + cL); i++; }); } } } outputFile(asyncT); #endregion }