private static List<process> getBLGdata(string p1, string p2)
 {
     List<string[]> mems = getRows(p2);
       List<string[]> cpus = getRows(p1);
       List<process> processes = new List<process>();
       int cols = cpus[0].Length;
       int rows = cpus.Count();
       for (int i = 1; i < cols; i++) {//start on column 1
     for (int j = 1; j < rows; j++) {//start on row 2
       string cmd = mems[0][i];
       int fM = cmd.IndexOf("(");
       int lM = cmd.IndexOf(")");
       string m = mems[j][i];
       m = (Convert.ToDouble(m) / 1024).ToString();
       string c = cpus[j][i];
       string cm = cmd.Substring(fM + 1, lM - fM - 1);
       if(cm.IndexOf("#")>=0){
     cm = cm.Remove(cm.IndexOf("#"));
       }
       bool found = false;
       foreach (process x in processes) {
     if (x.command == cm) {
     //if (x.pid == i) {
       x.add(m, c);
       found = true;
       break;
     }
       }
       if (!found) {
     process item = new process(i.ToString(), m, c, cm);
     processes.Add(item);
       }
     }
       }
     return processes;
 }
        static List<process> readSherpa(string filename, bool print)
        {
            string line;
              string host = "new";
              int cores = 0;
              List<process> processes = new List<process>();
              List<string> summary = new List<string>();
              List<string> times = new List<string>();
              List<double> cpu_all_usr = new List<double>();
              List<double> memsum = new List<double>();
              List<string> disklabels = new List<string>();
              List<double> disksizes = new List<double>();
              List<string> disksizesb = new List<string>();
              List<string> netwuts = new List<string>();
              List<List<string>> topList = new List<List<string>>();
              List<double>[] diskbusy;
              List<double>[] netties;
              string[] dix;

              string datime = "";
              string ddate = "";
              string ttime = "";
              //string warnings = "";

              using (StreamReader reader = new StreamReader(filename)) {

            /*read in each line of text then do stuff with it*/
            //small while loop only does maybe 50lines before breaking
            while ((line = reader.ReadLine()) != null) {//this is the prelim loop to make the primary loop go quicker
              summary.Add(line);
              string[] values = line.Split(',');
              if (values[1] == "time") {
            if (values[0] == "AAA")
              ttime = values[2];
            datime = String.Join("", values[2].Split(new[] { ':', '.' }));
              }
              if (values[1] == "date") {
            if (values[0] == "AAA")
              ddate = values[2];
            datime = String.Join("", values[2].Split('-')) + "_" + datime;
              }
              if (values[1] == "host")
            host = values[2];
              if (values[1] == "cpus")
            cores = Convert.ToInt32(values[2]);
              if (values[0] == "NET") {//first line of NET data from the file
            foreach (string nets in values.Skip(2)) { //for all the nets presented on this line (skipping the first 2 garbage lines)
              if (nets != "") netwuts.Add(nets);//all the things, each iface, each bond, eths, los..  everything from the ifconfig
            }
              }
              if (values[0] == "DISKBUSY") {//first line of DISKBUSY holds disk names
            foreach (string diskN in values.Skip(2)) { //for all the disk labels presented on this line (skipping the first 2 garbage lines)
              if (diskN != "") disklabels.Add(diskN);//all sd and dm partitions, just keep it all in there
            }
              }
              if (values[0] == "BBBP") {
            if (values[2] == "/proc/partitions") {
              try {
                dix = values[3].Split(new[] { ' ', '\"' }, StringSplitOptions.RemoveEmptyEntries);
                if (dix[0] != "major") {
                  disksizes.Add(Convert.ToDouble(dix[2]) / 1000);
                  disksizesb.Add(dix[3]);
                }
              } catch { }
            } else if (values[2] == "/proc/1/stat")
              break;
              }
            }//some background info was gathered from AAA

            netties = new List<double>[netwuts.Count()];
            for (int i = 0; i < netties.Count(); i++) {
              netties[i] = new List<double>();//so many I dont even
            }//we now have netwuts.count netties[]s; each netties is a double list we can add each(EVERY SINGLE) line nmon records

            diskbusy = new List<double>[disklabels.Count()];
            for (int i = 0; i < disklabels.Count(); i++) {
              diskbusy[i] = new List<double>();//almost as many I dont even
            }//we now have disklabels.count diskbusy[]s; each diskbusy is a double list we can add each(EVERY SINGLE) line nmon records
            List<UARG> uargs = new List<UARG>();
            while ((line = reader.ReadLine()) != null) { //Got all the prelim done, now do the rest of the file
              string[] values = line.Split(',');
              /*switch was faster than an if block*/
              try {
            switch (values[0]) {
              case "ZZZZ":
                times.Add(values[2] + " " + values[3]);
                break;
              case "UARG":
                double uargPID = 0;
                string uargCMD = "";
                try { uargPID = Convert.ToDouble(values[2]);
                uargCMD = values[4];
                if (uargCMD.IndexOf(" ") >= 0) {
                  UARG tU = new UARG(uargPID, uargCMD.Substring(0, uargCMD.IndexOf(" ")));
                  uargs.Add(tU);
                } else {
                  UARG tU = new UARG(uargPID, uargCMD);
                  uargs.Add(tU);
                }

                } catch { }

                break;
              case "TOP":
                List<string> topstuff = new List<string>();
                //TOP,+PID,Time,%CPU,%Usr,%Sys,Size,ResSet,ResText,ResData,ShdLib,MajorFault,MinorFault,Command
                //TOP,0031885,T0050,92.9,89.2,3.7,1416768,1105388,144,0,143692,34,0,osii_dbms_adapt
                topstuff.Add(values[2].Substring(1, values[2].Length - 1));//time in front of topstuff
                for (int i = 1; i < values.Count(); i++) {
                  if (i != 2) {//skip time
                    topstuff.Add(values[i]);//add each value starting from 1 (skipping 2)
                    //Time,+PID,%CPU,%Usr,%Sys,Size,ResSet,ResText,ResData,ShdLib,MajorFault,MinorFault,Command
                    //0050,0031885,92.9,89.2,3.7,1416768,1105388,144,0,143692,34,0,osii_dbms_adapt
                  }
                }
                topList.Add(topstuff);
                string TOPpid = topstuff[1];
                int TPID = Convert.ToInt32(TOPpid);
                string TOPres = topstuff[6];
                string TOPcpu = topstuff[2];
                bool found = false;

                foreach (process x in processes) {
                  if (x.command == topstuff[12]) {//find by command
                    x.add(TOPres, TOPcpu);
                    found = true;
                    break;
                  }

                  //if (x.pid == TPID) {//find by PID
                  //  x.add(TOPres, TOPcpu);
                  //  found = true;
                  //  break;
                  //}
                }
                if (!found) {
                  process t = new process(TOPpid, TOPres, TOPcpu, topstuff[12]);
                  processes.Add(t);
                }
                break;
              case "CPU_ALL":
                if (values[2] != "User%") {
                  cpu_all_usr.Add((Convert.ToDouble(values[2]) + Convert.ToDouble(values[3])));
                }
                break;
              case "MEM":
                if (values[2] != "memtotal") {
                  memsum.Add(100.0 * (1 - ((Convert.ToDouble(values[6]) + Convert.ToDouble(values[11]) + Convert.ToDouble(values[14])) / Convert.ToDouble(values[2]))));

                }
                break;
              case "NET":
                Parallel.ForEach(values.Skip(2), (nets, y, i) => {
                  if (nets != "") netties[i].Add(Convert.ToDouble(nets));
                });
                break;
              case "DISKBUSY":
                Parallel.ForEach(values.Skip(2), (disk, y, i) => {
                  diskbusy[i].Add(Convert.ToDouble(disk));
                });
                break;
              //etc
              default: //poison buckets barf pile
                break;
            }//end switch
              } catch (Exception e) {
            string m = e.Message;
              }
            }//end while
            for (int i = 0; i < processes.Count; i++) {
              if (processes[i].command.Length >= 14) {
            int uI = findPID(Convert.ToDouble(processes[i].pid), uargs);
            if (uI >= 0) {
              processes[i].command = uargs[uI].CMD;
            }
              }
              }

            }

            return (processes);
        }
 static int getSIndex(List<string> values1, process x, string type, string status)
 {
     //Nsheet, x, type, status
       int index = -1;
       for (int i = 0; i < values1.Count; i++) {
     //if (values1[i] == value1 && values2[i] == value2) {
     if(values1[i]==(x.command+","+type+","+status)){
       index = i;
       break;
     }
       }
       return index;
 }