| 
					
				 | 
			
			
				@ -1,7 +1,9 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.hos.monitor.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.mongodb.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.common.constants.ContextAttributes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.core.datatype.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.tenant.model.TenantSession; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.model.ActionResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.model.Result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.model.TreeView; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -11,6 +13,7 @@ import org.springframework.data.mongodb.core.MongoOperations; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.mongodb.core.MongoTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpSession; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -32,11 +35,13 @@ public class ServerMonitorService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private Mongo mongo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Result getMonitorList(String host, String type, String beginTime, String endTime) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Result getMonitorList(HttpSession session,String host, String type, String beginTime, String endTime) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mongoOperations = new MongoTemplate(mongo, MONITOR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DBCollection envCollection = mongoOperations.getCollection(SERVER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                new BasicDBObject[]{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        new BasicDBObject().append("tenant",tenantSession.getTenant()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        new BasicDBObject().append("host",host), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        new BasicDBObject().append("type",type), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        new BasicDBObject().append("create_time", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -57,11 +62,13 @@ public class ServerMonitorService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return actionResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Result getMonitorDetail(String host, String type, String date) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Result getMonitorDetail(HttpSession session,String host, String type, String date) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mongoOperations = new MongoTemplate(mongo, MONITOR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DBCollection envCollection = mongoOperations.getCollection(SERVER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                new BasicDBObject[]{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        new BasicDBObject().append("tenant",tenantSession.getTenant()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        new BasicDBObject().append("host", host), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        new BasicDBObject().append("type", type), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        new BasicDBObject().append("create_time",new BasicDBObject().append(QueryOperators.LTE, DateUtil.toTimestamp(date)))}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -104,11 +111,17 @@ public class ServerMonitorService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Result getServerTreeList() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Result getServerTreeList(HttpSession session) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TreeView> treeList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mongoOperations = new MongoTemplate(mongo, MONITOR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DBCollection envCollection = mongoOperations.getCollection(HOST); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DBCursor cursor = envCollection.find(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //查询条件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                new BasicDBObject[]{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        new BasicDBObject().append("tenant",tenantSession.getTenant())}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DBCursor cursor = envCollection.find(queryObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        while(cursor.hasNext()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DBObject dbObject = cursor.next(); 
			 |