|
@ -34,11 +34,11 @@ public class ServerMonitorService {
|
|
|
private MongoOperations mongoOperations;
|
|
|
|
|
|
@Autowired
|
|
|
private Mongo mongo;
|
|
|
private MongoClient mongoClient;
|
|
|
|
|
|
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);
|
|
|
mongoOperations = new MongoTemplate(mongoClient, MONITOR);
|
|
|
DBCollection envCollection = mongoOperations.getCollection(SERVER);
|
|
|
Timestamp begin = DateUtil.toTimestamp(beginTime);
|
|
|
Timestamp end = DateUtil.toTimestamp(endTime);
|
|
@ -47,8 +47,8 @@ public class ServerMonitorService {
|
|
|
new BasicDBObject().append("tenant", tenantSession.getTenant()),
|
|
|
new BasicDBObject().append("host", host),
|
|
|
new BasicDBObject().append("type", type),
|
|
|
new BasicDBObject("create_time", new BasicDBObject().append(QueryOperators.GTE, begin)
|
|
|
.append(QueryOperators.LT, end))
|
|
|
new BasicDBObject("create_date", new BasicDBObject().append(QueryOperators.GTE, beginTime)
|
|
|
.append(QueryOperators.LT, endTime))
|
|
|
});
|
|
|
|
|
|
List<DBObject> result = new ArrayList<>();
|
|
@ -66,7 +66,7 @@ public class ServerMonitorService {
|
|
|
|
|
|
public Result getMonitorDetail(HttpSession session, String host, String type, String date) {
|
|
|
TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION);
|
|
|
mongoOperations = new MongoTemplate(mongo, MONITOR);
|
|
|
mongoOperations = new MongoTemplate(mongoClient, MONITOR);
|
|
|
DBCollection envCollection = mongoOperations.getCollection(SERVER);
|
|
|
Timestamp timestamp = DateUtil.toTimestamp(date);
|
|
|
BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
|
|
@ -74,10 +74,10 @@ public class ServerMonitorService {
|
|
|
new BasicDBObject().append("tenant", tenantSession.getTenant()),
|
|
|
new BasicDBObject().append("host", host),
|
|
|
new BasicDBObject().append("type", type),
|
|
|
new BasicDBObject("create_time", new BasicDBObject(QueryOperators.LTE, timestamp))});
|
|
|
new BasicDBObject("create_date", new BasicDBObject(QueryOperators.LTE, date))});
|
|
|
|
|
|
Map result = new HashMap<>();
|
|
|
DBCursor cursor = envCollection.find(queryObject).sort(new BasicDBObject("create_time", -1)).limit(1);
|
|
|
DBCursor cursor = envCollection.find(queryObject).sort(new BasicDBObject("create_date", -1)).limit(1);
|
|
|
while (cursor.hasNext()) {
|
|
|
DBObject dbObject = cursor.next();
|
|
|
dbObject.removeField("_id");
|
|
@ -92,7 +92,7 @@ public class ServerMonitorService {
|
|
|
|
|
|
public Result getHosts() {
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
mongoOperations = new MongoTemplate(mongo, MONITOR);
|
|
|
mongoOperations = new MongoTemplate(mongoClient, MONITOR);
|
|
|
DBCollection envCollection = mongoOperations.getCollection(HOST);
|
|
|
DBCursor cursor = envCollection.find();
|
|
|
while (cursor.hasNext()) {
|
|
@ -117,7 +117,7 @@ public class ServerMonitorService {
|
|
|
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);
|
|
|
mongoOperations = new MongoTemplate(mongoClient, MONITOR);
|
|
|
DBCollection envCollection = mongoOperations.getCollection(HOST);
|
|
|
//查询条件
|
|
|
BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
|