Search in sources :

Example 61 with RuntimeMXBean

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;
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) MultipartEntityBuilder(org.apache.http.entity.mime.MultipartEntityBuilder) GzipCompressingEntity(org.apache.http.client.entity.GzipCompressingEntity) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) RuntimeMXBean(java.lang.management.RuntimeMXBean) MemoryUsage(java.lang.management.MemoryUsage) NotNull(org.jetbrains.annotations.NotNull)

Example 62 with RuntimeMXBean

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;
}
Also used : RuntimeMXBean(java.lang.management.RuntimeMXBean) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(com.evolveum.midpoint.util.exception.SystemException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException)

Example 63 with RuntimeMXBean

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;
}
Also used : RuntimeMXBean(java.lang.management.RuntimeMXBean) URISyntaxException(java.net.URISyntaxException) ParseException(org.apache.commons.cli.ParseException)

Example 64 with RuntimeMXBean

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;
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean) Resource(org.springframework.core.io.Resource) ClassLoadingMXBean(java.lang.management.ClassLoadingMXBean) RuntimeMXBean(java.lang.management.RuntimeMXBean) TreeMap(java.util.TreeMap)

Example 65 with RuntimeMXBean

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
    }
}
Also used : ResourceManager(org.apache.geode.cache.control.ResourceManager) RuntimeMXBean(java.lang.management.RuntimeMXBean)

Aggregations

RuntimeMXBean (java.lang.management.RuntimeMXBean)92 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)16 MemoryMXBean (java.lang.management.MemoryMXBean)11 IOException (java.io.IOException)9 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)9 ThreadMXBean (java.lang.management.ThreadMXBean)8 MemoryUsage (java.lang.management.MemoryUsage)6 Method (java.lang.reflect.Method)6 ArrayList (java.util.ArrayList)6 ClassLoadingMXBean (java.lang.management.ClassLoadingMXBean)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Properties (java.util.Properties)5 InputStream (java.io.InputStream)4 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)4 Field (java.lang.reflect.Field)4 Date (java.util.Date)4 BufferedReader (java.io.BufferedReader)3 File (java.io.File)3 InputStreamReader (java.io.InputStreamReader)3