/**
*
*/
package com.opensource.nredis.proxy.monitor.api;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.MemoryMXBean;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.abel533.echarts.Grid;
import com.github.abel533.echarts.Option;
import com.github.abel533.echarts.axis.AxisLabel;
import com.github.abel533.echarts.axis.CategoryAxis;
import com.github.abel533.echarts.axis.ValueAxis;
import com.github.abel533.echarts.code.AxisType;
import com.github.abel533.echarts.code.SeriesType;
import com.github.abel533.echarts.code.Trigger;
import com.github.abel533.echarts.series.Line;
import com.opensource.nredis.proxy.monitor.api.utils.ConfigUtils;
import com.opensource.nredis.proxy.monitor.date.utils.DateBase;
import com.opensource.nredis.proxy.monitor.enums.TomcatStatusEnums;
import com.opensource.nredis.proxy.monitor.jvm.tools.CPUBean;
import com.opensource.nredis.proxy.monitor.jvm.tools.HeapMemroryGarbage;
import com.opensource.nredis.proxy.monitor.jvm.tools.MemrorySpaceBean;
import com.opensource.nredis.proxy.monitor.jvm.tools.MonitorJVM;
import com.opensource.nredis.proxy.monitor.jvm.tools.QuartzRuntimeBean;
import com.opensource.nredis.proxy.monitor.jvm.tools.TomcatThreadBean;
import com.opensource.nredis.proxy.monitor.model.SystemApplication;
import com.opensource.nredis.proxy.monitor.model.SystemComponent;
import com.opensource.nredis.proxy.monitor.platform.DataGridObject;
import com.opensource.nredis.proxy.monitor.platform.EChartsObject;
import com.opensource.nredis.proxy.monitor.platform.NormalAreaStyle;
import com.opensource.nredis.proxy.monitor.platform.ResponseObject;
import com.opensource.nredis.proxy.monitor.platform.RestStatus;
import com.opensource.nredis.proxy.monitor.service.ISystemApplicationService;
import com.opensource.nredis.proxy.monitor.service.ISystemComponentService;
import com.opensource.nredis.proxy.monitor.string.utils.StringUtil;
/**
* @author liubing
* 系统首页监控图
*/
@Controller
public class SystemIndexController {
private Logger logger = Logger.getLogger(SystemIndexController.class);
@Autowired
private ISystemApplicationService systemApplicationService;
@Autowired
private ISystemComponentService systemComponentService;
private static Integer tomcatFlag=1;
private static Integer quartzFlag=2;
//--------------------------------tomcat thread--------------
private List<String> threadTime=new ArrayList<String>();
private Map<Integer,List<Long>> tomcatCurrentThreadCountMap=new ConcurrentHashMap<Integer, List<Long>>();
private Map<Integer,List<Long>> tomcatCurrentThreadsBusyMap=new ConcurrentHashMap<Integer, List<Long>>();
private Map<Integer,List<Long>> tomcatMaxThreadMap=new ConcurrentHashMap<Integer, List<Long>>();
//------------------------------jvm thread---------------------
private Map<Integer,List<Integer>> jvmThreadThreadCountsMap=new ConcurrentHashMap<Integer, List<Integer>>();
private Map<Integer,List<Integer>> jvmThreadDeadThreadCountsMap=new ConcurrentHashMap<Integer, List<Integer>>();
//----------------------------jvm classLoader--------------------
private Map<Integer,List<Integer>> jvmClassLoaderLoadedClassCountMap=new ConcurrentHashMap<Integer, List<Integer>>();
//------------------------------cpu -----------------------------------
private Map<Integer,List<Double>> CPUCountMap=new ConcurrentHashMap<Integer, List<Double>>();
//------------------------------jvm heap -----------------------------------
private Map<Integer,List<Double>>jvmHeapCountMap=new ConcurrentHashMap<Integer, List<Double>>();
//-------------------------------jvm各个区域使用率---------------------------------------
private Map<Integer,List<Double>> jvmEdenCountMap=new ConcurrentHashMap<Integer, List<Double>>();
private Map<Integer,List<Double>> jvmSurvivorCountMap=new ConcurrentHashMap<Integer, List<Double>>();
private Map<Integer,List<Double>>jvmOldCountMap=new ConcurrentHashMap<Integer, List<Double>>();
private Map<Integer,List<Double>> jvmPermCountMap=new ConcurrentHashMap<Integer, List<Double>>();
@RequestMapping(value = "/{id}/searchSystemComponentObject", method = RequestMethod.GET)
@ResponseBody
public ResponseObject searchSystemComponentObject(@PathVariable Integer id)throws Exception{
ResponseObject responseObject=new ResponseObject();
Map<String, Integer> result=new HashMap<String, Integer>();
List<SystemComponent> systemComponents=systemComponentService.getListByApplicationId(id);
if(systemComponents!=null&&systemComponents.size()>0){
for(SystemComponent systemComponent:systemComponents){
if(StringUtil.isNotEmpty(systemComponent.getComponentValue())&&Integer.parseInt(systemComponent.getComponentValue())==quartzFlag){
result.put("quartz", 1);//有
}
if(StringUtil.isNotEmpty(systemComponent.getComponentValue())&&Integer.parseInt(systemComponent.getComponentValue())==tomcatFlag){
result.put("tomcat", 1);//有
}
}
}else{
result.put("quartz", 0);//无
result.put("tomcat", 0);//无
}
responseObject.setData(result);
responseObject.setStatus(RestStatus.SERVER_ERROR.code);
responseObject.setMessage(RestStatus.SERVER_ERROR.message);
return responseObject;
}
/**
* 统一时间点
* 查询监控报表数据
* @return
* @throws Exception
*/
@RequestMapping(value = "/{id}/searchEChartsObject", method = RequestMethod.GET)
@ResponseBody
public EChartsObject searchEChartsObject(@PathVariable Integer id)throws Exception{
SystemApplication systemApplication=systemApplicationService.getEntityById(id);
Integer tomcat=0,quartz=0;//默认无关联组件
List<SystemComponent> systemComponents=systemComponentService.getListByApplicationId(id);
if(systemComponents!=null&&systemComponents.size()>0){
for(SystemComponent systemComponent:systemComponents){
if(StringUtil.isNotEmpty(systemComponent.getComponentValue())&&Integer.parseInt(systemComponent.getComponentValue())==quartzFlag){
quartz=1;//有关联控件
}
if(StringUtil.isNotEmpty(systemComponent.getComponentValue())&&Integer.parseInt(systemComponent.getComponentValue())==tomcatFlag){
tomcat=1;//有关联控件
}
}
}
return getSelfCPUUsed(systemApplication,tomcat,quartz);
}
/**
* 获取cpu使用消息
* @param systemApplication
* @param tomcatFlag 1:成功,2:失败
* @param quartzFlag 1:成功,2:失败
* @return
* @throws Exception
*/
private EChartsObject getSelfCPUUsed(SystemApplication systemApplication,Integer tomcatFlag,Integer quartzFlag)throws Exception{
EChartsObject chartsObject=new EChartsObject();
Long start = System.currentTimeMillis();
MonitorJVM monitorJVM=new MonitorJVM(systemApplication.getJmxHost(), systemApplication.getJmxPort(), systemApplication.getJmxUserName(), systemApplication.getJmxPassWord());
CPUBean cPUBean=monitorJVM.getProcessCpuTime();
try {
if(quartzFlag!=null&&quartzFlag==1){
chartsObject.setQuartzRuntimeDataGridObject(searchQuartzRuntimeBeans(systemApplication,monitorJVM));
}
if(tomcatFlag!=null&&tomcatFlag==1){
chartsObject.setTomcatThreadOption(searchSelfTomcatThread(systemApplication,monitorJVM));
}
chartsObject.setHeapMemroryGarbageObject(searchHeapMemroryGarbage(systemApplication,monitorJVM));
chartsObject.setJvmInfoOption(searchSelfJVMInfo(systemApplication,monitorJVM));
chartsObject.setJ
没有合适的资源?快使用搜索试试~ 我知道了~
redis-monitor-master.zip
共816个文件
css:207个
png:148个
java:145个
1 下载量 182 浏览量
2022-12-10
10:07:49
上传
评论
收藏 2.37MB ZIP 举报
温馨提示
大家还在愁JVM,CPU等监控无门吗?对于分布式环境怎么样监控呢?,小型机器人替你搞定一切!redis-monitor 是一个nredis-proxy 的小型机器人,可以监控redisServer,nredis-proxy,jvm ,cpu等;具有failover功能!
资源推荐
资源详情
资源评论
收起资源包目录
redis-monitor-master.zip (816个子文件)
.classpath 1KB
.classpath 1KB
.classpath 1KB
.classpath 1KB
.classpath 1KB
org.eclipse.wst.common.component 2KB
org.eclipse.wst.common.component 327B
org.eclipse.wst.common.component 323B
org.eclipse.wst.common.component 256B
org.eclipse.wst.common.component 253B
org.eclipse.wst.jsdt.ui.superType.container 49B
easyui.css 59KB
easyui.css 58KB
easyui.css 58KB
easyui.css 58KB
easyui.css 56KB
easyui.css 55KB
font-awesome.css 37KB
font-awesome.min.css 30KB
layui.css 27KB
global.css 18KB
layer.css 14KB
tabs.css 9KB
tabs.css 9KB
tabs.css 9KB
tabs.css 9KB
laydate.css 8KB
tabs.css 7KB
tabs.css 7KB
mobile.css 7KB
color.css 6KB
datagrid.css 6KB
datagrid.css 6KB
datagrid.css 6KB
datagrid.css 6KB
datagrid.css 5KB
datagrid.css 5KB
linkbutton.css 4KB
linkbutton.css 4KB
linkbutton.css 4KB
linkbutton.css 4KB
linkbutton.css 4KB
calendar.css 4KB
calendar.css 4KB
calendar.css 4KB
calendar.css 4KB
calendar.css 4KB
calendar.css 4KB
linkbutton.css 3KB
tree.css 3KB
tree.css 3KB
tree.css 3KB
tree.css 3KB
tree.css 3KB
tree.css 3KB
panel.css 3KB
panel.css 3KB
panel.css 3KB
panel.css 3KB
textbox.css 3KB
textbox.css 3KB
textbox.css 3KB
textbox.css 3KB
textbox.css 3KB
textbox.css 3KB
layout.css 3KB
layout.css 3KB
layout.css 3KB
layout.css 3KB
layout.css 3KB
layout.css 3KB
icon.css 2KB
panel.css 2KB
panel.css 2KB
window.css 2KB
window.css 2KB
window.css 2KB
window.css 2KB
menu.css 2KB
menu.css 2KB
menu.css 2KB
menu.css 2KB
menu.css 2KB
menu.css 2KB
window.css 2KB
window.css 2KB
tooltip.css 2KB
tooltip.css 2KB
tooltip.css 2KB
tooltip.css 2KB
tooltip.css 2KB
tooltip.css 2KB
menubutton.css 2KB
menubutton.css 2KB
menubutton.css 2KB
menubutton.css 2KB
menubutton.css 2KB
menubutton.css 2KB
datalist.css 2KB
datalist.css 2KB
共 816 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
m0_72731342
- 粉丝: 4
- 资源: 1829
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 1键切换,随机播放本地音乐(适合管理大量本地音乐),无需联网,珍藏版音乐软件
- canoe的log数据文件读取
- 纸检测55-YOLOv5数据集合集.rar
- 实现vue+docxtemplater导出word文档功能时,需要引入的资源文件
- 个人PPT模板,总结或者作为素材使用
- 纸板、面料、纸类、塑料检测68-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 【java源代码】基于spring+vue的音乐推荐管理(完整前后端+mysql+说明文档+LW).zip
- 长文本c++Aes加密
- 纸和塑料检测55-YOLO(v7至v9)、Paligemma、VOC数据集合集.rar
- 烟雾明火分割数据集labelme格式5205张2类别.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功