package org.bench4q.monitor.file.Linux;

import java.io.FileNotFoundException;
import java.io.PrintWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;

import org.bench4q.monitor.model.LogicalDiskModel;
import org.bench4q.monitor.model.MemoryModel;
import org.bench4q.monitor.performance.linux.MemoryMonitor;
import org.bench4q.monitor.files.Write;

public class WriteMemoryLinux extends Write{

	private MemoryMonitor memoryMonitor;
	public WriteMemoryLinux(PrintWriter out,int idleTime) throws FileNotFoundException{
		this.out=out;
		this.memoryMonitor=new MemoryMonitor();
		this.idleTime=idleTime;
	}
	public void run(){
		try{
			JAXBContext context = JAXBContext.newInstance(LogicalDiskModel.class);  
		     Marshaller marshaller = context.createMarshaller();  
		     MemoryModel memoryModel=memoryMonitor.getMemoryInfo(idleTime);
		     marshaller.marshal(memoryModel, out);  
		}
		catch(Exception e){
			System.out.println(e);
		}
		
	}

}

