本文整理匯總了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();
}
示例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)));
}
示例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;
}
示例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);
}
示例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;
}
示例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 );
}
}
示例7: getUptime
import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
public static long getUptime() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getUptime();
}
示例8: getSystemUptime
import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
public Long getSystemUptime() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getUptime();
}
示例9: getUptime
import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
public Long getUptime() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getUptime();
}
示例10: getUptime
import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
@Override
public Long getUptime() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getUptime();
}
示例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();
}
示例12: getUptime
import java.lang.management.RuntimeMXBean; //導入方法依賴的package包/類
/**
* Gets UP time.
*
* @return UP time
*/
public Long getUptime() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getUptime();
}