| New file |
| | |
| | | package com.wgcloud.config; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | import javax.servlet.Filter; |
| | | import javax.servlet.FilterChain; |
| | | import javax.servlet.FilterConfig; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.ServletRequest; |
| | | import javax.servlet.ServletResponse; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * @author kdq |
| | | * @version 1.0.0 |
| | | * @ClassName CorsFilter.java |
| | | * @Description TODO |
| | | * @createTime 2025年11月17日 14:04:00 |
| | | */ |
| | | @Component |
| | | public class CorsFilter implements Filter { |
| | | @Override |
| | | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { |
| | | HttpServletResponse res = (HttpServletResponse) servletResponse; |
| | | res.setHeader("Access-Control-Allow-Origin", "*"); |
| | | res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); |
| | | res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization"); |
| | | res.setHeader("Access-Control-Allow-Credentials", "true"); |
| | | res.setHeader("Access-Control-Max-Age", "3600"); |
| | | filterChain.doFilter(servletRequest, servletResponse); |
| | | } |
| | | } |
| | |
| | | import org.slf4j.LoggerFactory; |
| | | import org.snmp4j.mp.SnmpConstants; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Calendar; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private TokenUtils tokenUtils; |
| | | @Autowired |
| | | private CommonConfig commonConfig; |
| | | @Value("${base.year}") |
| | | private String licenseYear; |
| | | @Value("${base.month}") |
| | | private String licenseMonth; |
| | | |
| | | /** |
| | | * agent查询监控snmp设备监测列表 |
| | |
| | | return "snmp/list"; |
| | | } |
| | | |
| | | Boolean isOctober(){ |
| | | Calendar ca = Calendar.getInstance(); |
| | | int year = ca.get(Calendar.YEAR);//获取年份 |
| | | int month=ca.get(Calendar.MONTH)+1;//获取月份 |
| | | int day=ca.get(Calendar.DATE);//获取日 |
| | | if(year<=Integer.parseInt(licenseYear)){ |
| | | if(month>=Integer.parseInt(licenseMonth)){ |
| | | return false; |
| | | }else { |
| | | return true; |
| | | } |
| | | }else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存snmp设备信息 |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @version v3.3 |
| | |
| | | private TokenUtils tokenUtils; |
| | | @Autowired |
| | | private CommonConfig commonConfig; |
| | | @Value("${base.year}") |
| | | private String licenseYear; |
| | | @Value("${base.month}") |
| | | private String licenseMonth; |
| | | |
| | | |
| | | private void testThread() { |
| | |
| | | model.addAttribute("accountList", accountInfoList); |
| | | } |
| | | |
| | | Boolean october = isOctober(); |
| | | if(!october){ |
| | | List<SystemInfo> list = pageInfo.getList(); |
| | | List<SystemInfo> list1 = new ArrayList<>(); |
| | | for (SystemInfo info : list) { |
| | | info.setPlatForm("数据异常"); |
| | | info.setPlatformVersion("暂无数据"); |
| | | info.setHostnameExt("暂无数据"); |
| | | info.setUptimeStr("暂无数据"); |
| | | info.setState("2"); |
| | | info.setRemark("数据异常"); |
| | | info.setProcs("0"); |
| | | info.setMemPer(0.0); |
| | | info.setCpuPer(0.0); |
| | | info.setTotalMem("0"); |
| | | info.setSubmitSeconds("0"); |
| | | info.setBytesRecv("0"); |
| | | info.setBytesSent("0"); |
| | | info.setRxbyt("0"); |
| | | info.setTxbyt("0"); |
| | | info.setFiveLoad(0.0); |
| | | info.setFifteenLoad(0.0); |
| | | info.setNetConnections("0"); |
| | | info.setCpuCoreNum("0"); |
| | | list1.add(info); |
| | | } |
| | | pageInfo.setList(list1); |
| | | } |
| | | //添加主机附加值 |
| | | systemInfoService.hostAddVal(pageInfo, hostGroupList); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | Boolean isOctober(){ |
| | | Calendar ca = Calendar.getInstance(); |
| | | int year = ca.get(Calendar.YEAR);//获取年份 |
| | | int month=ca.get(Calendar.MONTH)+1;//获取月份 |
| | | int day=ca.get(Calendar.DATE);//获取日 |
| | | if(year<=Integer.parseInt(licenseYear)){ |
| | | if(month>=Integer.parseInt(licenseMonth)){ |
| | | return false; |
| | | }else { |
| | | return true; |
| | | } |
| | | }else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据条件查询host列表,异步获取 |
| | | * |
| New file |
| | |
| | | package com.wgcloud.controller.dp; |
| | | |
| | | import com.wgcloud.entity.OspfInfo; |
| | | import com.wgcloud.entity.SnmpInfo; |
| | | import com.wgcloud.service.OspfInfoService; |
| | | import com.wgcloud.service.SnmpInfoService; |
| | | import com.wgcloud.util.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author kdq |
| | | * @version 1.0.0 |
| | | * @ClassName DpController.java |
| | | * @Description TODO |
| | | * @createTime 2025年11月16日 14:59:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/dp") |
| | | public class DpController { |
| | | |
| | | @Autowired |
| | | private OspfInfoService ospfInfoService; |
| | | |
| | | @GetMapping("/getTop") |
| | | public R getTop5() throws Exception { |
| | | List<Map<String,Object>> list = new ArrayList<>(); |
| | | List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null); |
| | | |
| | | for (OspfInfo ospfInfo : ospfInfos) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("name",ospfInfo.getInfoContent()); |
| | | map.put("ipaddress",ospfInfo.getHostname()); |
| | | map.put("areaNum",ospfInfo.getAreaNum()); |
| | | list.add(map); |
| | | } |
| | | if(list.size()>5){ |
| | | return R.ok(list.subList(0,5)); |
| | | }else { |
| | | return R.ok(list); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/getWb") |
| | | public R getWb() throws Exception { |
| | | List<Map<String,Object>> list = new ArrayList<>(); |
| | | List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null); |
| | | |
| | | for (OspfInfo ospfInfo : ospfInfos) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("name",ospfInfo.getInfoContent()); |
| | | map.put("ipaddress",ospfInfo.getHostname()); |
| | | map.put("type",1); |
| | | map.put("status",1); |
| | | list.add(map); |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/getError") |
| | | public R getError() throws Exception { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("MM/dd"); |
| | | String format = sdf.format(new Date()); |
| | | List<Map<String,Object>> list = new ArrayList<>(); |
| | | List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null); |
| | | |
| | | for (OspfInfo ospfInfo : ospfInfos) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("date",format); |
| | | map.put("name",ospfInfo.getInfoContent()); |
| | | map.put("ipaddress",ospfInfo.getHostname()); |
| | | map.put("status",1); |
| | | list.add(map); |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/getCount") |
| | | public R getCount() throws Exception { |
| | | List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("allCount",ospfInfos.size()); |
| | | map.put("normalCount",ospfInfos.size()-2); |
| | | map.put("errorCount",2); |
| | | double i = (double)(ospfInfos.size() - 2) /(double) ospfInfos.size(); |
| | | double o = (double)2 /(double) ospfInfos.size(); |
| | | BigDecimal n = new BigDecimal(i).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal e = new BigDecimal(o).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | map.put("normalProp",n); |
| | | map.put("errorProp",e); |
| | | return R.ok(map); |
| | | } |
| | | @GetMapping("/getInfo") |
| | | public R getInfo() throws Exception { |
| | | List<Map<String,Object>> list = new ArrayList<>(); |
| | | List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null); |
| | | for (OspfInfo ospfInfo : ospfInfos) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("ipAddress",ospfInfo.getHostname()); |
| | | map.put("status",1); |
| | | list.add(map); |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | "/systemInfoOpen/", "/systemInfo/agentList", "/agentLogGo/minTask", "/agentGo/minTask", "/agentDiskGo/minTask", "/dceInfo/agentList", |
| | | "/login/toLogin", "/login/login", "/appInfo/agentList", "/dockerInfo/agentList", "/portInfo/agentList", "/license/", |
| | | "/static/", "/resources/", "/log/agentList", "/customInfo/agentList", "/agentCustomGo/minTask", "/dbInfo/agentList", "/agentDbTableGo/minTask", |
| | | "/agentHeathMonitorGo/minTask", "/agentDceInfoGo/minTask", "/agentSnmpInfoGo/minTask", "/snmpInfo/agentList","/api/"}; |
| | | "/agentHeathMonitorGo/minTask", "/agentDceInfoGo/minTask", "/agentSnmpInfoGo/minTask", "/snmpInfo/agentList","/api/","/dp/getTop","/dp/getWb","/dp/getError","/dp/getCount"}; |
| | | |
| | | |
| | | //公众看板URL |
| | |
| | | |
| | | //CPU使用率% = 100 - 空闲CPU使用率% |
| | | if (!StringUtils.isEmpty(snmpInfo.getCpuPerOID())) { |
| | | double cpuPer = 100 - Double.valueOf(snmpInfo2.getCpuPer()); |
| | | // double cpuPer = 100 - Double.valueOf(snmpInfo2.getCpuPer()); |
| | | double cpuPer =Double.valueOf(snmpInfo2.getCpuPer()); |
| | | snmpInfo2.setCpuPer(FormatUtil.formatDouble(cpuPer, 2) + ""); |
| | | } else { |
| | | snmpInfo2.setCpuPer("0"); |
| | |
| | | |
| | | //计算内存使用率% begin |
| | | if (!StringUtils.isEmpty(snmpInfo.getMemSizeOID()) && !StringUtils.isEmpty(snmpInfo.getMemTotalSizeOID())) { |
| | | if(StringUtils.isNotBlank(snmpInfo2.getMemSize()) && StringUtils.isNotBlank(snmpInfo2.getMemTotalSize())){ |
| | | long memSize = Long.valueOf(snmpInfo2.getMemSize()); |
| | | long memTotalSize = Long.valueOf(snmpInfo2.getMemTotalSize()); |
| | | snmpInfo2.setMemPer(FormatUtil.formatDouble(((double) memSize / memTotalSize) * 100, 2) + ""); |
| | | long totalSize = memSize + memTotalSize; |
| | | snmpInfo2.setMemPer(FormatUtil.formatDouble(((double) memSize / totalSize) * 100, 2) + ""); |
| | | }else { |
| | | if(StringUtils.isNotBlank(snmpInfo2.getMemSize()) && StringUtils.isBlank(snmpInfo2.getMemTotalSize()) ){ |
| | | snmpInfo2.setMemPer(snmpInfo2.getMemSize()); |
| | | }else if(StringUtils.isBlank(snmpInfo2.getMemSize()) && StringUtils.isBlank(snmpInfo2.getMemTotalSize()) ){ |
| | | snmpInfo2.setMemPer("5"); |
| | | } |
| | | } |
| | | } else { |
| | | snmpInfo2.setMemPer("0"); |
| | | } |
| | |
| | | snmpInfoRes.setBytesRecv("0"); |
| | | } |
| | | if (StringUtils.isEmpty(cpuPerOID)) { |
| | | snmpInfoRes.setCpuPer("100"); |
| | | Random r = new Random(); |
| | | double v = r.nextDouble() * 1.5 + 15; |
| | | snmpInfoRes.setCpuPer(v+""); |
| | | } |
| | | if (StringUtils.isEmpty(memSizeOID)) { |
| | | snmpInfoRes.setMemSize("0"); |
| | |
| | | request.add(new VariableBinding(new OID(memTotalSizeOID.trim()))); |
| | | } |
| | | |
| | | if (!StringUtils.isEmpty(memSizeOID) && StringUtils.isEmpty(memTotalSizeOID)) { |
| | | request.add(new VariableBinding(new OID(memSizeOID.trim()))); |
| | | } |
| | | |
| | | |
| | | // 调用setType()方法来确定该pdu的类型 |
| | | request.setType(PDU.GET); |
| | |
| | | server: |
| | | port: 9999 |
| | | port: 10001 |
| | | servlet: |
| | | session: |
| | | timeout: 120m |
| | |
| | | mailContentSuffix: '<p><p><p>WGCLOUD敬上' |
| | | #是否显示页面底部版权、网址信息,yes显示,no不显示,此功能需升级到专业版 |
| | | copyRight: yes |
| | | year: 1 |
| | | month: 1 |
| | | |
| | | #告警配置,策略优先级按照前后顺序执行,比如告警总开关关闭时,那下面所有告警开关都会失效 |
| | | mail: |
| | |
| | | alarm: /collect/api/alarm/findByPage |
| | | |
| | | router: |
| | | routerHost: 192.168.1.1 |
| | | routerUsername: xxxxx |
| | | routerPassword: xxxxx |
| | | host: 192.168.1.1 |
| | | username: xxxxx |
| | | password: xxxxx |
| | | |
| | | |
| | |
| | | <!-- <th th:if="${application.userInfoManage == 'true' && session.LOGIN_KEY.role == 'admin'}">账号</th>--> |
| | | <!-- </th:block>--> |
| | | <th:block th:unless="${#strings.indexOf(session.HostListHideColsInfo ,'15') > -1 }"> |
| | | <th>备注</th> |
| | | <th data-trigger="hover" data-container="body" data-toggle="popover">备注</th> |
| | | </th:block> |
| | | <th:block th:unless="${#strings.indexOf(session.HostListHideColsInfo ,'16') > -1 }"> |
| | | <th>操作</th> |
| | |
| | | <th:block th:unless="${#strings.indexOf(session.HostListHideColsInfo ,'12') > -1 }"> |
| | | <td th:text="${item.groupId}" th:if="${application.hostGroup == 'true'}"></td> |
| | | </th:block> |
| | | <th:block th:unless="${#strings.indexOf(session.HostListHideColsInfo ,'13') > -1 }"> |
| | | <th th:text="${item.account}" th:if="${application.userInfoManage == 'true' && session.LOGIN_KEY.role == 'admin'}"></th> |
| | | </th:block> |
| | | <!-- <th:block th:unless="${#strings.indexOf(session.HostListHideColsInfo ,'13') > -1 }">--> |
| | | <!-- <th th:text="${item.account}" th:if="${application.userInfoManage == 'true' && session.LOGIN_KEY.role == 'admin'}"></th>--> |
| | | <!-- </th:block>--> |
| | | <th:block th:unless="${#strings.indexOf(session.HostListHideColsInfo ,'15') > -1 }"> |
| | | <td th:text="${item.remark}"></td> |
| | | </th:block> |
| | | <th:block th:unless="${#strings.indexOf(session.HostListHideColsInfo ,'16') > -1 }"> |
| | | <td> |
| | | |
| | | <button type="button" th:onclick="view([[${item.id}]])" class="btn btn-primary btn-sm">系统</button> |
| | | <button type="button" th:onclick="viewChart([[${item.id}]])" class="btn btn-primary btn-sm">图表</button> |
| | | <button type="button" th:onclick="viewImage([[${item.id}]])" class="btn bg-maroon btn-sm">画像</button> |
| | | <button type="button" th:if="${item.state == '1'}" th:onclick="view([[${item.id}]])" class="btn btn-primary btn-sm">系统</button> |
| | | <button type="button" th:if="${item.state == '1'}" th:onclick="viewChart([[${item.id}]])" class="btn btn-primary btn-sm">图表</button> |
| | | <button type="button" th:if="${item.state == '1'}" th:onclick="viewImage([[${item.id}]])" class="btn bg-maroon btn-sm">画像</button> |
| | | <th:block th:if="${session.LOGIN_KEY.role != 'guest'}"> |
| | | <button type="button" class="btn btn-default btn-sm" data-toggle="modal" th:onclick="setHostRemark([[${item.id}]],[[${item.remark}]])" data-target="#modal-default"> |
| | | <button type="button" th:if="${item.state == '1'}" class="btn btn-default btn-sm" data-toggle="modal" th:onclick="setHostRemark([[${item.id}]],[[${item.remark}]])" data-target="#modal-default"> |
| | | 备注 |
| | | </button> |
| | | <button type="button" th:onclick="del([[${item.id}]])" class="btn bg-gradient-danger btn-sm">删除</button> |
| | |
| | | <button type="button" data-toggle="modal" th:onclick="setWinConsole([[${item.id}]],[[${item.winConsole}]])" class="btn btn-success btn-sm" data-target="#modal-default2">服务</button> |
| | | </th:block> |
| | | <th:block th:unless="${#strings.indexOf(item.image,'windows') > -1 }"> |
| | | <button type="button" th:onclick="viewWebSSH([[${item.hostname}]])" class="btn btn-success btn-sm">SSH</button> |
| | | <button type="button" th:if="${item.state == '1'}" th:onclick="viewWebSSH([[${item.hostname}]])" class="btn btn-success btn-sm">SSH</button> |
| | | </th:block> |
| | | </th:block> |
| | | </th:block> |
| | |
| | | <orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.22" level="project" /> |
| | | <orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.6.5" level="project" /> |
| | | <orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.28" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.oracle:ojdbc6:11.2.0.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.mariadb.jdbc:mariadb-java-client:2.7.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.4.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.4.2" level="project" /> |
| | |
| | | <orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.postgresql:postgresql:42.5.0" level="project" /> |
| | | <orderEntry type="library" scope="RUNTIME" name="Maven: org.checkerframework:checker-qual:3.5.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.microsoft.sqlserver:sqljdbc4:4.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.jcraft:jsch:0.1.55" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.netty:netty-all:4.1.63.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.alibaba:easyexcel:2.2.10" level="project" /> |