package org.bench4q.monitor.api;

import java.io.IOException;

import org.bench4q.monitor.entiry.MonitorContorlEntity;
import org.bench4q.monitor.model.NetworkInterfaceModel;
import org.bench4q.monitor.service.linux.NetworkInterfaceServiceLinux;
import org.bench4q.monitor.service.windows.NetworkInterfaceServiceWindows;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

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

	@RequestMapping("/NetworkInterface")
	@ResponseBody
	public NetworkInterfaceModel getNetworkInterfaceInfo() throws IOException,
			InterruptedException {
		if (this.getOsNameString().contains("windows")) {
			NetworkInterfaceServiceWindows networkInterfaceServiceWindows = new NetworkInterfaceServiceWindows();
			return networkInterfaceServiceWindows.getNetworkInterfaceInfo(this
					.getIdleTime());
		} else if (this.getOsNameString().contains("linux")) {
			NetworkInterfaceServiceLinux networkInterfaceServiceLinux = new NetworkInterfaceServiceLinux();
			return networkInterfaceServiceLinux.getNetworkInterfaceInfo(this
					.getIdleTime());
		} else
			return null;
	}

}
