修改页面弹窗全屏
This commit is contained in:
@@ -46,7 +46,7 @@ public class hostJob {
|
||||
private static final double DISK_RATE = Double.parseDouble(Global.getConfig("biz.host.Disk", "60"));
|
||||
private static final LoggerUtils logger = LoggerUtils.getInstance();
|
||||
|
||||
@Scheduled(cron = "0 0/15 * * * ?")
|
||||
@Scheduled(cron = "0 0/10 * * * ?")
|
||||
public void initJob() {
|
||||
try {
|
||||
HostStatus();
|
||||
@@ -88,68 +88,61 @@ public class hostJob {
|
||||
* 运行信息更新
|
||||
*/
|
||||
public void syncServerInfo(BizMonitorHost host) {
|
||||
if (host.getIsAuth().equals("1")) {
|
||||
DockerUtils dockerUtils = new DockerUtils(host.getIpAddress(), host.getCheckTargetPort());
|
||||
List<Container> containerList = dockerUtils.listContainers(true);
|
||||
host.setRunTargetNums(containerList.size());
|
||||
monitorHostService.save(host);
|
||||
BizMonitorAccount monitorAccount = new BizMonitorAccount();
|
||||
monitorAccount.setHostId(host.getHostId());
|
||||
monitorAccount.setUstatus("1");
|
||||
monitorAccount.setSshUsername("ogsapp");
|
||||
List<BizMonitorAccount> accountList = accountService.findList(monitorAccount);
|
||||
if (accountList.size() > 0) {
|
||||
try {
|
||||
BizMonitorAccount account = accountList.get(0);
|
||||
Session session = SystemUtil.getSshSession(account);
|
||||
if (session.isConnected()) {
|
||||
CpuInfo cpuInfo = SystemUtil.getCpuMemUsage(session);
|
||||
ServerInfo info = SystemUtil.getServerBasicInfo(session);
|
||||
List<DiskInfo> diskInfos = SystemUtil.getDiskInfos(session);
|
||||
syncDeviceInfo(host, diskInfos);
|
||||
BizServerInfo bizServerInfo = new BizServerInfo();
|
||||
bizServerInfo.setHostId(host.getHostId());
|
||||
// 新增主机监控
|
||||
BizResourceMonitor resourceMonitor = new BizResourceMonitor();
|
||||
resourceMonitor.setHostName(host.getHostname());
|
||||
resourceMonitor.setCpuUsage(cpuInfo.getCpuUsage());
|
||||
resourceMonitor.setMemoryUsage(cpuInfo.getMemoryUsage());
|
||||
resourceMonitor.setMemoryTotal(info.getMemoryTotal());
|
||||
resourceMonitor.setHostId(host.getHostId());
|
||||
resourceMonitorService.save(resourceMonitor);
|
||||
// 更新主机监控
|
||||
List<BizServerInfo> serverInfoList = serverInfoService.findList(bizServerInfo);
|
||||
BizServerInfo serverInfo = serverInfoList.isEmpty() ? new BizServerInfo() : serverInfoList.get(0);
|
||||
serverInfo.setUptime(info.getUptime());
|
||||
serverInfo.setOs(info.getOs());
|
||||
serverInfo.setKernelVersion(info.getKernelVersion());
|
||||
serverInfo.setHostname(info.getHostname());
|
||||
serverInfo.setIpAddress(info.getIpAddress());
|
||||
serverInfo.setCpuModel(info.getCpuModel());
|
||||
serverInfo.setMemoryTotal(info.getMemoryTotal());
|
||||
serverInfo.setCpuUsage(cpuInfo.getCpuUsage());
|
||||
serverInfo.setMemoryUsage(cpuInfo.getMemoryUsage());
|
||||
serverInfo.setLastOnlineTime(new Date());
|
||||
serverInfo.setHostId(host.getHostId());
|
||||
serverInfoService.save(serverInfo);
|
||||
if (serverInfo.getCpuUsage() >= CPU_RATE) {
|
||||
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "CPU预警", 2, host.getHostname() + "CPU预警", "当前主机CPU已超过" + CPU_RATE + "%,请及时处理,主机IP:" + host.getIpAddress(), "业务系统", "0");
|
||||
bizWarningAlertService.save(warningAlert);
|
||||
}
|
||||
if (serverInfo.getMemoryUsage() >= MEM_RATE) {
|
||||
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "内存预警", 2, host.getHostname() + "内存预警", "当前主机内存已超过" + MEM_RATE + "%,请及时处理,主机IP:" + host.getIpAddress(), "业务系统", "0");
|
||||
bizWarningAlertService.save(warningAlert);
|
||||
}
|
||||
SystemUtil.closeSession(session);
|
||||
BizMonitorAccount monitorAccount = new BizMonitorAccount();
|
||||
monitorAccount.setHostId(host.getHostId());
|
||||
monitorAccount.setUstatus("1");
|
||||
monitorAccount.setSshUsername("ogsapp");
|
||||
List<BizMonitorAccount> accountList = accountService.findList(monitorAccount);
|
||||
if (accountList.size() > 0) {
|
||||
try {
|
||||
BizMonitorAccount account = accountList.get(0);
|
||||
Session session = SystemUtil.getSshSession(account);
|
||||
if (session.isConnected()) {
|
||||
CpuInfo cpuInfo = SystemUtil.getCpuMemUsage(session);
|
||||
ServerInfo info = SystemUtil.getServerBasicInfo(session);
|
||||
List<DiskInfo> diskInfos = SystemUtil.getDiskInfos(session);
|
||||
syncDeviceInfo(host, diskInfos);
|
||||
BizServerInfo bizServerInfo = new BizServerInfo();
|
||||
bizServerInfo.setHostId(host.getHostId());
|
||||
// 新增主机监控
|
||||
BizResourceMonitor resourceMonitor = new BizResourceMonitor();
|
||||
resourceMonitor.setHostName(host.getHostname());
|
||||
resourceMonitor.setCpuUsage(cpuInfo.getCpuUsage());
|
||||
resourceMonitor.setMemoryUsage(cpuInfo.getMemoryUsage());
|
||||
resourceMonitor.setMemoryTotal(info.getMemoryTotal());
|
||||
resourceMonitor.setHostId(host.getHostId());
|
||||
resourceMonitorService.save(resourceMonitor);
|
||||
// 更新主机监控
|
||||
List<BizServerInfo> serverInfoList = serverInfoService.findList(bizServerInfo);
|
||||
BizServerInfo serverInfo = serverInfoList.isEmpty() ? new BizServerInfo() : serverInfoList.get(0);
|
||||
serverInfo.setUptime(info.getUptime());
|
||||
serverInfo.setOs(info.getOs());
|
||||
serverInfo.setKernelVersion(info.getKernelVersion());
|
||||
serverInfo.setHostname(info.getHostname());
|
||||
serverInfo.setIpAddress(info.getIpAddress());
|
||||
serverInfo.setCpuModel(info.getCpuModel());
|
||||
serverInfo.setMemoryTotal(info.getMemoryTotal());
|
||||
serverInfo.setCpuUsage(cpuInfo.getCpuUsage());
|
||||
serverInfo.setMemoryUsage(cpuInfo.getMemoryUsage());
|
||||
serverInfo.setLastOnlineTime(new Date());
|
||||
serverInfo.setHostId(host.getHostId());
|
||||
serverInfoService.save(serverInfo);
|
||||
if (serverInfo.getCpuUsage() >= CPU_RATE) {
|
||||
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "CPU预警", 2, host.getHostname() + "CPU预警", "当前主机CPU已超过" + CPU_RATE + "%,请及时处理,主机IP:" + host.getIpAddress(), "业务系统", "0");
|
||||
bizWarningAlertService.save(warningAlert);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), host);
|
||||
if (serverInfo.getMemoryUsage() >= MEM_RATE) {
|
||||
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "内存预警", 2, host.getHostname() + "内存预警", "当前主机内存已超过" + MEM_RATE + "%,请及时处理,主机IP:" + host.getIpAddress(), "业务系统", "0");
|
||||
bizWarningAlertService.save(warningAlert);
|
||||
}
|
||||
SystemUtil.closeSession(session);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), host);
|
||||
}
|
||||
if (host.getCheckTargetNums() != containerList.size()) {
|
||||
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "容器预警", 2, host.getHostname() + "容器预警", "当前主机容器运行数量" + containerList.size() + "与配置数量不一致,请及时处理,主机IP:" + host.getIpAddress(), "业务系统", "0");
|
||||
bizWarningAlertService.save(warningAlert);
|
||||
}
|
||||
}
|
||||
if (host.getIsAuth().equals("1")) {
|
||||
syncDockerInfo(host);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,4 +175,15 @@ public class hostJob {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void syncDockerInfo(BizMonitorHost host) {
|
||||
DockerUtils dockerUtils = new DockerUtils(host.getIpAddress(), host.getCheckTargetPort());
|
||||
List<Container> containerList = dockerUtils.listContainers(true);
|
||||
host.setRunTargetNums(containerList.size());
|
||||
monitorHostService.save(host);
|
||||
if (host.getCheckTargetNums() != containerList.size()) {
|
||||
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "容器预警", 2, host.getHostname() + "容器预警", "当前主机容器运行数量" + containerList.size() + "与配置数量不一致,请及时处理,主机IP:" + host.getIpAddress(), "业务系统", "0");
|
||||
bizWarningAlertService.save(warningAlert);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user