代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Java
】
代码获取系统运行信息
作者:
皓云
/ 发布于
2018/3/23
/
582
MemoryMXBean memorymbean = ManagementFactory.getMemoryMXBean(); MemoryUsage usage = memorymbean.getHeapMemoryUsage(); System.out.println("INIT HEAP: " + usage.getInit()); System.out.println("MAX HEAP: " + usage.getMax()); System.out.println("USE HEAP: " + usage.getUsed()); System.out.println("\nFull Information:"); System.out.println("Heap Memory Usage: " + memorymbean.getHeapMemoryUsage()); System.out.println("Non-Heap Memory Usage: " + memorymbean.getNonHeapMemoryUsage()); List<String> inputArguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); System.out.println("===================java options=============== "); System.out.println(inputArguments); System.out.println("=======================通过java来获取相关系统状态============================ "); int i = (int)Runtime.getRuntime().totalMemory()/1024;//Java 虚拟机中的内存总量,以字节为单位 System.out.println("总的内存量 i is "+i); int j = (int)Runtime.getRuntime().freeMemory()/1024;//Java 虚拟机中的空闲内存量 System.out.println("空闲内存量 j is "+j); System.out.println("最大内存量 is "+Runtime.getRuntime().maxMemory()/1024); System.out.println("=======================OperatingSystemMXBean============================ "); OperatingSystemMXBean osm = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); // System.out.println(osm.getFreeSwapSpaceSize()/1024); // System.out.println(osm.getFreePhysicalMemorySize()/1024); // System.out.println(osm.getTotalPhysicalMemorySize()/1024); //获取操作系统相关信息 System.out.println("osm.getArch() "+osm.getArch()); System.out.println("osm.getAvailableProcessors() "+osm.getAvailableProcessors()); //System.out.println("osm.getCommittedVirtualMemorySize() "+osm.getCommittedVirtualMemorySize()); System.out.println("osm.getName() "+osm.getName()); //System.out.println("osm.getProcessCpuTime() "+osm.getProcessCpuTime()); System.out.println("osm.getVersion() "+osm.getVersion()); //获取整个虚拟机内存使用情况 System.out.println("=======================MemoryMXBean============================ "); MemoryMXBean mm=(MemoryMXBean)ManagementFactory.getMemoryMXBean(); System.out.println("getHeapMemoryUsage "+mm.getHeapMemoryUsage()); System.out.println("getNonHeapMemoryUsage "+mm.getNonHeapMemoryUsage()); //获取各个线程的各种状态,CPU 占用情况,以及整个系统中的线程状况 System.out.println("=======================ThreadMXBean============================ "); ThreadMXBean tm=(ThreadMXBean)ManagementFactory.getThreadMXBean(); System.out.println("getThreadCount "+tm.getThreadCount()); System.out.println("getPeakThreadCount "+tm.getPeakThreadCount()); System.out.println("getCurrentThreadCpuTime "+tm.getCurrentThreadCpuTime()); System.out.println("getDaemonThreadCount "+tm.getDaemonThreadCount()); System.out.println("getCurrentThreadUserTime "+tm.getCurrentThreadUserTime()); //当前编译器情况 System.out.println("=======================CompilationMXBean============================ "); CompilationMXBean gm=(CompilationMXBean)ManagementFactory.getCompilationMXBean(); System.out.println("getName "+gm.getName()); System.out.println("getTotalCompilationTime "+gm.getTotalCompilationTime()); //获取多个内存池的使用情况 System.out.println("=======================MemoryPoolMXBean============================ "); List<MemoryPoolMXBean> mpmList=ManagementFactory.getMemoryPoolMXBeans(); for(MemoryPoolMXBean mpm:mpmList){ System.out.println("getUsage "+mpm.getUsage()); System.out.println("getMemoryManagerNames "+mpm.getMemoryManagerNames().toString()); } //获取GC的次数以及花费时间之类的信息 System.out.println("=======================MemoryPoolMXBean============================ "); List<GarbageCollectorMXBean> gcmList=ManagementFactory.getGarbageCollectorMXBeans(); for(GarbageCollectorMXBean gcm:gcmList){ System.out.println("getName "+gcm.getName()); System.out.println("getMemoryPoolNames "+gcm.getMemoryPoolNames()); } //获取运行时信息 System.out.println("=======================RuntimeMXBean============================ "); RuntimeMXBean rmb=(RuntimeMXBean)ManagementFactory.getRuntimeMXBean(); System.out.println("getClassPath "+rmb.getClassPath()); System.out.println("getLibraryPath "+rmb.getLibraryPath()); System.out.println("getVmVersion "+rmb.getVmVersion());
试试其它关键字
同语言下
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
可能有用的
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
皓云
贡献的其它代码
(
13
)
.
删除所有空目录
.
代码获取系统运行信息
.
隐藏手机号中间4位
.
Cookie帮助类
.
Spark MLlib之KMeans
.
从网络上进行下载图片,并保存到本地
.
阻止网站被嵌套
.
显示周一到周日
.
获取当前手机系统语言
.
字符串大小写转换
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3