use of java.lang.management.RuntimeMXBean in project android by JetBrains.
the class GoogleCrash method createPost.
@NotNull
private HttpUriRequest createPost(@NotNull FlightRecorder flightRecorder, @NotNull String issueText, @NotNull List<Path> logFiles) {
HttpPost post = new HttpPost(myCrashUrl);
ApplicationInfo applicationInfo = getApplicationInfo();
String strictVersion = applicationInfo == null ? "0.0.0.0" : applicationInfo.getStrictVersion();
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
// key names recognized by crash
builder.addTextBody(KEY_PRODUCT_ID, "AndroidStudio");
builder.addTextBody(KEY_VERSION, strictVersion);
builder.addTextBody("exception_info", getUniqueStackTrace());
builder.addTextBody("user_report", issueText);
if (ANONYMIZED_UID != null) {
builder.addTextBody("guid", ANONYMIZED_UID);
}
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
builder.addTextBody("ptime", Long.toString(runtimeMXBean.getUptime()));
// product specific key value pairs
builder.addTextBody("fullVersion", applicationInfo == null ? "0.0.0.0" : applicationInfo.getFullVersion());
builder.addTextBody("osName", StringUtil.notNullize(SystemInfo.OS_NAME));
builder.addTextBody("osVersion", StringUtil.notNullize(SystemInfo.OS_VERSION));
builder.addTextBody("osArch", StringUtil.notNullize(SystemInfo.OS_ARCH));
builder.addTextBody("locale", StringUtil.notNullize(LOCALE));
builder.addTextBody("vmName", StringUtil.notNullize(runtimeMXBean.getVmName()));
builder.addTextBody("vmVendor", StringUtil.notNullize(runtimeMXBean.getVmVendor()));
builder.addTextBody("vmVersion", StringUtil.notNullize(runtimeMXBean.getVmVersion()));
MemoryUsage usage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
builder.addTextBody("heapUsed", Long.toString(usage.getUsed()));
builder.addTextBody("heapCommitted", Long.toString(usage.getCommitted()));
builder.addTextBody("heapMax", Long.toString(usage.getMax()));
// add report specific data
builder.addTextBody("Type", "InstantRunFlightRecorder");
addFlightRecorderLogs(builder, flightRecorder, logFiles);
post.setEntity(new GzipCompressingEntity(builder.build()));
return post;
}
use of java.lang.management.RuntimeMXBean in project midpoint by Evolveum.
the class WebComponentUtil method getSystemLoad.
public static double getSystemLoad() {
com.sun.management.OperatingSystemMXBean operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
int availableProcessors = operatingSystemMXBean.getAvailableProcessors();
long prevUpTime = runtimeMXBean.getUptime();
long prevProcessCpuTime = operatingSystemMXBean.getProcessCpuTime();
try {
Thread.sleep(150);
} catch (Exception ignored) {
// ignored
}
operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
long upTime = runtimeMXBean.getUptime();
long processCpuTime = operatingSystemMXBean.getProcessCpuTime();
long elapsedCpu = processCpuTime - prevProcessCpuTime;
long elapsedTime = upTime - prevUpTime;
double cpuUsage = Math.min(99F, elapsedCpu / (elapsedTime * 10000F * availableProcessors));
return cpuUsage;
}
use of java.lang.management.RuntimeMXBean in project mysql_perf_analyzer by yahoo.
the class App method getPid.
/**
* Get process id of current running starloader
*
* @return OS process id
*/
public static int getPid() {
try {
RuntimeMXBean runtime = java.lang.management.ManagementFactory.getRuntimeMXBean();
String jvmName = runtime.getName();
String ss = jvmName.substring(0, jvmName.indexOf('@'));
return Integer.parseInt(ss);
} catch (Exception ex) {
ex.printStackTrace();
}
// no valid number
return -1;
}
use of java.lang.management.RuntimeMXBean in project opennms by OpenNMS.
the class JavaReportPlugin method getEntries.
@Override
public Map<String, Resource> getEntries() {
final TreeMap<String, Resource> map = new TreeMap<String, Resource>();
map.put("Class Version", getResourceFromProperty("java.class.version"));
map.put("Compiler", getResourceFromProperty("java.compiler"));
map.put("Home", getResourceFromProperty("java.home"));
map.put("Version", getResourceFromProperty("java.version"));
map.put("Vendor", getResourceFromProperty("java.vendor"));
map.put("VM Version", getResourceFromProperty("java.vm.version"));
map.put("VM Name", getResourceFromProperty("java.vm.name"));
MemoryMXBean memoryBean = getBean(ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class);
if (memoryBean == null) {
LOG.info("falling back to local VM MemoryMXBean");
memoryBean = ManagementFactory.getMemoryMXBean();
}
addGetters(memoryBean, map);
RuntimeMXBean runtimeBean = getBean(ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
if (runtimeBean == null) {
LOG.info("falling back to local VM RuntimeMXBean");
runtimeBean = ManagementFactory.getRuntimeMXBean();
}
addGetters(runtimeBean, map);
ClassLoadingMXBean classBean = getBean(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, ClassLoadingMXBean.class);
if (classBean == null) {
LOG.info("falling back to local VM ClassLoadingMXBean");
classBean = ManagementFactory.getClassLoadingMXBean();
}
addGetters(classBean, map);
return map;
}
use of java.lang.management.RuntimeMXBean in project geode by apache.
the class ResourceManagerValidator method validateJavaStartupParameters.
public static void validateJavaStartupParameters(GemFireCache cache) {
// Get the input arguments
ResourceManager rm = cache.getResourceManager();
RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
List<String> inputArguments = runtimeBean.getInputArguments();
if (cache.getLogger().fineEnabled()) {
cache.getLogger().fine("Full input java arguments: " + inputArguments);
}
// Validate the arguments based on VM vendor
String vmVendor = runtimeBean.getVmVendor();
if (vmVendor.startsWith("Sun") || vmVendor.startsWith("Apple")) {
// java.vm.vendor = Sun Microsystems Inc. || java.vm.vendor = Apple Inc.
validateSunArguments(cache, rm, inputArguments);
} else if (vmVendor.startsWith("IBM")) {
// java.vm.vendor = IBM Corporation
// TODO validate IBM input arguments
} else if (vmVendor.startsWith("BEA")) {
// java.vm.vendor = BEA Systems, Inc.
// TODO validate JRockit input arguments
}
}
Aggregations