提交 9cc43f0f 编写于 作者: tianshiyeben's avatar tianshiyeben

no message

上级 bcf4c288

要显示的变更太多。

To preserve performance only 1000 of 1000+ files are displayed.
## WGCLOUD
linux性能监测工具,运维监控,网络吞吐率,服务器cpu监控,内存监控
![a.jpg](https://raw.githubusercontent.com/tianshiyeben/wgcloud/master/demo/a.jpg)
## 依赖环境
1.JDK1.8
2.tomcat8.5+
3.mysql5.6+
4.CentOS6.4或以上,Red Hat6.4或以上,其他系统暂不支持
5.检测被监控的HOST主机是否已经安装sysstat,如下信息说明已经安装,如果没有请通过yum install sysstat安装
```
[root@localhost ~]# mpstat
Linux 3.10.0-514.el7.x86_64 (localhost.localdomain) 2019年01月10日 _x86_64_ (4 CPU)
13时40分26秒 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
13时40分26秒 all 0.60 0.00 0.19 0.16 0.00 0.03 0.00 0.00 0.00 99.02
```
## 源码使用
用eclispe新建一个web maven工程,使用src来替换新建工程的src目录,使用pom.xml替换新建工程里的pom.xml,设置好jdk即可。
sql文件夹是数据库创建脚本,在mysql新建名为dats的数据库,执行dats.sql脚本
application.properties,配置数据库链接信息
host.properties,配置监控服务器信息,格式为ip=端口//用户名//密码,可以配置多个,尽量不要使用root账号
因为本应用会通过配置的host.properties信息来从目标服务器获取运行状态,所以被监控的服务器不需要安装本应用。
## 监控指标
```
%usr:用户态的CPU时间(%)
%sys:核心时间(%))
%idle:空闲时间(%)
%iowait:IO等待时间(%)
rxpck/s:每秒钟接收的数据包
txpck/s:每秒钟发送的数据包
rxkB/s:每秒钟接收的kb
txkB/s:每秒钟发送的kb
active/s:每秒本地发起的TCP连接数,既通过connect调用创建的TCP连接
passive/s:每秒远程发起的TCP连接数,即通过accept调用创建的TCP连接
%CPU:进程占用CPU的使用率
%MEM:进程使用的物理内存和总内存的百分比
r/s, w/s, rkB/s, wkB/s:分别表示每秒读写次数和每秒读写数据量(千字节)。读写量过大,可能会引起性能问题。
await:IO操作的平均等待时间,单位是毫秒。这是应用程序在和磁盘交互时,需要消耗的时间,包括IO等待和实际操作的耗时。
如果这个数值过大,可能是硬件设备遇到了瓶颈或者出现故障。
avgqu-sz:向设备发出的请求平均数量。如果这个数值大于1,可能是硬件设备已经饱和(部分前端硬件设备支持并行写入)。
%util:设备利用率。这个数值表示设备的繁忙程度,经验值是如果超过60,可能会影响IO性能(可以参照IO操作平均等待时间)。
如果到达100%,说明硬件设备已经饱和。
```
![b.jpg](https://raw.githubusercontent.com/tianshiyeben/wgcloud/master/demo/b.jpg)
## 连接失败的服务器信息怎么删除
服务器每3天会清空连接失败的服务器信息,所以3天后你就看不到连接失败的服务器信息了。目前暂不支持手动操作,全部由系统自动处理。
同时系统会定时清除30天前的监控信息。
## 告警提示规则
系统内存使用率阈值99%,超过发送邮件,24小时不会重复发。
进程内存监控报警百分比阈值99%,超过发送邮件,24小时不会重复发。
进程CPU使用率监控报警百分比阈值99%,超过发送邮件,24小时不会重复发。
若不想接受告警通知,可在applications.properties里,关闭提示。
## 访问地址
http://localhost:9000/wgcloud
登陆账号/密码:admin/111111
## 联系
邮件:wg900@qq.com
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wgcloud</groupId>
<artifactId>wgcloud</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>wgcloud Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.java.version>1.8</project.build.java.version>
</properties>
<!-- maven jar仓库配置,用于增加私有仓库或者国内仓库 -->
<repositories>
<repository>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>central-repos</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>central-repos2</id>
<name>Central Repository 2</name>
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<!-- maven plugin仓库配置,用于增加私有仓库或者国内仓库 -->
<pluginRepositories>
<pluginRepository>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</pluginRepository>
<pluginRepository>
<id>central-repos</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</pluginRepository>
<pluginRepository>
<id>central-repos2</id>
<name>Central Repository 2</name>
<url>http://repo1.maven.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.*</include>
</includes>
</resource>
</resources>
<!--当项目没有规定目标时的默认值-->
<defaultGoal>install</defaultGoal>
<plugins>
<!-- java编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${project.build.java.version}</source>
<target>${project.build.java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
<!-- 指定jsp等文件所在位置 -->
<warSourceDirectory>src\main\webapp</warSourceDirectory>
<webResources>
<resource>
<directory>target/classes</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.17.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.3.17.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.3.17.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.17.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.17.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.17.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.9.1.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
</dependency>
<dependency>
<groupId>ch.ethz.ganymed</groupId>
<artifactId>ganymed-ssh2</artifactId>
<version>262</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>17.0</version>
</dependency>
<dependency>
<groupId>math.geom2d</groupId>
<artifactId>javaGeom</artifactId>
<version>0.11.1</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.8</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
/*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1
Source Server Version : 50717
Source Host : localhost:3306
Source Database : dats
Target Server Type : MYSQL
Target Server Version : 50717
File Encoding : 65001
Date: 2019-01-03 09:38:43
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for app_info
-- ----------------------------
DROP TABLE IF EXISTS `app_info`;
CREATE TABLE `app_info` (
`ID` char(32) NOT NULL,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(30) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`APP_PID` char(15) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
`APP_NAME` varchar(50) DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `APP_INFO_INDEX` (`ACCOUNT_ID`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of app_info
-- ----------------------------
-- ----------------------------
-- Table structure for app_state
-- ----------------------------
DROP TABLE IF EXISTS `app_state`;
CREATE TABLE `app_state` (
`ID` char(32) NOT NULL,
`APP_INFO_ID` char(32) DEFAULT NULL,
`CPU_PER` char(10) DEFAULT NULL,
`MEM_PER` char(10) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `APP_STAT_INDEX` (`APP_INFO_ID`,`CREATE_TIME`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of app_state
-- ----------------------------
-- ----------------------------
-- Table structure for cpu_state
-- ----------------------------
DROP TABLE IF EXISTS `cpu_state`;
CREATE TABLE `cpu_state` (
`ID` char(32) NOT NULL,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(30) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`USER` char(30) DEFAULT NULL,
`SYS` char(30) DEFAULT NULL,
`IDLE` char(30) DEFAULT NULL,
`IOWAIT` char(30) DEFAULT NULL,
`IRQ` char(30) DEFAULT NULL,
`SOFT` char(30) DEFAULT NULL,
`DATE_STR` char(30) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `CPU_ACC_HOST_INDEX` (`ACCOUNT_ID`,`HOST_NAME`,`CREATE_TIME`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of cpu_state
-- ----------------------------
-- ----------------------------
-- Table structure for desk_state
-- ----------------------------
DROP TABLE IF EXISTS `desk_state`;
CREATE TABLE `desk_state` (
`ID` char(32) NOT NULL,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(30) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`FILE_STSTEM` char(30) DEFAULT NULL,
`SIZE` char(30) DEFAULT NULL,
`USED` char(30) DEFAULT NULL,
`AVAIL` char(30) DEFAULT NULL,
`USE_PER` char(10) DEFAULT NULL,
`DATE_STR` char(30) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `DESK_ACC_HOST_INDEX` (`ACCOUNT_ID`,`HOST_NAME`,`CREATE_TIME`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of desk_state
-- ----------------------------
-- ----------------------------
-- Table structure for diskio_state
-- ----------------------------
DROP TABLE IF EXISTS `diskio_state`;
CREATE TABLE `diskio_state` (
`ID` char(32) COLLATE utf8_unicode_ci NOT NULL,
`ACCOUNT_ID` char(32) COLLATE utf8_unicode_ci DEFAULT NULL,
`ACCOUNT` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`HOST_NAME` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`RS` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`WS` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`RKBS` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`WKBS` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`AWAIT` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`AVGQUSZ` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`UTIL` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
`DATE_STR` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- ----------------------------
-- Records of diskio_state
-- ----------------------------
-- ----------------------------
-- Table structure for intrusion_info
-- ----------------------------
DROP TABLE IF EXISTS `intrusion_info`;
CREATE TABLE `intrusion_info` (
`ID` char(32) NOT NULL,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(10) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`LSMOD` text,
`PASSWD_INFO` varchar(100) DEFAULT NULL,
`CRONTAB` text,
`PROMISC` varchar(100) DEFAULT NULL,
`RPCINFO` text,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of intrusion_info
-- ----------------------------
-- ----------------------------
-- Table structure for log_info
-- ----------------------------
DROP TABLE IF EXISTS `log_info`;
CREATE TABLE `log_info` (
`ID` char(32) NOT NULL,
`ACCOUNT` char(50) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`INFO_CONTENT` varchar(500) DEFAULT NULL,
`STATE` char(1) DEFAULT NULL,
`CREATE_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`),
KEY `LOG_ACCOUNT_INDEX` (`ACCOUNT`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of log_info
-- ----------------------------
-- ----------------------------
-- Table structure for mem_state
-- ----------------------------
DROP TABLE IF EXISTS `mem_state`;
CREATE TABLE `mem_state` (
`ID` char(32) NOT NULL,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(30) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`TOTAL` char(30) DEFAULT NULL,
`USED` char(30) DEFAULT NULL,
`FREE` char(30) DEFAULT NULL,
`USE_PER` char(10) DEFAULT NULL,
`DATE_STR` char(30) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `MEM_ACC_HOST_INDEX` (`ACCOUNT_ID`,`HOST_NAME`,`CREATE_TIME`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of mem_state
-- ----------------------------
-- ----------------------------
-- Table structure for msg_info
-- ----------------------------
DROP TABLE IF EXISTS `msg_info`;
CREATE TABLE `msg_info` (
`ID` char(32) NOT NULL,
`ACCEPT_INFO` char(50) DEFAULT NULL,
`INFO_CONTENT` varchar(255) DEFAULT NULL,
`MSG_TITLE` varchar(100) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(30) DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `MSG_ACCOUNT_INDEX` (`ACCOUNT`) USING BTREE,
KEY `MSG_ACCEPT_INDEX` (`ACCEPT_INFO`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of msg_info
-- ----------------------------
-- ----------------------------
-- Table structure for netio_state
-- ----------------------------
DROP TABLE IF EXISTS `netio_state`;
CREATE TABLE `netio_state` (
`ID` char(32) NOT NULL,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(30) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`RXPCK` char(30) DEFAULT NULL,
`TXPCK` char(30) DEFAULT NULL,
`RXBYT` char(30) DEFAULT NULL,
`TXBYT` char(30) DEFAULT NULL,
`RXCMP` char(30) DEFAULT NULL,
`TXCMP` char(30) DEFAULT NULL,
`RXMCST` char(30) DEFAULT NULL,
`DATE_STR` char(30) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `NETIO_ACC_HOST_INDEX` (`ACCOUNT_ID`,`HOST_NAME`,`CREATE_TIME`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of netio_state
-- ----------------------------
-- ----------------------------
-- Table structure for system_info
-- ----------------------------
DROP TABLE IF EXISTS `system_info`;
CREATE TABLE `system_info` (
`ID` char(32) NOT NULL,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(30) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`VERSION` char(100) DEFAULT NULL,
`VERSION_DETAIL` char(200) DEFAULT NULL,
`CPU_NUM` char(30) DEFAULT NULL,
`YX_DAYS` char(10) DEFAULT NULL,
`CPU_CORE_NUM` char(10) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
`CPU_XH` char(150) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of system_info
-- ----------------------------
-- ----------------------------
-- Table structure for sys_load_state
-- ----------------------------
DROP TABLE IF EXISTS `sys_load_state`;
CREATE TABLE `sys_load_state` (
`ID` char(32) NOT NULL,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(30) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`ONE_LOAD` char(30) DEFAULT NULL,
`FIVE_LOAD` char(30) DEFAULT NULL,
`FIFTEEN_LOAD` char(30) DEFAULT NULL,
`USERS` char(10) DEFAULT NULL,
`DATE_STR` char(30) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `LOAD_ACC_HOST_INDEX` (`ACCOUNT_ID`,`HOST_NAME`,`CREATE_TIME`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sys_load_state
-- ----------------------------
-- ----------------------------
-- Table structure for tcp_state
-- ----------------------------
DROP TABLE IF EXISTS `tcp_state`;
CREATE TABLE `tcp_state` (
`ID` char(32) NOT NULL,
`ACCOUNT_ID` char(32) DEFAULT NULL,
`ACCOUNT` char(30) DEFAULT NULL,
`HOST_NAME` char(30) DEFAULT NULL,
`ACTIVE` char(30) DEFAULT NULL,
`PASSIVE` char(30) DEFAULT NULL,
`RETRANS` char(30) DEFAULT NULL,
`DATE_STR` char(30) DEFAULT NULL,
`CREATE_TIME` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `TCP_ACC_HOST_INDEX` (`ACCOUNT_ID`,`HOST_NAME`,`CREATE_TIME`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of tcp_state
-- ----------------------------
package com.common;
import java.util.Iterator;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.core.timer.impl.BatchCommitJobImpl;
import com.core.timer.impl.MonitorDayJobImpl;
import com.util.HostInfo;
import com.util.MyDayTask;
import com.util.MyHourTask;
import com.util.MyMinTask;
import com.util.PropertyUtil;
import com.util.staticvar.StaticKeys;
/**
*
* @ClassName:AppInit.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: AppInit.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class AppInit implements ServletContextListener{
private static final Logger logger = LoggerFactory.getLogger(AppInit.class);
//邮件帐号
public static String fromMailName = "";
//邮件密码
public static String fromPwd = "";
//SMTP服务器
public static String smtpHost = "";
//SMTP端口
public static String smtpPort="";
//是否使用SSL,0不使用,1使用
public static String smtpSSL="";
//admin管理员密码
public static String admindPwd= "111111";
//是否发送邮件告警标识
public static String sendMail = "1";
//接受邮件的地址
public static String toMail = "";
/* (non-Javadoc)
* @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
*/
@Override
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
*/
@Override
public void contextInitialized(ServletContextEvent arg0) {
//从配置文件读取邮箱用户名
fromMailName = PropertyUtil.get("application.properties", "fromMailName");
//从配置文件读取邮箱密码
fromPwd = PropertyUtil.get("application.properties", "fromPwd");
//从配置文件读取smtp服务器
smtpHost = PropertyUtil.get("application.properties", "smtpHost");
//从配置文件读取smtp端口
smtpPort = PropertyUtil.get("application.properties", "smtpPort");
//从配置文件读取smtpSSL标识
smtpSSL = PropertyUtil.get("application.properties", "smtpSSL");
//从配置文件读取管理员密码
admindPwd = PropertyUtil.get("application.properties", "admindPwd");
//是否发送邮件告警标识,1发送0不发送
sendMail = PropertyUtil.get("application.properties", "sendMail");
//接受邮件的地址
toMail = PropertyUtil.get("application.properties", "toMail");
TimerTask dayTask = new MonitorDayJobImpl();
TimerTask minTask = new BatchCommitJobImpl();
Timer timer = new Timer();
//1分钟后执行,之后每隔24小时执行
timer.schedule(dayTask, 60000,24*60*60*1000);
//10分钟后执行,之后每隔5分钟执行
timer.schedule(minTask, 600000,5*60*1000);
//从配置文件加载host信息
Set<String> set = PropertyUtil.getKeys(""+StaticKeys.HOST_PRO_FILE);
Iterator<String> iter = set.iterator();
while(iter.hasNext()){
HostInfo hostInfo = new HostInfo();
hostInfo.setHostname(iter.next());
String hostStr = PropertyUtil.get(""+StaticKeys.HOST_PRO_FILE, hostInfo.getHostname());
if(StringUtils.isEmpty(hostStr)){
break;
}
hostStr = hostStr.trim();
hostInfo.setSshPort(Integer.valueOf(hostStr.split("//")[0]));
hostInfo.setUsername(hostStr.split("//")[1]);
hostInfo.setPassword(hostStr.split("//")[2]);
StaticKeys.hostInfoList.add(hostInfo);
}
TimerTask dayClientTask = new MyDayTask();
TimerTask hourClientTask = new MyHourTask();
TimerTask minClientTask = new MyMinTask();
Timer timerClient = new Timer();
//2分钟后执行,之后每隔2小时执行
timerClient.schedule(hourClientTask, 120000,2*60*60*1000);
//9分钟后执行,之后每隔24小时执行
timerClient.schedule(dayClientTask, 540000,24*60*60*1000);
//16分钟后执行,之后每隔10分钟执行
timerClient.schedule(minClientTask, 960000,10*60*1000);
}
}
package com.common;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
*
* @ClassName:ApplicationContextHelper.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: ApplicationContextHelper.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Component
public class ApplicationContextHelper implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext( ApplicationContext applicationContext1 ) throws BeansException {
applicationContext = applicationContext1;
}
public static ApplicationContext getApplicationContext(){
return applicationContext;
}
@SuppressWarnings("unchecked")
public static <T> T getBean(Class<T> clazz) {
return (T) applicationContext.getBean(clazz);
}
}
\ No newline at end of file
package com.common;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.util.staticvar.StaticKeys;
/**
*
* @ClassName:LoginInterceptor.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: LoginInterceptor.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class LoginInterceptor implements HandlerInterceptor {
String[] static_resource = {"login/toLogin","login/login","sys/code",".css",".js",".jpg",".png",".ico",".gif","font"};
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
String uri = request.getRequestURI();
for (String ss : static_resource) {
if (uri.indexOf(ss) != -1) {
return true;
}
}
Object user = request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
if (user != null) {
return true;
}
response.sendRedirect("/wgcloud/sys/login/toLogin");
return false;
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
}
}
\ No newline at end of file
package com.common;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
/**
*
* @ClassName:Page.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: Page.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@SuppressWarnings("serial")
public class Page implements Serializable {
public static final Page EMPTY_PAGE = new Page(Collections.EMPTY_LIST, 0, 0, 0);
@SuppressWarnings("rawtypes")
private List objects;
private int pageSize;
private int totalNumber;
private int totalPage;
private int currentPage;
private int viewCountPages;
public Page(){}
@SuppressWarnings({ "rawtypes" })
public Page(List objects, int pageSize, int totalNum, int currentPage) {
if (objects.equals(Collections.EMPTY_LIST)) {
this.objects = objects;
}else{
this.objects = objects;
this.totalNumber = totalNum;
this.currentPage = currentPage;
this.pageSize = pageSize;
this.totalPage = (totalNumber - 1) / pageSize + 1;
if((this.currentPage+5<10)&&(this.totalPage<10)){
this.viewCountPages = totalPage;
}else if((this.currentPage+5<10)&&(this.totalPage>=10)){
this.viewCountPages = 10;
}else if(this.currentPage+5>this.totalPage){
this.viewCountPages = this.totalPage;
}else{
this.viewCountPages = this.currentPage+5;
}
}
}
@SuppressWarnings("rawtypes")
public List getList() {
return objects;
}
public int getPageSize() {
return pageSize;
}
public int getTotalNumber() {
return totalNumber;
}
public int getTotalPage() {
return totalPage;
}
public int getCurrentPage() {
if(this.getTotalNumber()>0)
currentPage = currentPage<1?1:currentPage;
return currentPage;
}
@SuppressWarnings("rawtypes")
public void setList(List objects) {
this.objects = objects;
}
public String toString(){
StringBuffer sb=null;
if(objects!=null){
sb=new StringBuffer(500);
for(int i=0;i<objects.size();i++){
sb.append(objects.toString()).append(",");
}
}
return sb==null?"":sb.toString();
}
@SuppressWarnings("rawtypes")
public List getObjects() {
return objects;
}
/**
* @param objects the objects to set
*/
@SuppressWarnings("rawtypes")
public void setObjects(List objects) {
this.objects = objects;
}
/**
* @param pageSize the pageSize to set
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
/**
* @param totalNumber the totalNumber to set
*/
public void setTotalNumber(int totalNumber) {
this.totalNumber = totalNumber;
}
/**
* @param totalPage the totalPage to set
*/
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
/**
* @param currentPage the currentPage to set
*/
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getViewCountPages() {
return viewCountPages;
}
public void setViewCountPages(int viewCountPages) {
this.viewCountPages = viewCountPages;
}
}
package com.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.common.Page;
import com.entity.app.AppInfo;
import com.entity.host.SystemInfo;
import com.entity.user.AccountInfo;
import com.service.app.AppInfoService;
import com.service.app.AppStateService;
import com.service.dash.DashboardService;
import com.service.host.SystemInfoService;
import com.service.log.LogInfoService;
import com.util.DateUtil;
import com.util.staticvar.HostKeys;
import com.util.staticvar.StaticKeys;
/**
*
* @ClassName:AppInfoController.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: AppInfoController.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Controller
@RequestMapping("/sys/app")
public class AppInfoController {
private static final Logger logger = LoggerFactory.getLogger(AppInfoController.class);
private String MENU_MARK = "app";//菜单标识
@Resource
private AppInfoService appInfoService;
@Resource
private AppStateService appStateService;
@Resource
private LogInfoService logInfoService;
@Resource
private DashboardService dashBoardService;
@Resource
private SystemInfoService systemInfoService;
@Resource
DashboardService dashboardService;
/**
* 根据条件查询app应用信息列表
* @param model
* @param request
* @return
*/
@RequestMapping(value="list")
public String AppInfoList(Model model,HttpServletRequest request) {
String curPage = request.getParameter(StaticKeys.CUR_PAGE);
if(StringUtils.isEmpty(curPage)){
curPage = "1";
}
Map<String, Object> params = new HashMap<String, Object>();
StringBuffer url = new StringBuffer();
Page page = null;
try {
page = appInfoService.selectByParams(params, Integer.valueOf(curPage), StaticKeys.PAGE_SIZE);
model.addAttribute("pageUrl", "/sys/app/list?1=1"+ url.toString());
model.addAttribute("page", page);
} catch (Exception e) {
logger.error("查询出错",e);
}
model.addAttribute(MENU_MARK, StaticKeys.MENU_ACTIVE);
return "app/list";
}
/**
* 转到添加页面
* @param AppInfo
* @param model
* @param request
* @return
*/
@RequestMapping(value="add")
public String addAppInfo( Model model,HttpServletRequest request) {
model.addAttribute(MENU_MARK, StaticKeys.MENU_ACTIVE);
try {
AccountInfo accountInfo = (AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
List<SystemInfo> sysInfoList = systemInfoService.selectByAccountId(accountInfo.getId());
model.addAttribute("sysInfoList", sysInfoList);
} catch (Exception e) {
logger.error("转到添加页面错误:",e);
}
return "app/add";
}
/**
* 保存应用监控信息
* @param AppInfo
* @param model
* @param request
* @return
*/
@RequestMapping(value="save")
public String saveAppInfo(AppInfo AppInfo, Model model,HttpServletRequest request) {
try {
AccountInfo accountInfo = (AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
Map<String, Object> params = new HashMap<String, Object>();
params.put("account", accountInfo.getAccount());
AppInfo.setAccount(accountInfo.getAccount());
AppInfo.setAccountId(accountInfo.getId());
appInfoService.save(AppInfo);
} catch (Exception e) {
logger.error("保存APP应用信息错误:",e);
}
return "redirect:/sys/app/list";
}
/**
* 查看APP应用信息
* @param AppInfo
* @param model
* @param request
* @return
*/
@RequestMapping(value="view")
public String viewAppInfo(Model model,HttpServletRequest request) {
String errorMsg = "转到查看APP应用页面错误:";
String id = request.getParameter("id");
AccountInfo accountInfo = (AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
model.addAttribute(MENU_MARK, StaticKeys.MENU_ACTIVE);
AppInfo AppInfo;
try {
AppInfo = appInfoService.selectById(id);
model.addAttribute("appInfo", AppInfo);
} catch (Exception e) {
logger.error(errorMsg,e);
logInfoService.save(accountInfo.getAccount(),"",errorMsg+e,StaticKeys.LOG_ERROR);
}
return "app/view";
}
/**
* 修改APP应用信息
* @param AppInfo
* @param model
* @param request
* @return
*/
@RequestMapping(value="edit")
public String editAppInfo(Model model,HttpServletRequest request) {
String errorMsg = "转到修改APP应用页面错误:";
String id = request.getParameter("id");
AccountInfo accountInfo = (AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
AppInfo AppInfo;
try {
AppInfo = appInfoService.selectById(id);
model.addAttribute("appInfo", AppInfo);
model.addAttribute(MENU_MARK, StaticKeys.MENU_ACTIVE);
List<SystemInfo> sysInfoList = systemInfoService.selectByAccountId(accountInfo.getId());
model.addAttribute("sysInfoList", sysInfoList);
} catch (Exception e) {
logger.error(errorMsg,e);
logInfoService.save(accountInfo.getAccount(),"",errorMsg+e,StaticKeys.LOG_ERROR);
}
return "app/edit";
}
/**
* 查看该应用统计图
* @param AppInfo
* @param model
* @param request
* @return
*/
@RequestMapping(value="viewChart")
public String viewChart(Model model,HttpServletRequest request) {
String errorMsg = "查看该应用统计图错误:";
String id = request.getParameter("id");
String date = request.getParameter("date");
String am = request.getParameter("am");
AccountInfo accountInfo = (AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
AppInfo AppInfo;
Page page = null;
try {
AppInfo = appInfoService.selectById(id);
Map<String, Object> params = new HashMap<String, Object>();
params.put("appInfoId", id);
if(StringUtils.isEmpty(date)){
date = DateUtil.getCurrentDate();
am = dashboardService.getDefaultAm();
}
dashboardService.setDateParam(am, date, params);
//组装日期查询字符串集合
model.addAttribute("dateList", dashBoardService.getDateList());
model.addAttribute("date", date);
model.addAttribute("am", am);
page = appStateService.selectByParams(params, 1, HostKeys.CHART_DATA_SIZE);
String appStateChart = dashBoardService.appStateChar(page.getObjects());
//echart图长度计算
if(page.getObjects().size()>HostKeys.BAR_SIZE){
model.addAttribute("chartWidth", ";width:"+page.getObjects().size()*HostKeys.BAR_WIDTH);
}
model.addAttribute("appInfo", AppInfo);
model.addAttribute("appStateChart", appStateChart);
model.addAttribute(MENU_MARK, StaticKeys.MENU_ACTIVE);
} catch (Exception e) {
logger.error(errorMsg,e);
logInfoService.save(accountInfo.getAccount(),"",errorMsg+e,StaticKeys.LOG_ERROR);
}
return "app/appState";
}
/**
* 修改APP应用信息
* @param AppInfo
* @param model
* @param request
* @return
*/
@RequestMapping(value="update")
public String updateAppInfo(AppInfo AppInfo, Model model,HttpServletRequest request) {
String errorMsg = "修改APP应用信息错误:";
AccountInfo accountInfo = (AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
try {
appInfoService.updateById(AppInfo);
} catch (Exception e) {
logger.error(errorMsg,e);
logInfoService.save(accountInfo.getAccount(),"",errorMsg+e,StaticKeys.LOG_ERROR);
}
return "redirect:/sys/app/list";
}
/**
* 删除APP应用信息
* @param id
* @param model
* @param request
* @param redirectAttributes
* @return
*/
@RequestMapping(value="del")
public String delete(Model model,HttpServletRequest request,RedirectAttributes redirectAttributes) {
String errorMsg = "删除app信息错误:";
AccountInfo accountInfo = (AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
try {
if(!StringUtils.isEmpty(request.getParameter("id"))){
appInfoService.deleteById(request.getParameter("id").split(","));
}
} catch (Exception e) {
logger.error(errorMsg,e);
logInfoService.save(accountInfo.getAccount(),"",errorMsg+e,StaticKeys.LOG_ERROR);
}
return "redirect:/sys/app/list";
}
}
package com.controller;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.util.staticvar.StaticKeys;
/**
*
* @ClassName:CodeController.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: CodeController.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Controller
@RequestMapping(value="/sys/code")
public class CodeController {
private static final Logger logger = LoggerFactory.getLogger(CodeController.class);
private int codeCount = 4;//定义图片上显示验证码的个数
char[] codeSequence = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
/**
* 获取验证码
* @param model
* @param request
* @return
*/
@RequestMapping(value="get")
public void hostInfoList(Model model,HttpServletRequest req, HttpServletResponse resp) {
int xx = 13;
int codeY = 22;
int width = 70;//定义图片的width
int height = 30;//定义图片的height
int fontHeight = 20;
// 定义图像buffer
BufferedImage buffImg = new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
// Graphics2D gd = buffImg.createGraphics();
//Graphics2D gd = (Graphics2D) buffImg.getGraphics();
Graphics gd = buffImg.getGraphics();
// 创建一个随机数生成器类
Random random = new Random();
// 将图像填充为白色
gd.setColor(Color.getColor("#ef3f22"));
gd.fillRect(0, 0, width, height);
// 创建字体,字体的大小应该根据图片的高度来定。
Font font = new Font("ITALIC", 0, fontHeight);
// 设置字体。
gd.setFont(font);
// 画边框。
gd.setColor(Color.BLACK);
gd.drawRect(0, 0, width - 1, height - 1);
// randomCode用于保存随机产生的验证码,以便用户登录后进行验证。
StringBuilder randomCode = new StringBuilder();
int red = 0, green = 0, blue = 0;
Font font2 = new Font("Fixedsys", Font.BOLD, fontHeight);
// 设置字体。
gd.setFont(font2);
// 随机产生codeCount数字的验证码。
for (int i = 0; i < codeCount; i++) {
// 得到随机产生的验证码数字。
String code = String.valueOf(codeSequence[random.nextInt(codeSequence.length)]);
// 产生随机的颜色分量来构造颜色值,这样输出的每位数字的颜色值都将不同。
red = random.nextInt(255);
green = random.nextInt(255);
blue = random.nextInt(255);
// 用随机产生的颜色将验证码绘制到图像中。
//gd.setColor(new Color(red, green, blue));
gd.drawString(code, (i + 1) * xx, codeY);
// 将产生的四个随机数组合在一起。
randomCode.append(code);
}
// 将四位数字的验证码保存到Session中。
HttpSession session = req.getSession();
session.setAttribute(StaticKeys.SESSION_CODE, randomCode.toString());
// 禁止图像缓存。
resp.setHeader("Pragma", "no-cache");
resp.setHeader("Cache-Control", "no-cache");
resp.setDateHeader("Expires", 0);
resp.setContentType("image/jpeg");
// 将图像输出到Servlet输出流中。
ServletOutputStream sos;
try {
sos = resp.getOutputStream();
ImageIO.write(buffImg, "jpeg", sos);
sos.close();
} catch (IOException e) {
logger.error("生成验证码异常:",e);
}
}
}
\ No newline at end of file
package com.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
/**
*
* @ClassName:CommonCotroller.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: CommonCotroller.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Controller
@RequestMapping(value="/common/error")
public class CommonCotroller {
/**
* 转向到404页面
* @param model
* @param request
* @return
*/
@RequestMapping("404")
public String to404(Model model,HttpServletRequest request) {
return "error/404";
}
/**
* 转向到500页面
* @param model
* @param request
* @return
*/
@RequestMapping("500")
public String to500(Model model,HttpServletRequest request) {
return "error/500";
}
}
\ No newline at end of file
package com.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.common.Page;
import com.entity.dash.DashboardView;
import com.entity.host.IntrusionInfo;
import com.entity.host.MemState;
import com.entity.host.SystemInfo;
import com.entity.user.AccountInfo;
import com.service.dash.DashboardService;
import com.service.host.CpuStateService;
import com.service.host.DeskStateService;
import com.service.host.DiskIoStateService;
import com.service.host.IntrusionInfoService;
import com.service.host.MemStateService;
import com.service.host.NetIoStateService;
import com.service.host.SysLoadStateService;
import com.service.host.SystemInfoService;
import com.service.host.TcpStateService;
import com.util.DateUtil;
import com.util.staticvar.HostKeys;
import com.util.staticvar.StaticKeys;
/**
*
* @ClassName:DashboardCotroller.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: DashboardCotroller.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Controller
@RequestMapping(value="/sys/dash")
public class DashboardCotroller {
private static final Logger logger = LoggerFactory.getLogger(DashboardCotroller.class);
@Resource
DashboardService dashboardService;
@Resource
CpuStateService cpuStateService;
@Resource
DeskStateService deskStateService;
@Resource
MemStateService memStateService;
@Resource
NetIoStateService netIoStateService;
@Resource
SysLoadStateService sysLoadStateService;
@Resource
TcpStateService tcpStateService;
@Resource
SystemInfoService systemInfoService;
@Resource
DiskIoStateService diskIoStateService;
@Resource
IntrusionInfoService intrusionInfoService;
/**
* 根据条件查询host列表
* @param model
* @param request
* @return
*/
@RequestMapping(value="main")
public String hostInfoList(Model model,HttpServletRequest request) {
List<DashboardView> dashboardList = new ArrayList();
AccountInfo accountInfo =(AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
List<SystemInfo> systemInfoList = null;
Map<String, Object> params = new HashMap<String, Object>();
Page page = null;
List<MemState> memStateList = null;
boolean isSetMemDate = false;//标识是否已经设置过最后获取内存时间
try {
systemInfoList = systemInfoService.selectByAccountId(accountInfo.getId());
for(int i = 0 ; i < systemInfoList.size(); i++){
SystemInfo systemInfo = systemInfoList.get(i);
params.put("accountId", accountInfo.getId());
params.put("hostname", systemInfo.getHostname());
if(StaticKeys.CONN_HOST_ERROR.equals(systemInfo.getVersion())){
DashboardView dashboardView = new DashboardView();
dashboardView.setHostname(systemInfo.getHostname());
dashboardView.setVersion(systemInfo.getVersion());
dashboardList.add(dashboardView);
continue;
}
page = memStateService.selectByParams(params, 1, 1);
memStateList = page.getObjects();
if(memStateList==null||memStateList.size()==0){
continue;
}
if(!isSetMemDate){
model.addAttribute("date", DateUtil.getDateTimeString(memStateList.get(0).getCreateTime()));
isSetMemDate = true;
}
DashboardView dashboardView = new DashboardView();
dashboardView.setHostname(systemInfo.getHostname());
dashboardView.setVersion(systemInfo.getVersion());
dashboardView.setYxDays(systemInfo.getYxDays());
dashboardView.setMemPer(Double.valueOf(memStateList.get(0).getUsePer()));
dashboardList.add(dashboardView);
}
} catch (Exception e) {
logger.error("主面板信息异常:",e);
}
model.addAttribute("list", dashboardList);
model.addAttribute("dashboard", StaticKeys.MENU_ACTIVE);
return "dash/dashboard";
}
/**
* 根据IP查询服务器详情信息
* @param model
* @param request
* @return
*/
@RequestMapping(value="detail")
public String hostDetail(Model model,HttpServletRequest request) {
//服务器名称
String hostname = request.getParameter("hostname");
String date = request.getParameter("date");
String am = request.getParameter("am");
AccountInfo accountInfo =(AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
model.addAttribute("dashboard", StaticKeys.MENU_ACTIVE);
Page page = null;
String returnView = "dash/dashdetail";
try {
if(!StringUtils.isEmpty(hostname)){
Map<String, Object> params = new HashMap<String, Object>();
params.put("accountId", accountInfo.getId());
params.put("hostname", hostname);
if(StringUtils.isEmpty(date)){
date = DateUtil.getCurrentDate();
am = dashboardService.getDefaultAm();
}
dashboardService.setDateParam(am, date, params);
//组装日期查询字符串集合
model.addAttribute("dateList", dashboardService.getDateList());
model.addAttribute("date", date);
model.addAttribute("am", am);
//加载服务器系统版本信息
SystemInfo systemInfo = systemInfoService.selectAllByParams(params).get(0);
//磁盘空间
model.addAttribute("systemInfo", systemInfo);
model.addAttribute("hostname", hostname);
page = deskStateService.selectByParams(params, 1, 1);
if( page.getObjects().size()>0){
model.addAttribute("deskState", page.getObjects().get(0));
}else{
return returnView;
}
//组装cpu占用情况图表字符串
page = cpuStateService.selectByParams(params, 1, HostKeys.CHART_DATA_SIZE);
model.addAttribute("cpu", dashboardService.cpuStateChar(page.getObjects()));
//echart图长度计算
if(page.getObjects().size()>HostKeys.BAR_SIZE){
model.addAttribute("chartWidth", ";width:"+page.getObjects().size()*HostKeys.BAR_WIDTH);
}
//组装内存使用情况图表字符串
page = memStateService.selectByParams(params, 1, HostKeys.CHART_DATA_SIZE);
model.addAttribute("mem", dashboardService.memStateChar(page.getObjects()));
//组装网络设备的吞吐率图表字符串
page = netIoStateService.selectByParams(params, 1, HostKeys.CHART_DATA_SIZE);
model.addAttribute("netio", dashboardService.netIoStateChar(page.getObjects()));
//组装TCP连接状态图表字符串
page = tcpStateService.selectByParams(params, 1, HostKeys.CHART_DATA_SIZE);
model.addAttribute("tcp", dashboardService.tcpStateChar(page.getObjects()));
//组装系统负载状态图表字符串
page = sysLoadStateService.selectByParams(params, 1, HostKeys.CHART_DATA_SIZE);
model.addAttribute("load", dashboardService.loadStateChar(page.getObjects()));
//组装磁盘使用情况图表字符串
page = diskIoStateService.selectByParams(params, 1, HostKeys.CHART_DATA_SIZE);
model.addAttribute("diskio", dashboardService.diskIoStateChar(page.getObjects()));
}
} catch (Exception e) {
logger.error(hostname+"--服务器详细信息异常:",e);
}
return returnView;
}
/**
* 入侵监控列表
* @param model
* @param request
* @return
*/
@RequestMapping(value="intrusionMain")
public String intrusionMain(Model model,HttpServletRequest request) {
AccountInfo accountInfo =(AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
List<IntrusionInfo> intrusionInfoList = null;
Map<String, Object> params = new HashMap<String, Object>();
try {
intrusionInfoList = intrusionInfoService.selectByAccountId(accountInfo.getId());
if(intrusionInfoList.size()>0){
model.addAttribute("date", DateUtil.getDateTimeString(intrusionInfoList.get(0).getCreateTime()));
}
} catch (Exception e) {
logger.error("入侵检测主面板信息异常:",e);
}
model.addAttribute("list", intrusionInfoList);
model.addAttribute("intrusion", StaticKeys.MENU_ACTIVE);
return "intrusion/dashboard";
}
/**
* 根据id查询服务器入侵监控详情信息
* @param model
* @param request
* @return
*/
@RequestMapping(value="intrusionDetail")
public String intrusionDetail(Model model,HttpServletRequest request) {
String id = request.getParameter("id");
AccountInfo accountInfo =(AccountInfo) request.getSession().getAttribute(StaticKeys.LOGIN_KEY);
model.addAttribute("intrusion", StaticKeys.MENU_ACTIVE);
String returnView = "intrusion/dashdetail";
try {
IntrusionInfo info = intrusionInfoService.selectById(id);
if(info!=null){
model.addAttribute("info", info);
}
} catch (Exception e) {
logger.error("--查看服务器入侵监控详情异常:",e);
}
return returnView;
}
}
\ No newline at end of file
package com.controller;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.common.Page;
import com.entity.log.LogInfo;
import com.service.log.LogInfoService;
import com.util.CodeUtil;
import com.util.staticvar.StaticKeys;
/**
*
* @ClassName:LogInfoController.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: LogInfoController.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Controller
@RequestMapping("/sys/log")
public class LogInfoController {
private static final Logger logger = LoggerFactory.getLogger(LogInfoController.class);
private String MENU_MARK = "logActive";//菜单标识
@Resource
private LogInfoService logInfoService;
/**
* 根据条件查询日志信息列表
* @param model
* @param request
* @return
*/
@RequestMapping(value="list")
public String LogInfoList(Model model,HttpServletRequest request) {
String curPage = request.getParameter(StaticKeys.CUR_PAGE);
if(StringUtils.isEmpty(curPage)){
curPage = "1";
}
String account = request.getParameter("account");
Map<String, Object> params = new HashMap<String, Object>();
StringBuffer url = new StringBuffer();
if(!StringUtils.isEmpty(account)) {
account = CodeUtil.unescape(account);
params.put("account", account);
url.append("&account=").append(CodeUtil.escape(account));
model.addAttribute("account", account);
}
Page page = null;
try {
page = logInfoService.selectByParams(params, Integer.valueOf(curPage), StaticKeys.PAGE_SIZE);
model.addAttribute("pageUrl", "/sys/log/list?1=1"+ url.toString());
model.addAttribute("page", page);
} catch (Exception e) {
logger.error("查询出错",e);
}
model.addAttribute(MENU_MARK, StaticKeys.MENU_ACTIVE);
return "log/list";
}
/**
* 查看日志信息
* @param LogInfo
* @param model
* @param request
* @return
*/
@RequestMapping(value="view")
public String viewLogInfo(Model model,HttpServletRequest request) {
model.addAttribute(MENU_MARK, StaticKeys.MENU_ACTIVE);
String id = request.getParameter("id");
LogInfo logInfo;
try {
logInfo = logInfoService.selectById(id);
model.addAttribute("logInfo", logInfo);
} catch (Exception e) {
logger.error("查看日志信息:",e);
}
return "log/view";
}
/**
* 删除
* @param id
* @param model
* @param request
* @param redirectAttributes
* @return
*/
@RequestMapping(value="del")
public String delete(Model model,HttpServletRequest request,RedirectAttributes redirectAttributes) {
Map<String,Object> map = new HashMap<String,Object>();
if(!StringUtils.isEmpty(request.getParameter("id"))){
try {
logInfoService.deleteById(request.getParameter("id").split(","));
} catch (Exception e) {
logger.error("删除日志异常:",e);
}
}
return "redirect:/sys/log/list";
}
}
package com.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.common.AppInit;
import com.entity.user.AccountInfo;
import com.util.shorturl.MD5;
import com.util.staticvar.StaticKeys;
/**
*
* @ClassName:LoginCotroller.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: LoginCotroller.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Controller
@RequestMapping(value="/sys/login")
public class LoginCotroller {
private static final Logger logger = LoggerFactory.getLogger(LoginCotroller.class);
/**
* 转向到登录页面
* @param model
* @param request
* @return
*/
@RequestMapping("toLogin")
public String toLogin(Model model,HttpServletRequest request) {
return "login/login";
}
/**
* 登出系统
* @param model
* @param request
* @return
*/
@RequestMapping("loginOut")
public String loginOut(Model model,HttpServletRequest request){
HttpSession session = request.getSession();
session.invalidate();
return "redirect:/sys/host/toLogin";
}
/**
* 管理员登录验证
* @param model
* @param request
* @return
*/
@RequestMapping(value="login")
public String login(Model model,HttpServletRequest request) {
String userName = request.getParameter("userName");
String passwd = request.getParameter("md5pwd");
String code = request.getParameter(StaticKeys.SESSION_CODE);
HttpSession session = request.getSession();
try {
if(!StringUtils.isEmpty(userName)&&!StringUtils.isEmpty(passwd)&&!StringUtils.isEmpty(code)){
if(!code.equals(session.getAttribute(StaticKeys.SESSION_CODE))){
model.addAttribute("error", "验证码错误");
return "login/login";
}
AccountInfo accountInfo = new AccountInfo();
if(MD5.GetMD5Code(AppInit.admindPwd).equals(passwd)){
accountInfo.setAccount("admin");
accountInfo.setId("admin");
request.getSession().setAttribute(StaticKeys.LOGIN_KEY, accountInfo);
return "redirect:/sys/dash/main";
}
}
} catch (Exception e) {
logger.error("登录异常:",e);
}
model.addAttribute("error", "帐号或者密码错误");
return "login/login";
}
}
\ No newline at end of file
package com.controller;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.common.Page;
import com.entity.msg.MsgInfo;
import com.service.msg.MsgInfoService;
import com.util.CodeUtil;
import com.util.staticvar.StaticKeys;
/**
*
* @ClassName:MsgInfoController.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: MsgInfoController.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Controller
@RequestMapping("/sys/msg")
public class MsgInfoController {
private static final Logger logger = LoggerFactory.getLogger(MsgInfoController.class);
private String MENU_MARK = "msgActive";//菜单标识
@Resource
private MsgInfoService msgInfoService;
/**
* 根据条件查询信息发送记录列表
* @param model
* @param request
* @return
*/
@RequestMapping(value="list")
public String msgInfoList(Model model,HttpServletRequest request) {
String curPage = request.getParameter(StaticKeys.CUR_PAGE);
if(StringUtils.isEmpty(curPage)){
curPage = "1";
}
String account = request.getParameter("account");
String acceptInfo = request.getParameter("acceptInfo");
Map<String, Object> params = new HashMap<String, Object>();
StringBuffer url = new StringBuffer();
if(!StringUtils.isEmpty(account)) {
account = CodeUtil.unescape(account);
params.put("account", account);
url.append("&account=").append(CodeUtil.escape(account));
model.addAttribute("account", account);
}
if(!StringUtils.isEmpty(acceptInfo)) {
acceptInfo = CodeUtil.unescape(acceptInfo);
params.put("acceptInfo", acceptInfo);
url.append("&acceptInfo=").append(CodeUtil.escape(acceptInfo));
model.addAttribute("acceptInfo", acceptInfo);
}
Page page = null;
try {
page = msgInfoService.selectByParams(params, Integer.valueOf(curPage), StaticKeys.PAGE_SIZE);
model.addAttribute("pageUrl", "/sys/msg/list?1=1"+ url.toString());
model.addAttribute("page", page);
} catch (Exception e) {
logger.error("查询出错",e);
}
model.addAttribute(MENU_MARK, StaticKeys.MENU_ACTIVE);
return "msg/list";
}
/**
* 查看信息发送记录
* @param LogInfo
* @param model
* @param request
* @return
*/
@RequestMapping(value="view")
public String viewLogInfo(Model model,HttpServletRequest request) {
model.addAttribute(MENU_MARK, StaticKeys.MENU_ACTIVE);
String id = request.getParameter("id");
MsgInfo logInfo;
try {
logInfo = msgInfoService.selectById(id);
model.addAttribute("msgInfo", logInfo);
} catch (Exception e) {
logger.error("查看信息发送记录:",e);
}
return "msg/view";
}
/**
* 删除
* @param id
* @param model
* @param request
* @param redirectAttributes
* @return
*/
@RequestMapping(value="del")
public String delete(Model model,HttpServletRequest request,RedirectAttributes redirectAttributes) {
if(!StringUtils.isEmpty(request.getParameter("id"))){
try {
msgInfoService.deleteById(request.getParameter("id").split(","));
} catch (Exception e) {
logger.error("删除日志异常:",e);
}
}
return "redirect:/sys/msg/list";
}
}
package com.core.timer.impl;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.common.ApplicationContextHelper;
import com.service.app.AppStateService;
import com.service.host.CpuStateService;
import com.service.host.DiskIoStateService;
import com.service.host.IntrusionInfoService;
import com.service.host.MemStateService;
import com.service.host.NetIoStateService;
import com.service.host.SysLoadStateService;
import com.service.host.TcpStateService;
import com.util.DateUtil;
import com.util.staticvar.BatchData;
/**
*
* @ClassName:BatchCommitJobImpl.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 每5分钟39秒时候批量提交监控数据
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class BatchCommitJobImpl extends TimerTask {
private static final Logger logger = LoggerFactory.getLogger(BatchCommitJobImpl.class);
@Override
public void run() {
timingTask();
}
public void timingTask(){
logger.info("批量提交监控数据任务开始----------"+DateUtil.getCurrentDateTime());
CpuStateService cpuStateService = (CpuStateService)ApplicationContextHelper.getBean(CpuStateService.class);
MemStateService memStateService = (MemStateService)ApplicationContextHelper.getBean(MemStateService.class);
NetIoStateService netIoStateService = (NetIoStateService)ApplicationContextHelper.getBean(NetIoStateService.class);
SysLoadStateService sysLoadStateService = (SysLoadStateService)ApplicationContextHelper.getBean(SysLoadStateService.class);
TcpStateService tcpStateService = (TcpStateService)ApplicationContextHelper.getBean(TcpStateService.class);
AppStateService appStateService = (AppStateService)ApplicationContextHelper.getBean(AppStateService.class);
DiskIoStateService diskIoStateService = (DiskIoStateService)ApplicationContextHelper.getBean(DiskIoStateService.class);
IntrusionInfoService intrusionInfoService = (IntrusionInfoService)ApplicationContextHelper.getBean(IntrusionInfoService.class);
try {
synchronized(BatchData.DISKIO_STATE_LIST) {
if(BatchData.DISKIO_STATE_LIST.size()>0){
diskIoStateService.saveRecord(BatchData.DISKIO_STATE_LIST);
BatchData.DISKIO_STATE_LIST.clear();
}
}
synchronized(BatchData.APP_STATE_LIST) {
if(BatchData.APP_STATE_LIST.size()>0){
appStateService.saveRecord(BatchData.APP_STATE_LIST);
BatchData.APP_STATE_LIST.clear();
}
}
synchronized(BatchData.CPU_STATE_LIST) {
if(BatchData.CPU_STATE_LIST.size()>0){
cpuStateService.saveRecord(BatchData.CPU_STATE_LIST);
BatchData.CPU_STATE_LIST.clear();
}
}
synchronized(BatchData.MEM_STATE_LIST) {
if(BatchData.MEM_STATE_LIST.size()>0){
memStateService.saveRecord(BatchData.MEM_STATE_LIST);
BatchData.MEM_STATE_LIST.clear();
}
}
synchronized(BatchData.NETIO_STATE_LIST) {
if(BatchData.NETIO_STATE_LIST.size()>0){
netIoStateService.saveRecord(BatchData.NETIO_STATE_LIST);
BatchData.NETIO_STATE_LIST.clear();
}
}
synchronized(BatchData.SYSLOAD_STATE_LIST) {
if(BatchData.SYSLOAD_STATE_LIST.size()>0){
sysLoadStateService.saveRecord(BatchData.SYSLOAD_STATE_LIST);
BatchData.SYSLOAD_STATE_LIST.clear();
}
}
synchronized(BatchData.TCP_STATE_LIST) {
if(BatchData.TCP_STATE_LIST.size()>0){
tcpStateService.saveRecord(BatchData.TCP_STATE_LIST);
BatchData.TCP_STATE_LIST.clear();
}
}
synchronized(BatchData.INTRUSION_INFO_LIST) {
if(BatchData.INTRUSION_INFO_LIST.size()>0){
intrusionInfoService.saveRecord(BatchData.INTRUSION_INFO_LIST);
BatchData.INTRUSION_INFO_LIST.clear();
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("批量提交监控数据异常----------",e);
}
logger.info("批量提交监控数据任务结束----------"+DateUtil.getCurrentDateTime());
}
}
package com.core.timer.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.common.ApplicationContextHelper;
import com.dao.app.AppInfoDao;
import com.dao.app.AppStateDao;
import com.dao.host.CpuStateDao;
import com.dao.host.DeskStateDao;
import com.dao.host.DiskIoStateDao;
import com.dao.host.IntrusionInfoDao;
import com.dao.host.MemStateDao;
import com.dao.host.NetIoStateDao;
import com.dao.host.SysLoadStateDao;
import com.dao.host.SystemInfoDao;
import com.dao.host.TcpStateDao;
import com.dao.log.LogInfoDao;
import com.dao.msg.MsgInfoDao;
import com.entity.app.AppInfo;
import com.util.DateUtil;
import com.util.msg.WarnPools;
import com.util.staticvar.StaticKeys;
/**
*
* @ClassName:MonitorDayJobImpl.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 每天1点删除历史信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class MonitorDayJobImpl extends TimerTask {
private static final Logger logger = LoggerFactory.getLogger(MonitorDayJobImpl.class);
@Override
public void run() {
timingTask();
}
public void timingTask(){
logger.info("定时清空历史数据任务开始----------"+DateUtil.getCurrentDateTime());
WarnPools.clearOldData();//清空发告警邮件的记录
String nowTime = DateUtil.getCurrentDateTime();
//3天前时间
String oneDayBefore = DateUtil.getDateBefore(nowTime, 3);
//30天前时间
String sevenDayBefore = DateUtil.getDateBefore(nowTime, 30);
Map<String, Object> params = new HashMap<String,Object>();
Map<String, Object> paramsDel = new HashMap<String,Object>();
SystemInfoDao systemInfoDao = (SystemInfoDao)ApplicationContextHelper.getBean(SystemInfoDao.class);
CpuStateDao cpuStateDao = (CpuStateDao)ApplicationContextHelper.getBean(CpuStateDao.class);
DeskStateDao deskStateDao = (DeskStateDao)ApplicationContextHelper.getBean(DeskStateDao.class);
MemStateDao memStateDao = (MemStateDao)ApplicationContextHelper.getBean(MemStateDao.class);
NetIoStateDao netIoStateDao = (NetIoStateDao)ApplicationContextHelper.getBean(NetIoStateDao.class);
SysLoadStateDao sysLoadStateDao = (SysLoadStateDao)ApplicationContextHelper.getBean(SysLoadStateDao.class);
TcpStateDao tcpStateDao = (TcpStateDao)ApplicationContextHelper.getBean(TcpStateDao.class);
AppInfoDao appInfoDao = (AppInfoDao)ApplicationContextHelper.getBean(AppInfoDao.class);
AppStateDao appStateDao = (AppStateDao)ApplicationContextHelper.getBean(AppStateDao.class);
DiskIoStateDao diskIoStateDao = (DiskIoStateDao)ApplicationContextHelper.getBean(DiskIoStateDao.class);
IntrusionInfoDao intrusionInfoDao = (IntrusionInfoDao)ApplicationContextHelper.getBean(IntrusionInfoDao.class);
List<AppInfo> appInfoList = null;
try {
appInfoList = appInfoDao.selectAllByParams(null);
paramsDel.put(StaticKeys.SEARCH_END_TIME,sevenDayBefore);
//执行删除操作begin
if(paramsDel.get(StaticKeys.SEARCH_END_TIME)!=null&&!"".equals(paramsDel.get(StaticKeys.SEARCH_END_TIME))){
cpuStateDao.deleteByAccountAndDate(paramsDel);//删除cpu监控信息
deskStateDao.deleteByAccountAndDate(paramsDel);//删除磁盘监控信息
memStateDao.deleteByAccountAndDate(paramsDel);//删除内存监控信息
netIoStateDao.deleteByAccountAndDate(paramsDel);//删除吞吐率监控信息
sysLoadStateDao.deleteByAccountAndDate(paramsDel);//删除负载状态监控信息
tcpStateDao.deleteByAccountAndDate(paramsDel);//删除tcp监控信息
diskIoStateDao.deleteByAccountAndDate(paramsDel);//删除磁盘IO监控信息
//删除进程监控信息
if(appInfoList.size()>0){
paramsDel.put("appInfoIds", getAppInfoIdList(appInfoList));
appStateDao.deleteByAppInfoIdsAndDate(paramsDel);
}
//删除3天前服务器系统信息和入侵检测信息
paramsDel.put(StaticKeys.SEARCH_END_TIME,oneDayBefore);
systemInfoDao.deleteByAccountAndDate(paramsDel);
intrusionInfoDao.deleteByAccountAndDate(paramsDel);
}
//执行删除操作end
//删除30天前的日志信息
LogInfoDao logInfoDao = (LogInfoDao)ApplicationContextHelper.getBean(LogInfoDao.class);
String thrityDayBefore = DateUtil.getDateBefore(nowTime, 30);
paramsDel.put(StaticKeys.SEARCH_END_TIME,thrityDayBefore);
logInfoDao.deleteByDate(paramsDel);
//删除30天前的信息发送记录
MsgInfoDao msgInfoDao = (MsgInfoDao)ApplicationContextHelper.getBean(MsgInfoDao.class);
msgInfoDao.deleteByDate(paramsDel);
} catch (Exception e) {
logger.info("定时清空历史数据任务出错:",e);
}
logger.info("定时清空历史数据任务结束----------"+DateUtil.getCurrentDateTime());
}
/**
* 取出AppInfo集合中的id
* @param list
* @return
*/
private List<String> getAppInfoIdList(List<AppInfo> list){
List<String> idList = new ArrayList<String>();
for(AppInfo info : list){
idList.add(info.getId());
}
return idList;
}
}
package com.dao.app;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.app.AppInfo;
/**
*
* @ClassName:AppInfoDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: AppInfoDao.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface AppInfoDao{
public List<AppInfo> selectAllByParams(Map<String,Object> map) throws Exception;
public List<AppInfo> selectByParams(Map<String,Object> params) throws Exception;
public AppInfo selectById(String id) throws Exception;
public List<AppInfo> selectByAccountId(String accountId) throws Exception;
public void save(AppInfo AppInfo) throws Exception;
public int deleteById(String[] id) throws Exception;
public AppInfo updateById(AppInfo AppInfo) throws Exception;
}
package com.dao.app;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.app.AppState;
/**
*
* @ClassName:AppStateDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: AppStateDao.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface AppStateDao {
public List<AppState> selectAllByParams(Map<String,Object> map) throws Exception;
public List<AppState> selectByParams(Map<String,Object> params) throws Exception;
public AppState selectById(String id) throws Exception;
public int selectByParamsCount(Map<String,Object> map);
public void save(AppState AppState) throws Exception;
public void saveRecord(List<AppState> recordList) throws Exception;
public int deleteByAppInfoId(String appInfoId) throws Exception;
public int deleteByAppInfoIdsAndDate(Map<String,Object> map) throws Exception;
public int deleteById(String[] id) throws Exception;
}
package com.dao.host;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.host.CpuState;
/**
*
* @ClassName:CpuStateDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: CpuStateDao.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface CpuStateDao{
public List<CpuState> selectAllByParams(Map<String,Object> map) throws Exception ;
public List<CpuState> selectByParams(Map<String,Object> params) throws Exception;
public CpuState selectById(String id) throws Exception;
public int selectByParamsCount(Map<String,Object> map);
public void save(CpuState CpuState) throws Exception;
public void insertList(List<CpuState> recordList) throws Exception;
public int deleteByAccountAndDate(Map<String,Object> map) throws Exception;
public int deleteById(String[] id) throws Exception;
}
package com.dao.host;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.host.DeskState;
/**
*
* @ClassName:DeskStateDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看磁盘大小使用信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface DeskStateDao{
public List<DeskState> selectAllByParams(Map<String,Object> map) throws Exception;
public List<DeskState> selectByParams(Map<String,Object> params) throws Exception;
public DeskState selectById(String id) throws Exception;
public void save(DeskState DeskState) throws Exception;
public int deleteByAccountAndDate(Map<String,Object> map) throws Exception;
public int deleteById(String[] id) throws Exception;
public int deleteByAccHname(Map<String,Object> map) throws Exception;
}
package com.dao.host;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.host.DiskIoState;
/**
*
* @ClassName:DiskIoStateDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看磁盘IO使用情况
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface DiskIoStateDao{
public List<DiskIoState> selectAllByParams(Map<String,Object> map) throws Exception;
public List<DiskIoState> selectByParams(Map<String,Object> params) throws Exception;
public DiskIoState selectById(String id) throws Exception;
public void save(DiskIoState DiskIoState) throws Exception;
public void insertList(List<DiskIoState> recordList) throws Exception;
public int deleteByAccountAndDate(Map<String,Object> map) throws Exception;
public int deleteById(String[] id) throws Exception;
}
package com.dao.host;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.host.IntrusionInfo;
/**
*
* @ClassName:IntrusionInfoDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看系统入侵信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface IntrusionInfoDao {
public List<IntrusionInfo> selectAllByParams(Map<String,Object> map) throws Exception ;
public List<IntrusionInfo> selectByAccountId(String accountId) throws Exception ;
public List<IntrusionInfo> selectByParams(Map<String,Object> params) throws Exception;
public IntrusionInfo selectById(String id) throws Exception;
public void save(IntrusionInfo IntrusionInfo) throws Exception;
public void insertList(List<IntrusionInfo> recordList) throws Exception;
public int deleteById(String[] id) throws Exception;
public int deleteByAccountAndDate(Map<String,Object> map) throws Exception;
public int deleteByAccHname(Map<String,Object> map) throws Exception;
}
package com.dao.host;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.common.Page;
import com.entity.host.DeskState;
import com.entity.host.MemState;
/**
*
* @ClassName:MemStateDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看内存使用情况
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface MemStateDao {
public List<MemState> selectAllByParams(Map<String,Object> map) throws Exception ;
public List<MemState> selectByParams(Map<String,Object> params) throws Exception;
public MemState selectById(String id) throws Exception;
public void save(MemState MemState) throws Exception;
public void insertList(List<MemState> recordList) throws Exception;
public int deleteByAccountAndDate(Map<String,Object> map) throws Exception;
public int deleteById(String[] id) throws Exception;
}
package com.dao.host;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.host.NetIoState;
/**
*
* @ClassName:NetIoStateDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看网络设备的吞吐率
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface NetIoStateDao{
public List<NetIoState> selectAllByParams(Map<String,Object> map) throws Exception;
public List<NetIoState> selectByParams(Map<String,Object> params) ;
public NetIoState selectById(String id) throws Exception;
public void save(NetIoState NetIoState) throws Exception;
public void insertList(List<NetIoState> recordList) throws Exception;
public int deleteByAccountAndDate(Map<String,Object> map) throws Exception;
public int deleteById(String[] id) throws Exception;
}
package com.dao.host;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.host.SysLoadState;
/**
*
* @ClassName:SysLoadStateDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看uptime查看系统负载状态
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface SysLoadStateDao {
public List<SysLoadState> selectAllByParams(Map<String,Object> map) throws Exception;
public List<SysLoadState> selectByParams(Map<String,Object> params) throws Exception;
public SysLoadState selectById(String id) throws Exception;
public void save(SysLoadState SysLoadState) throws Exception;
public void insertList(List<SysLoadState> recordList) throws Exception;
public int deleteByAccountAndDate(Map<String,Object> map) throws Exception;
public int deleteById(String[] id) throws Exception;
}
package com.dao.host;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.host.SystemInfo;
/**
*
* @ClassName:SystemInfoDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看系统信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface SystemInfoDao {
public List<SystemInfo> selectAllByParams(Map<String,Object> map) throws Exception ;
public List<SystemInfo> selectByAccountId(String accountId) throws Exception ;
public List<SystemInfo> selectByParams(Map<String,Object> params);
public SystemInfo selectById(String id) throws Exception;
public void save(SystemInfo SystemInfo) throws Exception;
public int deleteById(String[] id) throws Exception;
public int deleteByAccountAndDate(Map<String,Object> map) throws Exception;
public int deleteByAccHname(Map<String,Object> map) throws Exception;
}
package com.dao.host;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.host.TcpState;
/**
*
* @ClassName:TcpStateDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看TCP连接状态
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface TcpStateDao {
public List<TcpState> selectAllByParams(Map<String,Object> map) throws Exception;
public List<TcpState> selectByParams(Map<String,Object> params) throws Exception;
public TcpState selectById(String id) throws Exception;
public void save(TcpState TcpState) throws Exception;
public void insertList(List<TcpState> recordList) throws Exception;
public int deleteByAccountAndDate(Map<String,Object> map) throws Exception;
public int deleteById(String[] id) throws Exception;
}
package com.dao.log;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.log.LogInfo;
/**
*
* @ClassName:LogInfoDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看日志信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface LogInfoDao{
public List<LogInfo> selectAllByParams(Map<String,Object> map);
public List<LogInfo> selectByParams(Map<String,Object> params) throws Exception;
public LogInfo selectById(String id) throws Exception;
public void save(LogInfo LogInfo) throws Exception;
public int deleteById(String[] id) throws Exception;
public int deleteByDate(Map<String,Object> map) throws Exception;
}
package com.dao.msg;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.msg.MsgInfo;
/**
*
* @ClassName:MsgInfoDao.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 信息发送记录
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
@Repository
public interface MsgInfoDao {
public List<MsgInfo> selectAllByParams(Map<String,Object> map) throws Exception ;
public List<MsgInfo> selectByParams(Map<String,Object> params) throws Exception;
public MsgInfo selectById(String id) throws Exception;
public void save(MsgInfo MsgInfo) throws Exception;
public int deleteById(String[] id) throws Exception;
public int deleteByDate(Map<String,Object> map) throws Exception;
}
package com.entity.app;
import java.io.Serializable;
import java.util.Date;
/**
*
* @ClassName:AppInfo.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: app端口信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class AppInfo implements Serializable{
/**
*
*/
private static final long serialVersionUID = -2913111613773445949L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 应用进程ID
*/
private String appPid;
/**
* 应用进程名称
*/
private String appName;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getAppPid() {
return appPid;
}
public void setAppPid(String appPid) {
this.appPid = appPid;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
}
\ No newline at end of file
package com.entity.app;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import com.util.DateUtil;
/**
*
* @ClassName:AppState.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: app状态监控
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class AppState implements Serializable{
/**
*
*/
private static final long serialVersionUID = -2913111613773445949L;
/**
* 主键
*/
private String id;
/**
* 应用信息ID
*/
private String appInfoId;
/**
* %CPU
*/
private String cpuPer;
/**
* %MEM
*/
private String memPer;
/**
* 添加时间
* MM-dd hh:mm:ss
*/
private String dateStr;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getCpuPer() {
return cpuPer;
}
public void setCpuPer(String cpuPer) {
this.cpuPer = cpuPer;
}
public String getAppInfoId() {
return appInfoId;
}
public void setAppInfoId(String appInfoId) {
this.appInfoId = appInfoId;
}
public String getMemPer() {
return memPer;
}
public void setMemPer(String memPer) {
this.memPer = memPer;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDateStr() {
String str = DateUtil.getDateTimeString(createTime);
if(!StringUtils.isEmpty(str)&&str.length()>16){
return str.substring(5);
}
return dateStr;
}
public void setDateStr(String dateStr) {
this.dateStr = dateStr;
}
}
\ No newline at end of file
package com.entity.dash;
import java.io.Serializable;
/**
*
* @ClassName:DashboardView.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 主面板概要信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class DashboardView implements Serializable{
/**
*
*/
private static final long serialVersionUID = -1262528746414406709L;
/**
* 主键
*/
private String id;
/**
* host名称
*/
private String hostname;
/**
*系统版本信息
*/
private String version;
/**
*系统已经运行了多少天
*/
private String yxDays;
/**
* 内存已使用百分比
*/
private double memPer;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getYxDays() {
return yxDays;
}
public void setYxDays(String yxDays) {
this.yxDays = yxDays;
}
public double getMemPer() {
return memPer;
}
public void setMemPer(double memPer) {
this.memPer = memPer;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
/**
*
* @ClassName:CpuState.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看CPU使用情况
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class CpuState implements Serializable{
/**
*
*/
private static final long serialVersionUID = -2913111613773445949L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 用户态的CPU时间(%)
*/
private String user;
/**
* 系统(内核)时间(%)
*/
private String sys;
/**
* 空闲时间(idle)(%)
*/
private String idle;
/**
* IO等待时间(wait)(%)
*/
private String iowait;
/**
* 硬中断时间(%)
*/
private String irq;
/**
* 软中断时间(%)
*/
private String soft;
/**
* 添加时间
* MM-dd hh:mm:ss
*/
private String dateStr;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getSys() {
return sys;
}
public void setSys(String sys) {
this.sys = sys;
}
public String getIdle() {
return idle;
}
public void setIdle(String idle) {
this.idle = idle;
}
public String getIowait() {
return iowait;
}
public void setIowait(String iowait) {
this.iowait = iowait;
}
public String getIrq() {
return irq;
}
public void setIrq(String irq) {
this.irq = irq;
}
public String getSoft() {
return soft;
}
public void setSoft(String soft) {
this.soft = soft;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDateStr() {
if(!StringUtils.isEmpty(dateStr)&&dateStr.length()>16){
return dateStr.substring(5);
}
return dateStr;
}
public void setDateStr(String dateStr) {
this.dateStr = dateStr;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
/**
*
* @ClassName:DeskState.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看磁盘大小使用信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class DeskState implements Serializable{
/**
*
*/
private static final long serialVersionUID = 879979812204191283L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 磁盘分区
*/
private String fileSystem;
/**
*分区大小
*/
private String size;
/**
* 已使用
*/
private String used;
/**
* 未使用
*/
private String avail;
/**
* 已使用百分比
*/
private String usePer;
/**
* 添加时间
* yyyy-MM-dd hh:mm:ss
*/
private String dateStr;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getFileSystem() {
return fileSystem;
}
public void setFileSystem(String fileSystem) {
this.fileSystem = fileSystem;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getUsed() {
return used;
}
public void setUsed(String used) {
this.used = used;
}
public String getAvail() {
return avail;
}
public void setAvail(String avail) {
this.avail = avail;
}
public String getUsePer() {
return usePer;
}
public void setUsePer(String usePer) {
this.usePer = usePer;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDateStr() {
if(!StringUtils.isEmpty(dateStr)&&dateStr.length()>16){
return dateStr.substring(5);
}
return dateStr;
}
public void setDateStr(String dateStr) {
this.dateStr = dateStr;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
/**
*
* @ClassName:DiskIoState.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看磁盘IO使用情况
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class DiskIoState implements Serializable{
/**
*
*/
private static final long serialVersionUID = -8284741180883299533L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 每秒读次数
*/
private String rs;
/**
* 每秒写次数
*/
private String ws;
/**
*每秒读数据量(千字节)
*/
private String rkBS;
/**
* 每秒写数据量(千字节)
*/
private String wkBS;
/**
* IO操作的平均等待时间,单位是毫秒。这是应用程序在和磁盘交互时,需要消耗的时间,包括IO等待和实际操作的耗时。如果这个数值过大,可能是硬件设备遇到了瓶颈或者出现故障
*/
private String await;
/**
* 向设备发出的请求平均数量。如果这个数值大于1,可能是硬件设备已经饱和(部分前端硬件设备支持并行写入)
*/
private String avgquSz;
/**
* 设备利用率。这个数值表示设备的繁忙程度,经验值是如果超过60,可能会影响IO性能(可以参照IO操作平均等待时间)。如果到达100%,说明硬件设备已经饱和
*/
private String util;
/**
* 添加时间
* MM-dd hh:mm:ss
*/
private String dateStr;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDateStr() {
if(!StringUtils.isEmpty(dateStr)&&dateStr.length()>16){
return dateStr.substring(5);
}
return dateStr;
}
public void setDateStr(String dateStr) {
this.dateStr = dateStr;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public String getRs() {
return rs;
}
public void setRs(String rs) {
this.rs = rs;
}
public String getWs() {
return ws;
}
public void setWs(String ws) {
this.ws = ws;
}
public String getRkBS() {
return rkBS;
}
public void setRkBS(String rkBS) {
this.rkBS = rkBS;
}
public String getWkBS() {
return wkBS;
}
public void setWkBS(String wkBS) {
this.wkBS = wkBS;
}
public String getAwait() {
return await;
}
public void setAwait(String await) {
this.await = await;
}
public String getAvgquSz() {
return avgquSz;
}
public void setAvgquSz(String avgquSz) {
this.avgquSz = avgquSz;
}
public String getUtil() {
return util;
}
public void setUtil(String util) {
this.util = util;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.util.Date;
/**
*
* @ClassName:HostInfo.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: host的IP密码等信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class HostInfo implements Serializable{
/**
*
*/
private static final long serialVersionUID = 3875927332935900938L;
/**
* 主键
*/
private String id;
/**
* host名称
*/
private String hostname;
/**
* 用户
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.sql.Timestamp;
/**
*
* @ClassName:IntrusionInfo.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 检查系统入侵信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class IntrusionInfo implements Serializable{
/**
*
*/
private static final long serialVersionUID = 879979812204191283L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 系统内核模块
*/
private String lsmod;
/**
*查看passwd文件修改时间
*/
private String passwdInfo;
/**
* 查看系统计划任务
*/
private String crontab;
/**
* 检查网络,正常网卡不该在promisc模式,可能存在sniffer
*/
private String promisc;
/**
* 系统rpc服务
*/
private String rpcinfo;
/**
* 创建时间
*/
private Timestamp createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public Timestamp getCreateTime() {
return createTime;
}
public void setCreateTime(Timestamp createTime) {
this.createTime = createTime;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public String getLsmod() {
return lsmod;
}
public void setLsmod(String lsmod) {
this.lsmod = lsmod;
}
public String getPasswdInfo() {
return passwdInfo;
}
public void setPasswdInfo(String passwdInfo) {
this.passwdInfo = passwdInfo;
}
public String getCrontab() {
return crontab;
}
public void setCrontab(String crontab) {
this.crontab = crontab;
}
public String getPromisc() {
return promisc;
}
public void setPromisc(String promisc) {
this.promisc = promisc;
}
public String getRpcinfo() {
return rpcinfo;
}
public void setRpcinfo(String rpcinfo) {
this.rpcinfo = rpcinfo;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
/**
*
* @ClassName:MemState.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看内存使用情况
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class MemState implements Serializable{
/**
*
*/
private static final long serialVersionUID = -1412473355088780549L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 总计内存,M
*/
private String total;
/**
*已使用多少,M
*/
private String used;
/**
* 未使用,M
*/
private String free;
/**
* 已使用百分比%
*/
private String usePer;
/**
* 添加时间
* yyyy-MM-dd hh:mm:ss
*/
private String dateStr;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getTotal() {
return total;
}
public void setTotal(String total) {
this.total = total;
}
public String getUsed() {
return used;
}
public void setUsed(String used) {
this.used = used;
}
public String getFree() {
return free;
}
public void setFree(String free) {
this.free = free;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDateStr() {
if(!StringUtils.isEmpty(dateStr)&&dateStr.length()>16){
return dateStr.substring(5);
}
return dateStr;
}
public void setDateStr(String dateStr) {
this.dateStr = dateStr;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public String getUsePer() {
return usePer;
}
public void setUsePer(String usePer) {
this.usePer = usePer;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
/**
*
* @ClassName:NetIoState.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 网络设备的吞吐率
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class NetIoState implements Serializable{
/**
*
*/
private static final long serialVersionUID = -8314012397341825158L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 每秒钟接收的数据包,rxpck/s
*/
private String rxpck;
/**
* 每秒钟发送的数据包,txpck/s
*/
private String txpck;
/**
* 每秒钟接收的KB数,rxkB/s
*/
private String rxbyt;
/**
* 每秒钟发送的KB数,txkB/s
*/
private String txbyt;
/**
* 每秒钟接收的压缩数据包,rxcmp/s
*/
private String rxcmp;
/**
* 每秒钟发送的压缩数据包,txcmp/s
*/
private String txcmp;
/**
* 每秒钟接收的多播数据包,rxmcst/s
*/
private String rxmcst;
/**
* 添加时间
* yyyy-MM-dd hh:mm:ss
*/
private String dateStr;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getRxpck() {
return rxpck;
}
public void setRxpck(String rxpck) {
this.rxpck = rxpck;
}
public String getTxpck() {
return txpck;
}
public void setTxpck(String txpck) {
this.txpck = txpck;
}
public String getRxbyt() {
return rxbyt;
}
public void setRxbyt(String rxbyt) {
this.rxbyt = rxbyt;
}
public String getTxbyt() {
return txbyt;
}
public void setTxbyt(String txbyt) {
this.txbyt = txbyt;
}
public String getRxcmp() {
return rxcmp;
}
public void setRxcmp(String rxcmp) {
this.rxcmp = rxcmp;
}
public String getTxcmp() {
return txcmp;
}
public void setTxcmp(String txcmp) {
this.txcmp = txcmp;
}
public String getRxmcst() {
return rxmcst;
}
public void setRxmcst(String rxmcst) {
this.rxmcst = rxmcst;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDateStr() {
if(!StringUtils.isEmpty(dateStr)&&dateStr.length()>16){
return dateStr.substring(5);
}
return dateStr;
}
public void setDateStr(String dateStr) {
this.dateStr = dateStr;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
/**
*
* @ClassName:SysLoadState.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: uptime查看系统负载状态
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class SysLoadState implements Serializable{
/**
*
*/
private static final long serialVersionUID = -4863071148000213553L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 1分钟之前到现在的负载
*/
private String oneLoad;
/**
*5分钟之前到现在的负载
*/
private String fiveLoad;
/**
*15分钟之前到现在的负载
*/
private String fifteenLoad;
/**
* 登录用户数量
*/
private String users;
/**
* 添加时间
* yyyy-MM-dd hh:mm:ss
*/
private String dateStr;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getOneLoad() {
return oneLoad;
}
public void setOneLoad(String oneLoad) {
this.oneLoad = oneLoad;
}
public String getFiveLoad() {
return fiveLoad;
}
public void setFiveLoad(String fiveLoad) {
this.fiveLoad = fiveLoad;
}
public String getFifteenLoad() {
return fifteenLoad;
}
public void setFifteenLoad(String fifteenLoad) {
this.fifteenLoad = fifteenLoad;
}
public String getUsers() {
return users;
}
public void setUsers(String users) {
this.users = users;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDateStr() {
if(!StringUtils.isEmpty(dateStr)&&dateStr.length()>16){
return dateStr.substring(5);
}
return dateStr;
}
public void setDateStr(String dateStr) {
this.dateStr = dateStr;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.sql.Timestamp;
/**
*
* @ClassName:SystemInfo.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看系统信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class SystemInfo implements Serializable{
/**
*
*/
private static final long serialVersionUID = 879979812204191283L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 系统版本信息
*/
private String version;
/**
*系统版本详细信息
*/
private String versionDetail;
/**
* 物理CPU个数
*/
private String cpuNum;
/**
* 每个物理CPU中core的个数(即核数)
*/
private String cpuCoreNum;
/**
* 系统已经运行了多少天
*/
private String yxDays;
/**
* CPU型号信息
*/
private String cpuXh;
/**
* 创建时间
*/
private Timestamp createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getVersionDetail() {
return versionDetail;
}
public void setVersionDetail(String versionDetail) {
this.versionDetail = versionDetail;
}
public String getCpuNum() {
return cpuNum;
}
public void setCpuNum(String cpuNum) {
this.cpuNum = cpuNum;
}
public String getCpuCoreNum() {
return cpuCoreNum;
}
public void setCpuCoreNum(String cpuCoreNum) {
this.cpuCoreNum = cpuCoreNum;
}
public String getYxDays() {
return yxDays;
}
public void setYxDays(String yxDays) {
this.yxDays = yxDays;
}
public Timestamp getCreateTime() {
return createTime;
}
public void setCreateTime(Timestamp createTime) {
this.createTime = createTime;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public String getCpuXh() {
return cpuXh;
}
public void setCpuXh(String cpuXh) {
this.cpuXh = cpuXh;
}
}
\ No newline at end of file
package com.entity.host;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
/**
*
* @ClassName:TcpState.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 查看TCP连接状态
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class TcpState implements Serializable{
/**
*
*/
private static final long serialVersionUID = -299667815095138020L;
/**
* 主键
*/
private String id;
/**
* 用户id
*/
private String accountId;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 每秒本地发起的TCP连接数,既通过connect调用创建的TCP连接;,active/s
*/
private String active;
/**
* 每秒远程发起的TCP连接数,即通过accept调用创建的TCP连接,passive/s
*/
private String passive;
/**
* 每秒TCP重传数量,retrans/s
*/
private String retrans;
/**
* 添加时间
* yyyy-MM-dd hh:mm:ss
*/
private String dateStr;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getActive() {
return active;
}
public void setActive(String active) {
this.active = active;
}
public String getPassive() {
return passive;
}
public void setPassive(String passive) {
this.passive = passive;
}
public String getRetrans() {
return retrans;
}
public void setRetrans(String retrans) {
this.retrans = retrans;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDateStr() {
if(!StringUtils.isEmpty(dateStr)&&dateStr.length()>16){
return dateStr.substring(5);
}
return dateStr;
}
public void setDateStr(String dateStr) {
this.dateStr = dateStr;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
}
\ No newline at end of file
package com.entity.log;
import java.io.Serializable;
import java.util.Date;
/**
*
* @ClassName:LogInfo.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: 日志信息
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class LogInfo implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1565538727002722890L;
/**
* 主键
*/
private String id;
/**
* 用户帐号
*/
private String account;
/**
* host名称
*/
private String hostname;
/**
* 描述
*/
private String infoContent;
/**
* 0成功,1失败
*/
private String state;
/**
* 创建时间
*/
private Date createTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public String getInfoContent() {
return infoContent;
}
public void setInfoContent(String infoContent) {
this.infoContent = infoContent;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
package com.util;
import java.util.Random;
import java.util.UUID;
/**
*
* @ClassName:UUIDUtil.java
* @version V1.0
* @author: wgcloud
* @date: 2019年1月14日
* @Description: UUIDUtil.java
* @Copyright: 2019 wgcloud. All rights reserved.
*
*/
public class UUIDUtil {
public static String getUUID(){
return String.valueOf(UUID.randomUUID()).replace("-", "");
}
/**
* 随机6位数字
* @return
*/
public static String getRandomSix(){
return ""+new Random().nextInt(999999);
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册