|
|
package com.monitor.middleware.nginx.service;
|
|
|
|
|
|
import com.monitor.cmdb.service.IMObjectInfoService;
|
|
|
import com.monitor.middleware.nginx.constant.InterVar;
|
|
|
import com.monitor.middleware.nginx.model.InfoType;
|
|
|
import com.monitor.middleware.rabbitmq.component.InfluxComp;
|
|
|
import com.monitor.middleware.rabbitmq.model.QueryRequest;
|
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import org.influxdb.dto.QueryResult;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by yoho on 2016/6/22.
|
|
|
*/
|
|
|
@RestController(value = "/middleware/nginx")
|
|
|
public class NginxService {
|
|
|
|
|
|
@Autowired
|
|
|
InfluxComp influxComp;
|
|
|
|
|
|
@Autowired
|
|
|
IMObjectInfoService imObjectInfoService;
|
|
|
|
|
|
@RequestMapping
|
|
|
public BaseResponse queryCount(@RequestBody QueryRequest request) {
|
|
|
|
|
|
BaseResponse response = new BaseResponse();
|
|
|
|
|
|
Map<InfoType, QueryResult> resultMap = new HashMap<>();
|
|
|
|
|
|
String moIp = imObjectInfoService.queryMObjectInfo(Integer.parseInt(request.getMoId())).getMoHostIp();
|
|
|
|
|
|
QueryResult apiResult = influxComp.doQuery(String.format(InterVar.SIMPLE_QUERY_SQL, InterVar.APIACCESSMEASURE, moIp), InterVar.DBNAME);
|
|
|
|
|
|
resultMap.put(InfoType.API_NO200, apiResult);
|
|
|
|
|
|
QueryResult serResult = influxComp.doQuery(String.format(InterVar.SIMPLE_QUERY_SQL, InterVar.SERACCESSMEASURE, moIp), InterVar.DBNAME);
|
|
|
|
|
|
resultMap.put(InfoType.SERVIE_NO200, serResult);
|
|
|
|
|
|
QueryResult luaResult = influxComp.doQuery(String.format(InterVar.SIMPLE_QUERY_SQL, InterVar.LUAERRORMEASURE, moIp), InterVar.DBNAME);
|
|
|
|
|
|
resultMap.put(InfoType.LUA_ERROR, luaResult);
|
|
|
|
|
|
QueryResult conResult = influxComp.doQuery(String.format(InterVar.SIMPLE_QUERY_SQL, InterVar.CONERRORMEASURE, moIp), InterVar.DBNAME);
|
|
|
|
|
|
resultMap.put(InfoType.CONNECTION_TIMOUT, conResult);
|
|
|
|
|
|
response.setData(resultMap);
|
|
|
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|