import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Iterator;

import org.apache.commons.io.FileUtils;


public class WindowsExtraction {
	
public static void main(String args[]){
		
		Iterator it = FileUtils.iterateFiles(new File("K:\\CSU Node Data\\ENS_WindowsPCs\\01_2012\\"), null, false);
		
        while(it.hasNext()){
        	
        	String fileName =((File) it.next()).getName();
        	
        
		PrintWriter pw = null;
		try{
			
			BufferedReader in = new BufferedReader(new FileReader("K:\\CSU Node Data\\ENS_WindowsPCs\\01_2012\\"+fileName));
			pw = new PrintWriter(new FileWriter("K:\\CSU Node Data\\ENS_WindowsPCs\\01_2012_output\\"+fileName));
			pw.println("MacAddr" +"\t"+"IPaddr"+"\t"+"Interface"+"\t"+"HostName"+"\t"+"Model"+"\t"+"NumCores"+"\t"+"ProcSpeed"+"\t"+"Vendor"+"\t"+"RamSize"+"\t"+"MemAvail"+"\t"+"MemUsedPerc"+"\t"+"MemFreePerc"+"\t"+"SwapAvail"+"\t"+"SwapUsed"+"\t"+"Uptime"+"\t"+"Num Drives"+"\t"+"FileSystem"+"\t"+"MaxSpace"+"\t"+"FreeSpace"+"\t"+"OsName"+"\t"+"OSDescription"+"\t"+"OSArch"+"\t"+"OsVersion"+"\t"+"Time"+"\t"+"MTU"+"\t"+"RX bytes"+"\t"+"TX Bytes"+"\t"+"CPU usage"+"\t"+"Num Process Extracted"+"\t"+"Process Name"+"\t"+"Proc Mem Util");
			String FirstString="";

			while(FirstString !=null )
			{
				FirstString = in.readLine();
				//count++;
				
				while(FirstString.trim().length() != 0)
				{
			

					if(FirstString.contains(", (load average unknown)"))
					{
						
						FirstString =FirstString.replace(", (load average unknown)", "");

					}
					
					if(FirstString.contains("CPU states:"))
					{
						
						String [] tokens1 = FirstString.split(":");
						
						
						String [] tokens2 = tokens1[1].split(",");
						
						
						FirstString ="";
						FirstString = tokens2[0].trim().replace("% user","\t");
						FirstString = FirstString + tokens2[1].trim().replace("% system","\t");
						FirstString = FirstString + tokens2[2].trim().replace("% nice","\t");
						FirstString = FirstString + tokens2[3].trim().replace("% wait","\t");
						FirstString = FirstString + tokens2[4].trim().replace("% idle","\t");
							
						
						
					}
					
					
					pw.print(FirstString +"\t");
					
					

					FirstString = in.readLine();
					
					
				
				}
				
				pw.println("");

				FirstString = in.readLine();
				FirstString = in.readLine();

			}
		}catch(Exception e){
			
		}
		
		finally{
			pw.close();
		}
		
	}
	}

}
