本文整理汇总了Java中com.sun.management.OperatingSystemMXBean.getTotalSwapSpaceSize方法的典型用法代码示例。如果您正苦于以下问题:Java OperatingSystemMXBean.getTotalSwapSpaceSize方法的具体用法?Java OperatingSystemMXBean.getTotalSwapSpaceSize怎么用?Java OperatingSystemMXBean.getTotalSwapSpaceSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.management.OperatingSystemMXBean
的用法示例。
在下文中一共展示了OperatingSystemMXBean.getTotalSwapSpaceSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.sun.management.OperatingSystemMXBean; //导入方法依赖的package包/类
@Override
public void execute(AgentOrder agentOrder) {
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
if (operatingSystemMXBean == null) {
return;
}
long totalSwapSpace = operatingSystemMXBean.getTotalSwapSpaceSize();
long freeSwapSpace = operatingSystemMXBean.getFreeSwapSpaceSize();
long usedSwapSpace = totalSwapSpace - freeSwapSpace;
OsEventBuilder eventBuilder = OsEventBuilder.createSwapBuilder(this.getEventBuilderData());
eventBuilder.setTotalSwapSpace(totalSwapSpace);
eventBuilder.setFreeSwapSpace(freeSwapSpace);
eventBuilder.setUsedSwapSpace(usedSwapSpace);
this.sendEvent(eventBuilder.toEvent());
}
示例2: getMemeryRate
import com.sun.management.OperatingSystemMXBean; //导入方法依赖的package包/类
/**
* 获取内存使用率
* @return
*/
public static String getMemeryRate()
{
OperatingSystemMXBean osmxb = (OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
// 总的物理内存+虚拟内存
long totalvirtualMemory = osmxb.getTotalSwapSpaceSize();
// 剩余的物理内存
long freePhysicalMemorySize = osmxb.getFreePhysicalMemorySize();
Double compare = (Double)(1 - freePhysicalMemorySize * 1.0 / totalvirtualMemory) * 100;
String str = compare.intValue() + "%";
return str;
}
示例3: PerformanceStatus
import com.sun.management.OperatingSystemMXBean; //导入方法依赖的package包/类
public PerformanceStatus() {
OperatingSystemMXBean bean= (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
heapMemoryUsage= memBean.getHeapMemoryUsage();
nonHeapMemoryUsage = memBean.getNonHeapMemoryUsage();
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
currentThreadCount=threadBean.getThreadCount();
daemonThreadCount= threadBean.getDaemonThreadCount();
beanCreatedThreadCount= threadBean.getTotalStartedThreadCount();
peakThreadCount = threadBean.getPeakThreadCount();
ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean();
loadedClassCount=classLoadingBean.getLoadedClassCount();
totalLoadedClassCount=classLoadingBean.getTotalLoadedClassCount();
unloadedClassCount=classLoadingBean.getUnloadedClassCount();
committedVirtualMemorySize = (bean.getCommittedVirtualMemorySize());
freePhysicalMemorySize =(bean.getFreePhysicalMemorySize());
totalPhysicalMemorySize =(bean.getTotalPhysicalMemorySize());
freeSwapSpaceSize =(bean.getFreeSwapSpaceSize());
totalSwapSpaceSize =(bean.getTotalSwapSpaceSize());
processCpuTime =(bean.getProcessCpuTime());
availableProcessors =bean.getAvailableProcessors();
processCpuLoad =bean.getProcessCpuLoad();
systemCpuLoad =bean.getSystemCpuLoad();
systemLoadAverage =bean.getSystemLoadAverage();
appStartUpTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(runtimeBean.getStartTime()));
runtime = (new Date().getTime() - runtimeBean.getStartTime())/1000;
os = bean.getName()+" "+bean.getVersion();
if(HostInfo.isLinux()){
try {
availableMemory = (LinuxInfoUtil.getAvailableMemKB()*1024l);
} catch (Throwable ignored) {
}
}
File[] roots = File.listRoots();
for(File file:roots){
rootFiles.add(new RootFile(file.getAbsolutePath(),file.getTotalSpace(),file.getFreeSpace()));
}
getGCStatus();
}
示例4: VMSummary
import com.sun.management.OperatingSystemMXBean; //导入方法依赖的package包/类
public VMSummary(){
MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
MemoryUsage u = bean.getHeapMemoryUsage();
heapCommitedMemory= (u.getCommitted());
heapUsedMemory=(u.getUsed());
heapMaxMemory=(u.getMax());
u = bean.getNonHeapMemoryUsage();
nonHeapCommitedMemory=(u.getCommitted());
nonHeapUsedMemory=(u.getUsed());
nonHeapMaxMemory=(u.getMax());
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
currentThreadCount=threadBean.getThreadCount();
daemonThreadCount= threadBean.getDaemonThreadCount();
totalStartedThreadCount= threadBean.getTotalStartedThreadCount();
peakThreadCount = threadBean.getPeakThreadCount();
ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean();
loadedClassCount=classLoadingBean.getLoadedClassCount();
totalLoadedClassCount=classLoadingBean.getTotalLoadedClassCount();
unloadedClassCount=classLoadingBean.getUnloadedClassCount();
getGCStatus();
RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
classPath = runtimeBean.getClassPath();
libraryPath = runtimeBean.getLibraryPath();
vmOptions = TextUtils.join(" ",runtimeBean.getInputArguments());
bootClassPath = runtimeBean.getBootClassPath();
upTime = runtimeBean.getUptime();
vmName=runtimeBean.getVmName();
vmVendor= runtimeBean.getVmVendor();
OperatingSystemMXBean osBean= (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
processCpuTime = osBean.getProcessCpuTime();
jdkVersion=System.getProperty("java.version");
jitCompiler=System.getProperty("java.vm.name");
os = osBean.getName() + " "+osBean.getVersion();
osArch = osBean.getArch();
availableProcessors = osBean.getAvailableProcessors();
commitedVirtualMemory = osBean.getCommittedVirtualMemorySize();
freePhysicalMemorySize =(osBean.getFreePhysicalMemorySize());
totalPhysicalMemorySize =(osBean.getTotalPhysicalMemorySize());
freeSwapSpaceSize =(osBean.getFreeSwapSpaceSize());
totalSwapSpaceSize =(osBean.getTotalSwapSpaceSize());
List<GarbageCollectorMXBean> beans = ManagementFactory.getGarbageCollectorMXBeans();
gcInfos = new ArrayList<>(beans.size());
for (GarbageCollectorMXBean b : beans) {
GCBean gcBean = new GCBean();
gcBean.name =b.getName();
gcBean.gcCount = b.getCollectionCount();
gcBean.gcTime = b.getCollectionTime();
gcInfos.add(gcBean);
}
}
示例5: getTotalMemery
import com.sun.management.OperatingSystemMXBean; //导入方法依赖的package包/类
/**
* 获取总共内存
* @return
*/
public static Long getTotalMemery(){
OperatingSystemMXBean osmxb = (OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
// 总的物理内存+虚拟内存
return osmxb.getTotalSwapSpaceSize();
}
示例6: PerformanceMonitor
import com.sun.management.OperatingSystemMXBean; //导入方法依赖的package包/类
public PerformanceMonitor()
{
ArrayList<MemoryPoolMXBean> hb = new ArrayList();
for (MemoryPoolMXBean p : ManagementFactory.getMemoryPoolMXBeans()) {
if (p.getType() == MemoryType.HEAP) {
hb.add(p);
}
}
hb.trimToSize();
hbean_ = hb;
num_mem_ = hbean_.size();
heap_start_ = new ArrayList(num_mem_);
heap_peak_ = new ArrayList(num_mem_);
heap_last_ = new ArrayList(num_mem_);
heap_committed_sum_ = 0;
heap_used_sum_ = 0;
for (int i=0 ; i<num_mem_ ; i++) {
MemoryPoolMXBean mb = hbean_.get(i);
mb.resetPeakUsage();
heap_peak_.add(mb.getPeakUsage());
MemoryUsage mu = mb.getUsage();
heap_start_.add(mu);
heap_last_.add(mu);
heap_committed_sum_ += mu.getCommitted()>>>MB_SHIFT;
heap_used_sum_ += mu.getUsed()>>>MB_SHIFT;
}
heap_cnt_ = 1;
gcbeans_ = ManagementFactory.getGarbageCollectorMXBeans();
num_gc_ = gcbeans_.size();
gc_time_ = new long[num_gc_];
gc_last_ = new long[num_gc_];
gc_cnt_ = new long[num_gc_];
for (int i=0 ; i<num_gc_ ; i++) {
GarbageCollectorMXBean gc = gcbeans_.get(i);
gc_cnt_[i] = gc.getCollectionCount();
gc_time_[i] = gc.getCollectionTime();
gc_last_[i] = gc_time_[i];
}
osbean_ = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
cpu_start_ = osbean_.getProcessCpuTime();
cpu_last_ = cpu_start_;
num_cpu_ = osbean_.getAvailableProcessors();
load_last_ = osbean_.getSystemLoadAverage();
swap_total_ = osbean_.getTotalSwapSpaceSize();
swap_last_ = osbean_.getFreeSwapSpaceSize();
thbean_ = (ThreadMXBean) ManagementFactory.getThreadMXBean();
th_daemon_ = thbean_.getDaemonThreadCount();
th_peak_ = thbean_.getPeakThreadCount();
th_count_ = thbean_.getThreadCount();
th_total_started_ = thbean_.getTotalStartedThreadCount();
time_start_ = System.currentTimeMillis();
time_last_ = time_start_;
time_prev_ = time_last_;
cpu_prev_ = cpu_last_;
instant_gc_ = 0.0;
instant_cpu_ = 0.0;
}