package org.bench4q.monitor.file.Linux;

import java.io.PrintWriter;

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

import org.bench4q.monitor.model.ProcessModel;
import org.bench4q.monitor.performance.linux.ProcessMonitor;
import org.bench4q.monitor.files.Write;

public class WriteProcessLinux extends Write {
	private ProcessMonitor processMonitor;

	public WriteProcessLinux(PrintWriter out, int idleTime) {
		this.out = out;
		this.processMonitor = new ProcessMonitor();
		this.idleTime = idleTime;
	}

	public void run() {
		try {
			JAXBContext context = JAXBContext.newInstance(ProcessModel.class);
			Marshaller marshaller = context.createMarshaller();
			ProcessModel processModel = processMonitor.getProcessInfo(idleTime);
			marshaller.marshal(processModel, out);
		} catch (Exception e) {
			System.out.println(e);
		}

	}

}
