mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 11:58:01 +08:00
Merge remote-tracking branch 'gitee/dev' into dev
This commit is contained in:
commit
badec76246
@ -52,8 +52,9 @@ public class WelcomeController extends BaseController {
|
|||||||
JSONArray array = null;
|
JSONArray array = null;
|
||||||
try {
|
try {
|
||||||
if (AbstractCommander.OS_INFO.isLinux()) {
|
if (AbstractCommander.OS_INFO.isLinux()) {
|
||||||
String head = AbstractCommander.getInstance().execSystemCommand("top -b -n 1 | head -7");
|
AbstractCommander instance = AbstractCommander.getInstance();
|
||||||
String s = AbstractCommander.getInstance().execSystemCommand("top -b -n 1 | grep java | head -10");
|
String head = instance.execSystemCommand("top -b -n 1 | head -7");
|
||||||
|
String s = instance.execSystemCommand("top -b -n 1 | grep java");
|
||||||
array = TopManager.formatLinuxTop(head + s);
|
array = TopManager.formatLinuxTop(head + s);
|
||||||
} else {
|
} else {
|
||||||
String s = AbstractCommander.getInstance().execSystemCommand("tasklist /V | findstr java");
|
String s = AbstractCommander.getInstance().execSystemCommand("tasklist /V | findstr java");
|
||||||
|
@ -7,6 +7,7 @@ import cn.hutool.cron.CronUtil;
|
|||||||
import cn.hutool.cron.Scheduler;
|
import cn.hutool.cron.Scheduler;
|
||||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||||
|
import cn.jiangzeyin.pool.ThreadPoolService;
|
||||||
import cn.keepbx.jpom.common.commander.AbstractCommander;
|
import cn.keepbx.jpom.common.commander.AbstractCommander;
|
||||||
import cn.keepbx.jpom.service.manage.CommandService;
|
import cn.keepbx.jpom.service.manage.CommandService;
|
||||||
import cn.keepbx.jpom.socket.SocketSessionUtil;
|
import cn.keepbx.jpom.socket.SocketSessionUtil;
|
||||||
@ -23,6 +24,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* top命令管理,保证整个服务器只获取一个top命令
|
* top命令管理,保证整个服务器只获取一个top命令
|
||||||
@ -77,6 +79,7 @@ public class TopManager {
|
|||||||
} else {
|
} else {
|
||||||
topInfo = getWindowsMonitor();
|
topInfo = getWindowsMonitor();
|
||||||
}
|
}
|
||||||
|
sendProcessList();
|
||||||
send(topInfo);
|
send(topInfo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
||||||
@ -89,6 +92,32 @@ public class TopManager {
|
|||||||
watch = true;
|
watch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送首页进程列表信息
|
||||||
|
*/
|
||||||
|
private static void sendProcessList() {
|
||||||
|
ExecutorService executorService = ThreadPoolService.newCachedThreadPool(TopManager.class);
|
||||||
|
executorService.execute(() -> {
|
||||||
|
JSONArray array;
|
||||||
|
try {
|
||||||
|
if (AbstractCommander.OS_INFO.isLinux()) {
|
||||||
|
AbstractCommander instance = AbstractCommander.getInstance();
|
||||||
|
String head = instance.execSystemCommand("top -b -n 1 | head -7");
|
||||||
|
String s = instance.execSystemCommand("top -b -n 1 | grep java");
|
||||||
|
array = formatLinuxTop(head + s);
|
||||||
|
} else {
|
||||||
|
String s = AbstractCommander.getInstance().execSystemCommand("tasklist /V | findstr java");
|
||||||
|
array = formatWindowsProcess(s);
|
||||||
|
}
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("processList", array);
|
||||||
|
send(jsonObject.toJSONString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取windows 监控
|
* 获取windows 监控
|
||||||
*
|
*
|
||||||
@ -118,6 +147,11 @@ public class TopManager {
|
|||||||
return jsonObject.toJSONString();
|
return jsonObject.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 磁盘占用
|
||||||
|
*
|
||||||
|
* @return 磁盘占用
|
||||||
|
*/
|
||||||
private static JSONArray getHardDisk() {
|
private static JSONArray getHardDisk() {
|
||||||
File[] files = File.listRoots();
|
File[] files = File.listRoots();
|
||||||
long freeSpace = 0;
|
long freeSpace = 0;
|
||||||
|
@ -78,8 +78,38 @@
|
|||||||
<script>
|
<script>
|
||||||
function loadSuccess() {
|
function loadSuccess() {
|
||||||
var ws, myEcharts;
|
var ws, myEcharts;
|
||||||
|
loadProcessList();
|
||||||
loadFirstEcharts();
|
loadFirstEcharts();
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
id: 'tab_monitor',
|
||||||
|
elem: '#tab_monitor',
|
||||||
|
// height: 'full-52',
|
||||||
|
even: true,
|
||||||
|
cols: [[
|
||||||
|
{field: 'pid', title: '进程id', sort: true, width: '8%'},
|
||||||
|
{field: 'USER', title: '所有者', width: '12%'},
|
||||||
|
{field: 'PR', title: '优先级', width: '8%', sort: true},
|
||||||
|
{field: 'NI', title: 'nice值', width: '8%', sort: true},
|
||||||
|
{field: 'VIRT', title: '使用虚拟内存', width: '8%', sort: true},
|
||||||
|
{field: 'RES', title: '使用物理内存', width: '8%', sort: true},
|
||||||
|
{field: 'SHR', title: '共享内存', width: '8%', sort: true},
|
||||||
|
{field: 'S', title: '进程状态', width: '8%', sort: true},
|
||||||
|
{field: 'CPU', title: '占用CPU', width: '8%', sort: true},
|
||||||
|
{field: 'MEM', title: '占用物理内存', width: '8%', sort: true},
|
||||||
|
{field: 'TIME', title: '时间总计', width: '8%', sort: true},
|
||||||
|
{field: 'COMMAND', title: '进程名称'}
|
||||||
|
]],
|
||||||
|
loading: true,
|
||||||
|
method: 'POST',
|
||||||
|
response: {
|
||||||
|
statusCode: 200
|
||||||
|
},
|
||||||
|
done: function (data) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
table.render(config);
|
||||||
|
|
||||||
function loadFirstEcharts() {
|
function loadFirstEcharts() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './getTop',
|
url: './getTop',
|
||||||
@ -101,34 +131,27 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
table.render({
|
function loadProcessList() {
|
||||||
id: 'tab_monitor',
|
$.ajax({
|
||||||
elem: '#tab_monitor',
|
|
||||||
url: '/processList',
|
url: '/processList',
|
||||||
// height: 'full-52',
|
type: 'POST',
|
||||||
even: true,
|
dataType: 'json',
|
||||||
cols: [[
|
async: true,
|
||||||
{field: 'pid', title: '进程id', sort: true, width: '8%'},
|
success: function (data) {
|
||||||
{field: 'USER', title: '所有者', width: '12%'},
|
if (200 == data.code) {
|
||||||
{field: 'PR', title: '优先级', width: '8%'},
|
if (data.data) {
|
||||||
{field: 'NI', title: 'nice值', width: '8%'},
|
config.data = data.data;
|
||||||
{field: 'VIRT', title: '使用虚拟内存', width: '8%'},
|
table.render(config);
|
||||||
{field: 'RES', title: '使用物理内存', width: '8%'},
|
}
|
||||||
{field: 'SHR', title: '共享内存', width: '8%'},
|
} else {
|
||||||
{field: 'S', title: '进程状态', width: '8%'},
|
layer.alert(data.msg);
|
||||||
{field: 'CPU', title: '占用CPU', width: '8%'},
|
}
|
||||||
{field: 'MEM', title: '占用物理内存', width: '8%'},
|
|
||||||
{field: 'TIME', title: '时间总计', width: '8%'},
|
|
||||||
{field: 'COMMAND', title: '进程名称'}
|
|
||||||
]],
|
|
||||||
loading: true,
|
|
||||||
method: 'POST',
|
|
||||||
response: {
|
|
||||||
statusCode: 200
|
|
||||||
},
|
},
|
||||||
done: function (data) {
|
error: function (err) {
|
||||||
|
layer.alert("监控信息异常!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function linkSocket(status) {
|
function linkSocket(status) {
|
||||||
if (!ws) {
|
if (!ws) {
|
||||||
@ -148,6 +171,11 @@
|
|||||||
if (top.top) {
|
if (top.top) {
|
||||||
loadEcharts(top);
|
loadEcharts(top);
|
||||||
}
|
}
|
||||||
|
if (top.processList) {
|
||||||
|
var processList = top.processList;
|
||||||
|
config.data = processList;
|
||||||
|
table.render(config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return;
|
||||||
|
@ -20,12 +20,24 @@ public class DTest {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
File[] files = File.listRoots();
|
File[] files = File.listRoots();
|
||||||
|
long freeSpace = 0;
|
||||||
|
long useAbleSpace = 0;
|
||||||
|
long totalSpace = 0;
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
|
long free = file.getFreeSpace();
|
||||||
|
freeSpace += free;
|
||||||
|
long total = file.getTotalSpace();
|
||||||
|
totalSpace += total;
|
||||||
|
useAbleSpace += total - free;
|
||||||
System.out.println(file.getPath());
|
System.out.println(file.getPath());
|
||||||
System.out.println(FileUtil.readableFileSize(file.getFreeSpace()));
|
System.out.println(FileUtil.readableFileSize(free));
|
||||||
System.out.println(FileUtil.readableFileSize(file.getTotalSpace()));
|
System.out.println(FileUtil.readableFileSize(total - free));
|
||||||
System.out.println("---------------------");
|
System.out.println(FileUtil.readableFileSize(total));
|
||||||
|
System.out.println("-------------------------");
|
||||||
}
|
}
|
||||||
|
System.out.println(FileUtil.readableFileSize(freeSpace));
|
||||||
|
System.out.println(FileUtil.readableFileSize(useAbleSpace));
|
||||||
|
System.out.println(FileUtil.readableFileSize(totalSpace));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printTrack() {
|
private static void printTrack() {
|
||||||
|
Loading…
Reference in New Issue
Block a user