package org.bench4q.monitor.api;

import java.io.IOException;

import org.bench4q.monitor.entiry.MonitorContorlEntity;
import org.bench4q.monitor.model.PhysicalDiskModel;
import org.bench4q.monitor.service.linux.PhysicalDiskServiceLinux;
import org.bench4q.monitor.service.windows.PhysicalDiskServiceWindows;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/Monitor")
public class PhysicalDiskController extends MonitorContorlEntity {

	@RequestMapping("/PhysicalDisk")
	@ResponseBody
	public PhysicalDiskModel getPhysicalDislInfo() throws IOException,
			InterruptedException {
		if (this.getOsNameString().contains("windows")) {
			PhysicalDiskServiceWindows physicalDiskServiceWindows = new PhysicalDiskServiceWindows();
			return physicalDiskServiceWindows.getPhysicalDiskInfo(this
					.getIdleTime());
		} else if (this.getOsNameString().contains("linux")) {
			PhysicalDiskServiceLinux physicalDiskServiceLinux = new PhysicalDiskServiceLinux();
			return physicalDiskServiceLinux.getPhysicalFDiskInfo(this
					.getIdleTime());
		} else
			return null;

	}
}
