use of java.lang.management.OperatingSystemMXBean in project Payara by payara.
the class RuntimeInfo method execute.
@Override
public void execute(AdminCommandContext context) {
report = context.getActionReport();
report.setActionExitCode(SUCCESS);
top = report.getTopMessagePart();
logger = context.getLogger();
boolean javaEnabledOnCmd = Boolean.parseBoolean(ctx.getArguments().getProperty("-debug"));
javaConfig = config.getJavaConfig();
jpdaEnabled = javaEnabledOnCmd || Boolean.parseBoolean(javaConfig.getDebugEnabled());
int debugPort = parsePort(javaConfig.getDebugOptions());
top.addProperty("debug", Boolean.toString(jpdaEnabled));
top.addProperty("debugPort", Integer.toString(debugPort));
final OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
top.addProperty("os.arch", osBean.getArch());
top.addProperty("os.name", osBean.getName());
top.addProperty("os.version", osBean.getVersion());
top.addProperty("availableProcessorsCount", "" + osBean.getAvailableProcessors());
// also if we are not on a sun jdk, we will not return this attribute.
if (!OS.isAix()) {
try {
final Method jm = osBean.getClass().getMethod("getTotalPhysicalMemorySize");
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
if (!jm.isAccessible()) {
jm.setAccessible(true);
}
return null;
}
});
top.addProperty("totalPhysicalMemorySize", "" + jm.invoke(osBean));
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
}
}
RuntimeMXBean rmxb = ManagementFactory.getRuntimeMXBean();
top.addProperty("startTimeMillis", "" + rmxb.getStartTime());
top.addProperty("pid", "" + rmxb.getName());
checkDtrace();
setDasName();
top.addProperty("java.vm.name", System.getProperty("java.vm.name"));
// setRestartable();
reportMessage.append(Strings.get("runtime.info.debug", jpdaEnabled ? "enabled" : "not enabled"));
report.setMessage(reportMessage.toString());
}
use of java.lang.management.OperatingSystemMXBean in project Payara by payara.
the class SummaryReporter method getSummaryReport.
public String getSummaryReport() throws RuntimeException {
try {
final StringBuilderNewLineAppender sb = new StringBuilderNewLineAppender(new StringBuilder());
final OperatingSystemMXBean os = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, OperatingSystemMXBean.class);
sb.append(getOSInfo(os));
final RuntimeMXBean rt = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
sb.append(getArguments(rt));
sb.append(getVMInfo(rt));
return (sb.toString(secretProperty));
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
use of java.lang.management.OperatingSystemMXBean in project traccar by tananaev.
the class Main method logSystemInfo.
public static void logSystemInfo() {
try {
OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
LOGGER.info("Operating system" + " name: " + operatingSystemBean.getName() + " version: " + operatingSystemBean.getVersion() + " architecture: " + operatingSystemBean.getArch());
RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
LOGGER.info("Java runtime" + " name: " + runtimeBean.getVmName() + " vendor: " + runtimeBean.getVmVendor() + " version: " + runtimeBean.getVmVersion());
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
LOGGER.info("Memory limit" + " heap: " + memoryBean.getHeapMemoryUsage().getMax() / (1024 * 1024) + "mb" + " non-heap: " + memoryBean.getNonHeapMemoryUsage().getMax() / (1024 * 1024) + "mb");
LOGGER.info("Character encoding: " + System.getProperty("file.encoding") + " charset: " + Charset.defaultCharset());
} catch (Exception error) {
LOGGER.warn("Failed to get system info");
}
}
use of java.lang.management.OperatingSystemMXBean in project pentaho-kettle by pentaho.
the class GetStatusServlet method getSystemInfo.
private static void getSystemInfo(SlaveServerStatus serverStatus) {
OperatingSystemMXBean operatingSystemMXBean = java.lang.management.ManagementFactory.getOperatingSystemMXBean();
ThreadMXBean threadMXBean = java.lang.management.ManagementFactory.getThreadMXBean();
RuntimeMXBean runtimeMXBean = java.lang.management.ManagementFactory.getRuntimeMXBean();
int cores = Runtime.getRuntime().availableProcessors();
long freeMemory = Runtime.getRuntime().freeMemory();
long totalMemory = Runtime.getRuntime().totalMemory();
String osArch = operatingSystemMXBean.getArch();
String osName = operatingSystemMXBean.getName();
String osVersion = operatingSystemMXBean.getVersion();
double loadAvg = operatingSystemMXBean.getSystemLoadAverage();
int threadCount = threadMXBean.getThreadCount();
long allThreadsCpuTime = 0L;
long[] threadIds = threadMXBean.getAllThreadIds();
for (int i = 0; i < threadIds.length; i++) {
allThreadsCpuTime += threadMXBean.getThreadCpuTime(threadIds[i]);
}
long uptime = runtimeMXBean.getUptime();
serverStatus.setCpuCores(cores);
serverStatus.setCpuProcessTime(allThreadsCpuTime);
serverStatus.setUptime(uptime);
serverStatus.setThreadCount(threadCount);
serverStatus.setLoadAvg(loadAvg);
serverStatus.setOsName(osName);
serverStatus.setOsVersion(osVersion);
serverStatus.setOsArchitecture(osArch);
serverStatus.setMemoryFree(freeMemory);
serverStatus.setMemoryTotal(totalMemory);
}
use of java.lang.management.OperatingSystemMXBean in project gephi by gephi.
the class ReportController method logCPU.
private void logCPU(Report report) {
OperatingSystemMXBean bean = ManagementFactory.getOperatingSystemMXBean();
report.setNumberOfProcessors(bean.getAvailableProcessors());
// NOI18N
String unknown = "unknown";
String str = // NOI18N
System.getProperty("os.name", unknown) + ", " + System.getProperty("os.version", unknown) + // NOI18N
", " + // NOI18N
System.getProperty("os.arch", unknown);
report.setOs(str);
}
Aggregations