當前位置: 首頁>>代碼示例>>Java>>正文


Java RuntimeMXBean.getUptime方法代碼示例

本文整理匯總了Java中java.lang.management.RuntimeMXBean.getUptime方法的典型用法代碼示例。如果您正苦於以下問題:Java RuntimeMXBean.getUptime方法的具體用法?Java RuntimeMXBean.getUptime怎麽用?Java RuntimeMXBean.getUptime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.management.RuntimeMXBean的用法示例。


在下文中一共展示了RuntimeMXBean.getUptime方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refresh

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
@Override
public void refresh() {
    if(HostInfo.isTomcat()){
        webInfo = "view";
    }
    RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
    upTime = runtimeBean.getUptime();
    EnApp enApp = EnFactory.getEnApp();
    enApp.refresh();
    appid = nullToNA(EnFactory.getEnBase().getAppId());
    appName = nullToNA(enApp.getName());
    appChineseName = nullToNA(enApp.getChineseName());
    appOwner = nullToNA(enApp.getOwner());
    appOwnerEmail = nullToNA(enApp.getOwnerContact());
    appBackup = nullToNA(enApp.getBackup());
    appVersion = nullToNA(enApp.getVersion());
    buildTime = nullToNA(enApp.getBuildTime());
    getStatus();
}
 
開發者ID:ctripcorp,項目名稱:cornerstone,代碼行數:20,代碼來源:AppInfo.java

示例2: reportCPU

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
private Optional<Double> reportCPU(OperatingSystemMXBean operatingSystemMXBean, RuntimeMXBean runtimeMXBean) {
    int availableProcessors = divideByNbCores ? operatingSystemMXBean.getAvailableProcessors() : 1;
    long upTime = runtimeMXBean.getUptime();
    long processCpuTime = operatingSystemMXBean.getProcessCpuTime();

    if (lastMeasures == null
            || lastMeasures.availableProcessors != availableProcessors
            || lastMeasures.processCpuTime < 0) {
        lastMeasures = new Measures(availableProcessors, upTime, processCpuTime);
        return Optional.empty();
    }

    long elapsedCpu = processCpuTime - lastMeasures.processCpuTime;
    long elapsedTime = upTime - lastMeasures.upTime;
    lastMeasures = new Measures(availableProcessors, upTime, processCpuTime);

    return Optional.of(Math.min(99D, elapsedCpu / (elapsedTime * 10000D * availableProcessors)));
}
 
開發者ID:jotak,項目名稱:hawkular-java-toolbox,代碼行數:19,代碼來源:CPUMonitoring.java

示例3: initialize

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
public LocatorStatusResponse initialize(final int locatorPort, final String locatorHost,
    final String locatorLogFile, final String locatorName) {
  final RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
  this.pid = identifyPid();
  this.jvmArgs = runtimeBean.getInputArguments();
  this.uptime = runtimeBean.getUptime();
  this.classpath = runtimeBean.getClassPath();
  this.gemfireVersion = GemFireVersion.getGemFireVersion();
  this.javaVersion = System.getProperty("java.version");
  this.workingDirectory = System.getProperty("user.dir");
  this.logFile = locatorLogFile;
  this.host = locatorHost;
  this.port = locatorPort;
  this.name = locatorName;
  return this;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:17,代碼來源:LocatorStatusResponse.java

示例4: applicationUptime

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
private String applicationUptime() {
    RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
    long seconds = rb.getUptime() / 1000;
    long d = (long) Math.floor(seconds / 86400);
    long h = (long) Math.floor((seconds % 86400) / 3600);
    long m = (long) Math.floor(((seconds % 86400) % 3600) / 60);
    long s = (long) Math.floor(((seconds % 86400) % 3600) % 60);

    if (d > 0) {
        return String.format("%sd %sh %sm %ss", d, h, m, s);
    }

    if (h > 0) {
        return String.format("%sh %sm %ss", h, m, s);
    }

    if (m > 0) {
        return String.format("%sm %ss", m, s);
    }
    return String.format("%ss", s);
}
 
開發者ID:avaire,項目名稱:avaire,代碼行數:22,代碼來源:StatsCommand.java

示例5: getProcessCpuUtilization

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
/**
 * obtain current process cpu utilization if jdk version is 1.6 by-hongqiangwei
 */
@SuppressWarnings("restriction")
public static double getProcessCpuUtilization() {

    com.sun.management.OperatingSystemMXBean osMBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory
            .getOperatingSystemMXBean();
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();

    long processCpuTime1 = osMBean.getProcessCpuTime();
    long runtime1 = runtimeMXBean.getUptime();

    ThreadHelper.suspend(50);

    long processCpuTime2 = osMBean.getProcessCpuTime();
    long runtime2 = runtimeMXBean.getUptime();

    long deltaProcessTime = processCpuTime2 - processCpuTime1;
    long deltaRunTime = (runtime2 - runtime1) * 1000000L;
    int cpuNumber = Runtime.getRuntime().availableProcessors();
    double cpuUtilization = (double) deltaProcessTime / (deltaRunTime * cpuNumber);

    return cpuUtilization;
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:26,代碼來源:JVMToolHelper.java

示例6: action

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
@Override
public void action(String prefix, String[] args, MessageReceivedEvent event)
{
    JDA.ShardInfo info = event.getJDA().getShardInfo();
    Runtime rt = Runtime.getRuntime();
    RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();

    String msg = "```python\n" +
            "\"Database\"\n" +
            "      Entries: " + Main.getDBDriver().getEventCollection().count() + "\n" +
            "    Schedules: " + Main.getDBDriver().getScheduleCollection().count() + "\n" +
            "       Guilds: " + Main.getDBDriver().getGuildCollection().count() + "\n" +
            "\n\"Shard\"\n" +
            "      ShardId: " + info.getShardId() + "/" + info.getShardTotal() + "\n" +
            "       Guilds: " + event.getJDA().getGuilds().size() + "\n" +
            "        Users: " + event.getJDA().getUsers().size() + "\n" +
            "ResponseTotal: " + event.getJDA().getResponseTotal() + "\n" +
            "\n\"Application\"\n" +
            " Memory-total: " +rt.totalMemory()/1024/1024 + " MB\n" +
            "       -free : " + rt.freeMemory()/1024/1024 + " MB\n" +
            "       -max  : " + rt.maxMemory()/1024/1024 + " MB\n" +
            "      Threads: " + Thread.activeCount() + "\n" +
            "       Uptime: " + rb.getUptime()/1000/60 + " minute(s)" +
            "```";

    if(event.isFromType(ChannelType.PRIVATE))
    {
        MessageUtilities.sendPrivateMsg( msg, event.getAuthor(), null );
    }
    else
    {
        MessageUtilities.sendMsg( msg, event.getTextChannel(), null );
    }
}
 
開發者ID:notem,項目名稱:Saber-Bot,代碼行數:35,代碼來源:StatsCommand.java

示例7: getUptime

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
public static long getUptime() {
    RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
    return rb.getUptime();
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:5,代碼來源:ServerUtil.java

示例8: getSystemUptime

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
public Long getSystemUptime() {
    RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
    return rb.getUptime();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:5,代碼來源:Controller.java

示例9: getUptime

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
public Long getUptime() {
    RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
    return rb.getUptime();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:5,代碼來源:Controller.java

示例10: getUptime

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
@Override
public Long getUptime() {
    RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
    return rb.getUptime();
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:6,代碼來源:Controller.java

示例11: AppInfo

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
public AppInfo() {

        RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
        AppStartUpTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(runtimeBean.getStartTime()));
        upTime = runtimeBean.getUptime();


    }
 
開發者ID:ctripcorp,項目名稱:cornerstone,代碼行數:9,代碼來源:AppInfo.java

示例12: getUptime

import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
/**
 * Gets UP time.
 *
 * @return UP time
 */
public Long getUptime() {
    RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
    return rb.getUptime();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:10,代碼來源:Controller.java


注:本文中的java.lang.management.RuntimeMXBean.getUptime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。