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.ProcessorModel;
import org.bench4q.monitor.performance.linux.ProcessorMonitor;
import org.bench4q.monitor.files.Write;

public class WriteProcessorLinux extends Write {
	private ProcessorMonitor processorMonitor;

	public WriteProcessorLinux(PrintWriter out, int idleTime)
			throws FileNotFoundException {
		this.out = out;
		this.processorMonitor = new ProcessorMonitor();
		this.idleTime = idleTime;
	}

	public void run() {
		try {
			JAXBContext context = JAXBContext.newInstance(ProcessorModel.class);
			Marshaller marshaller = context.createMarshaller();
			ProcessorModel processorModel = processorMonitor
					.getProcessorInfo(idleTime);
			marshaller.marshal(processorModel, out);
		} catch (Exception e) {
			System.out.println(e);
		}

	}

}
