当前位置: 首页>>代码示例>>Java>>正文


Java OperatingSystemMXBean.getFreeSwapSpaceSize方法代码示例

本文整理汇总了Java中com.sun.management.OperatingSystemMXBean.getFreeSwapSpaceSize方法的典型用法代码示例。如果您正苦于以下问题:Java OperatingSystemMXBean.getFreeSwapSpaceSize方法的具体用法?Java OperatingSystemMXBean.getFreeSwapSpaceSize怎么用?Java OperatingSystemMXBean.getFreeSwapSpaceSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.management.OperatingSystemMXBean的用法示例。


在下文中一共展示了OperatingSystemMXBean.getFreeSwapSpaceSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:20,代码来源:SwapAgent.java

示例2: 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();
}
 
开发者ID:ctripcorp,项目名称:cornerstone,代码行数:48,代码来源:PerformanceStatus.java

示例3: 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);
    }

}
 
开发者ID:ctripcorp,项目名称:cornerstone,代码行数:65,代码来源:VMSummary.java

示例4: 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;
}
 
开发者ID:Titousensei,项目名称:sisyphus,代码行数:68,代码来源:PerformanceMonitor.java


注:本文中的com.sun.management.OperatingSystemMXBean.getFreeSwapSpaceSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。