use of java.lang.management.OperatingSystemMXBean in project asterixdb by apache.
the class NCServiceTest method testJvmArgs.
@Test
public void testJvmArgs() {
Map<String, String> configuration = new HashMap<>();
OperatingSystemMXBean osMXBean = ManagementFactory.getOperatingSystemMXBean();
PA.setValue(NCService.class, "nodeSection", "nc/nc1");
PA.setValue(NCService.class, "osMXBean", osMXBean);
PA.invokeMethod(NCService.class, "configEnvironment(java.util.Map)", configuration);
String javaOpts = configuration.get("JAVA_OPTS");
String prefix = javaOpts.substring(4);
String sizeStr = prefix.substring(0, prefix.length() - 1);
int size = Integer.parseInt(sizeStr);
long ramSize = ((com.sun.management.OperatingSystemMXBean) osMXBean).getTotalPhysicalMemorySize();
int base = 1024 * 1024 * 5;
Assert.assertTrue(size == ramSize * 3 / base + ((ramSize * 3) % base == 0 ? 0 : 1));
}
use of java.lang.management.OperatingSystemMXBean in project asterixdb by apache.
the class GetNodeDetailsJSONWork method getCCDetails.
private ObjectNode getCCDetails() {
ObjectNode o = om.createObjectNode();
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
List<GarbageCollectorMXBean> gcMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
OperatingSystemMXBean osMXBean = ManagementFactory.getOperatingSystemMXBean();
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
if (includeConfig) {
o.put("os_name", osMXBean.getName());
o.put("arch", osMXBean.getArch());
o.put("os_version", osMXBean.getVersion());
o.put("num_processors", osMXBean.getAvailableProcessors());
o.put("vm_name", runtimeMXBean.getVmName());
o.put("vm_version", runtimeMXBean.getVmVersion());
o.put("vm_vendor", runtimeMXBean.getVmVendor());
o.putPOJO("classpath", runtimeMXBean.getClassPath().split(File.pathSeparator));
o.putPOJO("library_path", runtimeMXBean.getLibraryPath().split(File.pathSeparator));
o.putPOJO("boot_classpath", runtimeMXBean.getBootClassPath().split(File.pathSeparator));
o.putPOJO("input_arguments", runtimeMXBean.getInputArguments());
o.putPOJO("system_properties", runtimeMXBean.getSystemProperties());
o.put("pid", PidHelper.getPid());
}
if (includeStats) {
MemoryUsage heapUsage = memoryMXBean.getHeapMemoryUsage();
MemoryUsage nonheapUsage = memoryMXBean.getNonHeapMemoryUsage();
List<ObjectNode> gcs = new ArrayList<>();
for (GarbageCollectorMXBean gcMXBean : gcMXBeans) {
ObjectNode gc = om.createObjectNode();
gc.put("name", gcMXBean.getName());
gc.put("collection-time", gcMXBean.getCollectionTime());
gc.put("collection-count", gcMXBean.getCollectionCount());
gcs.add(gc);
}
o.putPOJO("gcs", gcs);
o.put("date", new Date().toString());
o.put("heap_init_size", heapUsage.getInit());
o.put("heap_used_size", heapUsage.getUsed());
o.put("heap_committed_size", heapUsage.getCommitted());
o.put("heap_max_size", heapUsage.getMax());
o.put("nonheap_init_size", nonheapUsage.getInit());
o.put("nonheap_used_size", nonheapUsage.getUsed());
o.put("nonheap_committed_size", nonheapUsage.getCommitted());
o.put("nonheap_max_size", nonheapUsage.getMax());
o.put("thread_count", threadMXBean.getThreadCount());
o.put("peak_thread_count", threadMXBean.getPeakThreadCount());
o.put("started_thread_count", threadMXBean.getTotalStartedThreadCount());
o.put("system_load_average", osMXBean.getSystemLoadAverage());
}
return o;
}
use of java.lang.management.OperatingSystemMXBean in project lucene-solr by apache.
the class OperatingSystemMetricSet method getMetrics.
@Override
public Map<String, Metric> getMetrics() {
final Map<String, Metric> metrics = new HashMap<>();
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
MetricUtils.addMXBeanMetrics(os, MetricUtils.OS_MXBEAN_CLASSES, null, (k, v) -> {
if (!metrics.containsKey(k)) {
metrics.put(k, v);
}
});
return metrics;
}
use of java.lang.management.OperatingSystemMXBean in project lucene-solr by apache.
the class SystemInfoHandler method getSystemInfo.
/**
* Get system info
*/
public static SimpleOrderedMap<Object> getSystemInfo() {
SimpleOrderedMap<Object> info = new SimpleOrderedMap<>();
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
// add at least this one
info.add(NAME, os.getName());
// add remaining ones dynamically using Java Beans API
// also those from JVM implementation-specific classes
MetricUtils.addMXBeanMetrics(os, MetricUtils.OS_MXBEAN_CLASSES, null, (name, metric) -> {
if (info.get(name) == null) {
info.add(name, ((Gauge) metric).getValue());
}
});
// Try some command line things:
try {
if (!Constants.WINDOWS) {
info.add("uname", execute("uname -a"));
info.add("uptime", execute("uptime"));
}
} catch (Exception ex) {
log.warn("Unable to execute command line tools to get operating system properties.", ex);
}
return info;
}
use of java.lang.management.OperatingSystemMXBean in project tdi-studio-se by Talend.
the class HeapHistogramPage method isSupported.
/**
* Gets the state indicating if heap histogram is supported.
* <p>
* WORKAROUND: Heap histogram is disabled on 64bit OS when monitoring eclipse itself, due to the issue that the
* method heapHisto() of the class HotSpotVirtualMachine causes continuously increasing the committed heap memory.
*
* @return <tt>true</tt> if heap histogram is supported
*/
boolean isSupported() {
IActiveJvm jvm = section.getJvm();
if (jvm == null) {
return false;
}
OperatingSystemMXBean osMBean = ManagementFactory.getOperatingSystemMXBean();
RuntimeMXBean runtimeMBean = ManagementFactory.getRuntimeMXBean();
if (osMBean.getArch().contains(ARCH_64BIT) && runtimeMBean.getName().contains(String.valueOf(jvm.getPid()))) {
return false;
}
return true;
}
Aggregations