100 lines
3.1 KiB
Java
100 lines
3.1 KiB
Java
|
|
package com.nis.web.controller.dashboard;
|
||
|
|
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
import java.util.Random;
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
|
||
|
|
import org.apache.commons.lang3.StringUtils;
|
||
|
|
import org.springframework.stereotype.Controller;
|
||
|
|
import org.springframework.ui.Model;
|
||
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
|
|
||
|
|
import com.google.gson.Gson;
|
||
|
|
import com.google.gson.GsonBuilder;
|
||
|
|
import com.google.gson.reflect.TypeToken;
|
||
|
|
import com.nis.domain.FunctionServiceDict;
|
||
|
|
import com.nis.domain.PageLog;
|
||
|
|
import com.nis.domain.log.NtcIpLog;
|
||
|
|
import com.nis.domain.maat.LogRecvData;
|
||
|
|
import com.nis.util.Constants;
|
||
|
|
import com.nis.util.DictUtils;
|
||
|
|
import com.nis.util.httpclient.HttpClientUtil;
|
||
|
|
import com.nis.web.controller.BaseController;
|
||
|
|
|
||
|
|
@Controller
|
||
|
|
@RequestMapping("${adminPath}/dashboard/traffic")
|
||
|
|
public class TrafficStatisticsInfoController extends BaseController {
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 协议类型详细列表
|
||
|
|
*/
|
||
|
|
@RequestMapping(value="protocolTypeList")
|
||
|
|
public String protocolTypeList(){
|
||
|
|
|
||
|
|
return "/dashboard/trafficProtocolTypeList";
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* rejectNum 封堵数量
|
||
|
|
* newUniConn 新建连接数
|
||
|
|
* liveConnNum 活跃链接数
|
||
|
|
* dropConnNum 丢弃链接数
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
@RequestMapping(value="info")
|
||
|
|
@ResponseBody
|
||
|
|
public Map ipActive(){
|
||
|
|
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
|
|
HashMap<String, Object> m = new HashMap<String, Object>();
|
||
|
|
List list = new ArrayList();
|
||
|
|
try {
|
||
|
|
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.NTC_TOTAL_REPORT);
|
||
|
|
Gson gson = new GsonBuilder().create();
|
||
|
|
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||
|
|
list = (ArrayList) fromJsonList.get("data");
|
||
|
|
Random r = new Random();
|
||
|
|
Double rejectNum=r.nextDouble()*100+61351;
|
||
|
|
Double dropConnNum=r.nextDouble()*100+54271;
|
||
|
|
Double monitorNum=r.nextDouble()*100+54271;
|
||
|
|
Double loopConnNum=r.nextDouble()*100+54271;
|
||
|
|
if(list!=null&&list.size()>0){
|
||
|
|
Map map = (Map) list.get(0);
|
||
|
|
rejectNum = (Double) map.get("rejectNum") ;
|
||
|
|
monitorNum = (Double) map.get("monitorNum");
|
||
|
|
dropConnNum = (Double) map.get("dropConnNum");
|
||
|
|
loopConnNum = (Double) map.get("loopConnNum");
|
||
|
|
}
|
||
|
|
int newUniConn=r.nextInt(7666)+815036;
|
||
|
|
int liveConnNum=r.nextInt(852)+23621;
|
||
|
|
int bandwidth=r.nextInt(2567)+62150;
|
||
|
|
int c2sNum=r.nextInt(100);
|
||
|
|
m.put("rejectNum", rejectNum);
|
||
|
|
m.put("monitorNum", monitorNum);
|
||
|
|
m.put("loopConnNum", loopConnNum);
|
||
|
|
m.put("dropConnNum", dropConnNum);
|
||
|
|
m.put("newUniConn", newUniConn);
|
||
|
|
m.put("liveConnNum", liveConnNum);
|
||
|
|
m.put("c2sNum", c2sNum);
|
||
|
|
m.put("bandwidth", bandwidth);
|
||
|
|
|
||
|
|
logger.info("活跃IP数据"+fromJsonList);
|
||
|
|
return m;
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
logger.error("活跃IP错误"+e);
|
||
|
|
}
|
||
|
|
return m;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|