| | |
| | | @ServletComponentScan("com.wgcloud.filter") |
| | | @ComponentScan(basePackages = "com.wgcloud") |
| | | @EnableCaching |
| | | //@EnableScheduling |
| | | @EnableScheduling |
| | | public class WgcloudServiceApplication { |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(WgcloudServiceApplication.class, args); |
| | |
| | | mailSetService.saveLog(request, StaticKeys.LOG_UPDATE, mailSet); |
| | | } |
| | | StaticKeys.mailSet = mailSet; |
| | | result = WarnMailUtil.sendMail(mailSet.getToMail(), "WGCLOUD测试邮件发送", "WGCLOUD测试邮件发送"); |
| | | result = WarnMailUtil.sendMail(mailSet.getToMail(), "系统测试邮件发送", "系统测试邮件发送"); |
| | | } catch (Exception e) { |
| | | logger.error("测试邮件设置信息错误", e); |
| | | logInfoService.save("测试邮件设置信息错误", e.toString(), StaticKeys.LOG_XTCZ); |
| | |
| | | ospfInfo.setMonitorIp(ospfMonitor.getHostname()); |
| | | ospfInfo.setMonitorUsername(ospfMonitor.getUsername()); |
| | | ospfInfo.setMonitorPassword(ospfMonitor.getPassword()); |
| | | ospfInfo.setMonitorRemoteType(ospfMonitor.getRemoteType()); |
| | | OspfInfoService.save(ospfInfo); |
| | | } else { |
| | | OspfMonitor ospfMonitor = ospfMonitorService.selectById(ospfInfo.getMonitorId()); |
| | | ospfInfo.setMonitorIp(ospfMonitor.getHostname()); |
| | | ospfInfo.setMonitorUsername(ospfMonitor.getUsername()); |
| | | ospfInfo.setMonitorPassword(ospfMonitor.getPassword()); |
| | | ospfInfo.setMonitorRemoteType(ospfMonitor.getRemoteType()); |
| | | OspfInfoService.updateById(ospfInfo); |
| | | } |
| | | |
| | |
| | | |
| | | private String monitorUsername; |
| | | private String monitorPassword; |
| | | private String monitorRemoteType; |
| | | |
| | | |
| | | public String getHostname() { |
| | |
| | | this.hostname = hostname; |
| | | } |
| | | |
| | | public String getMonitorRemoteType() { |
| | | return monitorRemoteType; |
| | | } |
| | | |
| | | |
| | | public void setMonitorRemoteType(String monitorRemoteType) { |
| | | this.monitorRemoteType = monitorRemoteType; |
| | | } |
| | | |
| | | |
| | | |
| | | public String getInfoContent() { |
| | | return infoContent; |
| | |
| | | |
| | | private String password; |
| | | |
| | | private String remoteType; |
| | | |
| | | public String getUsername() { |
| | | return username; |
| | | } |
| | | public String getRemoteType() { |
| | | return remoteType; |
| | | } |
| | | |
| | | public void setUsername(String username) { |
| | | this.username = username; |
| | | } |
| | | public void setRemoteType(String remoteType) { |
| | | this.remoteType = remoteType; |
| | | } |
| | | |
| | | public String getPassword() { |
| | | return password; |
| | |
| | | map.put("username",ospfInfo.getMonitorUsername()); |
| | | map.put("password",ospfInfo.getMonitorPassword()); |
| | | map.put("monitorIp",ospfInfo.getMonitorIp()); |
| | | if(ospfInfo.getMonitorRemoteType().equals("TELNET")){ |
| | | map.put("type","0"); |
| | | }else if(ospfInfo.getMonitorRemoteType().equals("SSH")){ |
| | | map.put("type","1"); |
| | | } |
| | | String str = JSON.toJSONString(map); |
| | | System.out.println(str); |
| | | try { |
| | |
| | | * 20秒后执行,之后每6分钟刷新一次 |
| | | * 初始化一些任务 |
| | | */ |
| | | //@Scheduled(initialDelay = 20000L, fixedRate = 6 * 60 * 1000) |
| | | @Scheduled(initialDelay = 20000L, fixedRate = 6 * 60 * 1000) |
| | | public void initTask() { |
| | | logger.info("initTask------------" + DateUtil.getDateTimeString(new Date())); |
| | | try { |
| | |
| | | * 90秒后执行,之后每隔15分钟执行, 单位:ms。 |
| | | * 检测数通PING设备 |
| | | */ |
| | | //@Scheduled(initialDelay = 90000L, fixedRateString = "${base.dceTimes}" + "000") |
| | | @Scheduled(initialDelay = 90000L, fixedRateString = "${base.dceTimes}" + "000") |
| | | public void dceInfoTask() { |
| | | if (!StaticKeys.NODE_MASTER.equals(commonConfig.getNodeType())) { |
| | | logger.info("slave节点不执行检测数通设备PING任务"); |
| | |
| | | String pingCommand; |
| | | Runtime r = Runtime.getRuntime(); |
| | | String osName = System.getProperty("os.name"); |
| | | System.out.println( "osName:"+osName); |
| | | if (osName.contains("Windows")) { |
| | | pingCommand = "ping " + ipAddress + " -n " + count + " -w " + (timeOut * 1000); |
| | | } else { |
| | | pingCommand = "ping " + " -c " + count + " -w " + timeOut + " " + ipAddress; |
| | | pingCommand = "ping " + " -c " + count + " " + ipAddress; |
| | | } |
| | | Integer diffTimes = StaticKeys.OUT_TIME_MARK; |
| | | try { |
| | |
| | | //查找整数的正则 begin |
| | | String regInt = "(=\\d+ms)"; |
| | | Pattern patternInt = Pattern.compile(regInt); |
| | | |
| | | Matcher matcherInt = patternInt.matcher(line); |
| | | while (matcherInt.find()) { |
| | | String groupStr = matcherInt.group(1); |
| | |
| | | String regDouble = "(=\\d+.\\d+ms)"; |
| | | Pattern patternDouble = Pattern.compile(regDouble); |
| | | Matcher matcherDouble = patternDouble.matcher(line); |
| | | |
| | | while (matcherDouble.find()) { |
| | | String groupStr = matcherDouble.group(1); |
| | | logger.debug(line + "--------------" + groupStr); |
| | |
| | | mails = mails.substring(1); |
| | | } |
| | | try { |
| | | String mailTitlePrefix = "[WGCLOUD]"; |
| | | String mailContentSuffix = "<p><p><p><a target='_blank' href='http://www.wgstart.com'>WGCLOUD</a>敬上"; |
| | | String mailTitlePrefix = "[TSSW]"; |
| | | String mailContentSuffix = "<p><p><p><a target='_blank' href='http://www.wgstart.com'>tssw</a>敬上"; |
| | | mailTitlePrefix = commonConfig.getMailTitlePrefix(); |
| | | mailContentSuffix = commonConfig.getMailContentSuffix(); |
| | | HtmlEmail email = new HtmlEmail(); |
| | |
| | | name: wgcloud-server |
| | | datasource: |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | | url: jdbc:mysql://127.0.0.1:3306/wgcloud?characterEncoding=utf-8&characterSetResults=utf8&autoReconnect=true&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true |
| | | url: jdbc:mysql://localhost:3306/wgcloud?characterEncoding=utf-8&characterSetResults=utf8&autoReconnect=true&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true |
| | | username: root |
| | | password: rootroot |
| | | # hikari连接池的参数 相关设置 |
| | |
| | | #服务接口监控间隔,单位秒,默认10分钟 |
| | | heathTimes: 600 |
| | | #数通设备监控间隔,单位秒,默认15分钟 |
| | | dceTimes: 900 |
| | | dceTimes: 300 |
| | | #snmp设备监测间隔,单位秒,默认20分钟 |
| | | snmpTimes: 1200 |
| | | #告警缓存时间间隔(此时间段内同一告警通知不再重复发),单位秒,默认120分钟 |
| | |
| | | #系统简称,如wgcloud,此功能需升级到专业版 |
| | | wgShortName: |
| | | #告警邮件标题前缀,此功能需升级到专业版 |
| | | mailTitlePrefix: '[WGCLOUD]' |
| | | mailTitlePrefix: '[KDQ]' |
| | | #告警邮件内容后缀,此功能需升级到专业版 |
| | | mailContentSuffix: '<p><p><p>WGCLOUD敬上' |
| | | mailContentSuffix: '<p><p><p>KDQ敬上' |
| | | #是否显示页面底部版权、网址信息,yes显示,no不显示,此功能需升级到专业版 |
| | | copyRight: yes |
| | | year: 1 |
| | |
| | | <result column="MONITOR_USERNAME" property="monitorUsername" jdbcType="CHAR" /> |
| | | <result column="MONITOR_PASSWORD" property="monitorPassword" jdbcType="CHAR" /> |
| | | <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="MONITOR_REMOTE_TYPE" property="monitorRemoteType" jdbcType="CHAR" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <sql id="tableColumnList"> |
| | | ID,HOST_NAME, INFO_CONTENT, STATE,AREA_NUM,CREATE_TIME,MONITOR_ID,MONITOR_IP,MONITOR_USERNAME,MONITOR_PASSWORD |
| | | ID,HOST_NAME, INFO_CONTENT, STATE,AREA_NUM,CREATE_TIME,MONITOR_ID,MONITOR_IP,MONITOR_USERNAME,MONITOR_PASSWORD,MONITOR_REMOTE_TYPE |
| | | </sql> |
| | | |
| | | |
| | | <sql id="queryByParams"> |
| | | <if test="hostname != null"> |
| | | <choose> |
| | |
| | | <![CDATA[ AND AREA_NUM = #{areaNum} ]]> |
| | | </if> |
| | | </sql> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="selectById" resultMap="resultMap" parameterType="java.lang.String"> |
| | | SELECT |
| | | <include refid="tableColumnList" /> |
| | | FROM OSPF_INFO WHERE ID=#{id} |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
| | | DELETE FROM OSPF_INFO WHERE ID = #{id} |
| | | </delete> |
| | | |
| | | |
| | | <delete id="deleteByDate" parameterType="map"> |
| | | DELETE FROM OSPF_INFO WHERE |
| | | <if test="_databaseId == 'mysql'"> |
| | |
| | | <![CDATA[ CREATE_TIME <= to_date(#{endTime},'yyyy-MM-dd hh24:mi:ss')]]> |
| | | </if> |
| | | </delete> |
| | | |
| | | |
| | | |
| | | |
| | | <delete id="deleteByAccHname" parameterType="map"> |
| | | DELETE FROM OSPF_INFO WHERE ACCOUNT = #{account} AND HOST_NAME = #{hostname} |
| | | </delete> |
| | | |
| | | |
| | | <delete id="deleteById" parameterType="java.lang.String"> |
| | | DELETE FROM OSPF_INFO WHERE ID IN |
| | | <foreach item="item" index="index" collection="array" open="(" separator="," close=")"> |
| | |
| | | <when test="_databaseId == 'oracle'"> |
| | | begin |
| | | <foreach collection="list" item="item" index="index"> |
| | | INSERT INTO OSPF_INFO (ID,HOST_NAME,INFO_CONTENT,STATE,AREA_NUM,CREATE_TIME,MONITOR_IP,MONITOR_ID,MONITOR_USERNAME,MONITOR_PASSWORD) VALUES |
| | | (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.areaNum},#{item.createTime},#{item.monitorIp},#{item.monitorId},#{item.monitorUsername},#{item.monitorPassword}); |
| | | INSERT INTO OSPF_INFO (ID,HOST_NAME,INFO_CONTENT,STATE,AREA_NUM,CREATE_TIME,MONITOR_IP,MONITOR_ID,MONITOR_REMOTE_TYPE,MONITOR_USERNAME,MONITOR_PASSWORD,CREATE_TIME) VALUES |
| | | (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.areaNum},#{item.createTime},#{item.monitorIp},#{item.monitorId},#{item.monitorRemoteType},#{item.monitorUsername},#{item.monitorPassword},#{item.createTime}); |
| | | </foreach> |
| | | end; |
| | | </when> |
| | | <otherwise> |
| | | INSERT INTO OSPF_INFO (ID,HOST_NAME,INFO_CONTENT,STATE,AREA_NUM,CREATE_TIME,MONITOR_IP,MONITOR_ID,MONITOR_USERNAME,MONITOR_PASSWORD) VALUES |
| | | INSERT INTO OSPF_INFO (ID,HOST_NAME,INFO_CONTENT,STATE,AREA_NUM,CREATE_TIME,MONITOR_IP,MONITOR_ID,MONITOR_REMOTE_TYPE,MONITOR_USERNAME,MONITOR_PASSWORD,CREATE_TIME) VALUES |
| | | <foreach collection="list" item="item" index="index" separator="," > |
| | | (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.areaNum},#{item.createTime},#{item.monitorIp},#{item.monitorId},#{item.monitorUsername},#{item.monitorPassword}) |
| | | (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.areaNum},#{item.createTime},#{item.monitorIp},#{item.monitorId},#{item.monitorRemoteType},#{item.monitorUsername},#{item.monitorPassword},#{item.createTime}) |
| | | </foreach> |
| | | </otherwise> |
| | | </choose> |
| | |
| | | <if test="areaNum != null" >AREA_NUM,</if> |
| | | <if test="monitorIp != null" >MONITOR_IP,</if> |
| | | <if test="monitorId != null" >MONITOR_ID,</if> |
| | | <if test="monitorRemoteType != null" >MONITOR_REMOTE_TYPE,</if> |
| | | <if test="monitorUsername != null" >MONITOR_USERNAME,</if> |
| | | <if test="monitorPassword != null" >MONITOR_PASSWORD,</if> |
| | | <if test="createTime != null" >CREATE_TIME</if> |
| | |
| | | <if test="areaNum != null" >#{areaNum},</if> |
| | | <if test="monitorIp != null" >#{monitorIp},</if> |
| | | <if test="monitorId != null" >#{monitorId},</if> |
| | | <if test="monitorRemoteType != null" >#{monitorRemoteType},</if> |
| | | <if test="monitorUsername != null" >#{monitorUsername},</if> |
| | | <if test="monitorPassword != null" >#{monitorPassword},</if> |
| | | <if test="createTime != null" >#{createTime}</if> |
| | |
| | | </where> |
| | | ORDER BY CREATE_TIME DESC |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByParams" parameterType="map" resultMap="resultMap"> |
| | | SELECT |
| | | <include refid="tableColumnList" /> |
| | |
| | | <if test="monitorPassword != null"> |
| | | MONITOR_PASSWORD = #{monitorPassword}, |
| | | </if> |
| | | <if test="monitorRemoteType != null"> |
| | | MONITOR_REMOTE_TYPE = #{monitorRemoteType}, |
| | | </if> |
| | | </set> |
| | | WHERE ID = #{id} |
| | | </update> |
| | | |
| | | |
| | | </mapper> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | <result column="USERNAME" property="username" jdbcType="CHAR" /> |
| | | <result column="PASSWORD" property="password" jdbcType="CHAR" /> |
| | | <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="REMOTE_TYPE" property="remoteType" jdbcType="CHAR" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <sql id="tableColumnList"> |
| | | ID,HOST_NAME, INFO_CONTENT, STATE,USERNAME,PASSWORD,CREATE_TIME |
| | | ID,HOST_NAME, INFO_CONTENT, STATE,USERNAME,PASSWORD,CREATE_TIME,REMOTE_TYPE |
| | | </sql> |
| | | |
| | | |
| | | <sql id="queryByParams"> |
| | | <if test="hostname != null"> |
| | | <choose> |
| | |
| | | <![CDATA[ AND AREA_NUM = #{areaNum} ]]> |
| | | </if> |
| | | </sql> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="selectById" resultMap="resultMap" parameterType="java.lang.String"> |
| | | SELECT |
| | | <include refid="tableColumnList" /> |
| | | FROM OSPF_MONITOR WHERE ID=#{id} |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
| | | DELETE FROM OSPF_MONITOR WHERE ID = #{id} |
| | | </delete> |
| | | |
| | | |
| | | <delete id="deleteByDate" parameterType="map"> |
| | | DELETE FROM OSPF_MONITOR WHERE |
| | | <if test="_databaseId == 'mysql'"> |
| | |
| | | <![CDATA[ CREATE_TIME <= to_date(#{endTime},'yyyy-MM-dd hh24:mi:ss')]]> |
| | | </if> |
| | | </delete> |
| | | |
| | | |
| | | |
| | | |
| | | <delete id="deleteByAccHname" parameterType="map"> |
| | | DELETE FROM OSPF_MONITOR WHERE ACCOUNT = #{account} AND HOST_NAME = #{hostname} |
| | | </delete> |
| | | |
| | | |
| | | <delete id="deleteById" parameterType="java.lang.String"> |
| | | DELETE FROM OSPF_MONITOR WHERE ID IN |
| | | <foreach item="item" index="index" collection="array" open="(" separator="," close=")"> |
| | |
| | | end; |
| | | </when> |
| | | <otherwise> |
| | | INSERT INTO OSPF_MONITOR (ID,HOST_NAME,INFO_CONTENT,STATE,USERNAME,PASSWORD,CREATE_TIME) VALUES |
| | | INSERT INTO OSPF_MONITOR (ID,HOST_NAME,INFO_CONTENT,STATE,USERNAME,PASSWORD,CREATE_TIME,REMOTE_TYPE) VALUES |
| | | <foreach collection="list" item="item" index="index" separator="," > |
| | | (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.username},#{item.password},#{item.createTime}) |
| | | (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.username},#{item.password},#{item.createTime},#{item.remoteType}) |
| | | </foreach> |
| | | </otherwise> |
| | | </choose> |
| | |
| | | <if test="state != null" >STATE,</if> |
| | | <if test="username != null" >USERNAME,</if> |
| | | <if test="password != null" >PASSWORD,</if> |
| | | <if test="createTime != null" >CREATE_TIME</if> |
| | | <if test="createTime != null" >CREATE_TIME,</if> |
| | | <if test="remoteType != null" >REMOTE_TYPE</if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides="," > |
| | | <if test="id != null" >#{id},</if> |
| | |
| | | <if test="state != null" >#{state},</if> |
| | | <if test="username != null" >#{username},</if> |
| | | <if test="password != null" >#{password},</if> |
| | | <if test="createTime != null" >#{createTime}</if> |
| | | <if test="createTime != null" >#{createTime},</if> |
| | | <if test="remoteType != null" >#{remoteType}</if> |
| | | </trim> |
| | | </insert> |
| | | |
| | |
| | | </where> |
| | | ORDER BY CREATE_TIME DESC |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByParams" parameterType="map" resultMap="resultMap"> |
| | | SELECT |
| | | <include refid="tableColumnList" /> |
| | |
| | | <if test="createTime != null"> |
| | | CREATE_TIME = #{createTime}, |
| | | </if> |
| | | <if test="remoteType != null"> |
| | | REMOTE_TYPE = #{remoteType}, |
| | | </if> |
| | | </set> |
| | | WHERE ID = #{id} |
| | | </update> |
| | | |
| | | |
| | | </mapper> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | <input type="text" th:value="${mailSet.fromMailName}" autocomplete="off" class="validate[required,maxSize[40],custom[email]] form-control" name="fromMailName" id="fromMailName" placeholder="123456@qq.com"> |
| | | </div> |
| | | <div class="form-group"> |
| | | <label for="fromPwd"><font color="red">*</font>发送邮箱密码 <span data-trigger="hover" data-container="body" data-toggle="popover" data-placement="top" data-content="显示密码" onclick="javascript:showPasswd();" style="cursor:pointer;margin-left: 5px"><i id="eyeSwitch" class="fa fa-eye"></i></span></label> |
| | | <label for="fromPwd"><font color="red">*</font>发送邮箱授权码 <span data-trigger="hover" data-container="body" data-toggle="popover" data-placement="top" data-content="显示密码" onclick="javascript:showPasswd();" style="cursor:pointer;margin-left: 5px"><i id="eyeSwitch" class="fa fa-eye"></i></span></label> |
| | | <input type="password" th:value="${mailSet.fromPwd}" class="validate[required,maxSize[20]] form-control" name="fromPwd" id="fromPwd" placeholder=""> |
| | | </div> |
| | | <div class="form-group"> |
| | |
| | | <label>密码</label> |
| | | <input type="text" autocomplete="off" th:value="${ospfMonitor.password}" class="validate[required,maxSize[50]] form-control" name="password" id="password" placeholder=""> |
| | | </div> |
| | | <div class="form-group"> |
| | | <label><font color="red">*</font>连接类型</label> |
| | | <select class="validate[required] form-control" name="remoteType" id="remoteType"> |
| | | <option value="">请选择</option> |
| | | <option value="TELNET" th:selected="${ospfMonitor.remoteType == 'TELNET'}">TELNET</option> |
| | | <option value="SSH" th:selected="${ospfMonitor.remoteType == 'SSH'}">SSH</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <!-- /.card-body --> |
| | | |
| | |
| | | <th title="设备IP">设备IP</th> |
| | | <th title="用户名">用户名</th> |
| | | <th title="密码">密码</th> |
| | | <th title="连接方式">连接方式</th> |
| | | </tr> |
| | | </th:block> |
| | | </thead> |
| | |
| | | <td th:text="${item.hostname}"></td> |
| | | <td th:text="${item.username}"></td> |
| | | <td th:text="${item.password}"></td> |
| | | <td th:text="${item.remoteType}"></td> |
| | | <td> |
| | | <th:block th:if="${session.LOGIN_KEY.role != 'guest'}"> |
| | | <button type="button" th:onclick="del([[${item.id}]])" class="btn bg-gradient-danger btn-sm">删除</button> |