use of java.lang.management.RuntimeMXBean in project geode by apache.
the class ProcessManager method getAgentString.
/**
* Get the java agent passed to this process and pass it to the child VMs. This was added to
* support jacoco code coverage reports
*/
private String getAgentString() {
RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
if (runtimeBean != null) {
for (String arg : runtimeBean.getInputArguments()) {
if (arg.contains("-javaagent:")) {
// HACK for gradle bug GRADLE-2859. Jacoco is passing a relative path
// That won't work when we pass this to dunit VMs in a different
// directory
arg = arg.replace("-javaagent:..", "-javaagent:" + System.getProperty("user.dir") + File.separator + "..");
arg = arg.replace("destfile=..", "destfile=" + System.getProperty("user.dir") + File.separator + "..");
return arg;
}
}
}
return "-DdummyArg=true";
}
use of java.lang.management.RuntimeMXBean in project karaf by apache.
the class EnvironmentDumpProvider method dumpVMInformation.
private void dumpVMInformation(final PrintWriter outPW, final DateFormat dateTimeFormatInstance) {
final RuntimeMXBean mxBean = ManagementFactory.getRuntimeMXBean();
if (mxBean == null) {
return;
}
outPW.printf(KEY_VALUE_FORMAT, "Instance name", mxBean.getName()).println();
outPW.printf(KEY_VALUE_FORMAT, "Start time", dateTimeFormatInstance.format(new Date(mxBean.getStartTime()))).println();
outPW.printf(KEY_VALUE_FORMAT, "Uptime", printDuration(mxBean.getUptime())).println();
outPW.println();
outPW.printf(KEY_VALUE_FORMAT, "Java VM", mxBean.getVmName() + " " + mxBean.getVmVersion()).println();
outPW.printf(INDENT_KEY_VALUE_FORMAT, "vendor", mxBean.getVmVendor()).println();
outPW.printf(INDENT_KEY_VALUE_FORMAT, "version", System.getProperty("java.version")).println();
outPW.println();
outPW.println("Input arguments:");
final List<String> inputArguments = mxBean.getInputArguments();
for (final String argument : inputArguments) {
if (argument != null && argument.contains("=")) {
final String[] split = argument.split("=");
outPW.printf(INDENT_KEY_VALUE_FORMAT, split[0], split[1]).println();
} else {
outPW.printf(INDENT_KEY_VALUE_FORMAT, argument, "").println();
}
}
outPW.println("Classpath:");
outPW.printf(INDENT_KEY_VALUE_FORMAT, "boot classpath", mxBean.getBootClassPath()).println();
outPW.printf(INDENT_KEY_VALUE_FORMAT, "library path", mxBean.getLibraryPath()).println();
outPW.printf(INDENT_KEY_VALUE_FORMAT, "classpath", mxBean.getClassPath()).println();
outPW.println("System properties:");
final Map<String, String> systemProperties = mxBean.getSystemProperties();
for (final Entry<String, String> property : systemProperties.entrySet()) {
outPW.printf(INDENT_KEY_VALUE_FORMAT, property.getKey(), property.getValue()).println();
}
outPW.println();
// JIT information
final CompilationMXBean compilationMXBean = ManagementFactory.getCompilationMXBean();
if (compilationMXBean != null) {
outPW.printf(KEY_VALUE_FORMAT, "JIT compiler", compilationMXBean.getName()).println();
outPW.printf(INDENT_KEY_VALUE_FORMAT, "total compile time", printDuration(compilationMXBean.getTotalCompilationTime())).println();
}
}
use of java.lang.management.RuntimeMXBean in project geode by apache.
the class LocatorStatusResponse method initialize.
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;
}
use of java.lang.management.RuntimeMXBean in project h2o-2 by h2oai.
the class VM method javaArgs.
static String[] javaArgs(String main) {
RuntimeMXBean r = ManagementFactory.getRuntimeMXBean();
ArrayList<String> list = new ArrayList<String>();
for (String s : r.getInputArguments()) if (!s.startsWith("-agentlib"))
if (!s.startsWith("-Xbootclasspath"))
list.add(s);
if (System.getProperty(H2O.DEBUG_ARG) != null)
if (list.indexOf("-D" + H2O.DEBUG_ARG) < 0)
list.add("-D" + H2O.DEBUG_ARG);
list.add(main);
return list.toArray(new String[list.size()]);
}
use of java.lang.management.RuntimeMXBean in project hazelcast by hazelcast.
the class PhoneHome method phoneHome.
public Map<String, String> phoneHome(Node hazelcastNode, String version, boolean isEnterprise) {
String downloadId = "source";
InputStream is = null;
try {
is = getClass().getClassLoader().getResourceAsStream("hazelcast-download.properties");
if (is != null) {
final Properties properties = new Properties();
properties.load(is);
downloadId = properties.getProperty("hazelcastDownloadId");
}
} catch (IOException ignored) {
EmptyStatement.ignore(ignored);
} finally {
IOUtil.closeResource(is);
}
//Calculate native memory usage from native memory config
NativeMemoryConfig memoryConfig = hazelcastNode.getConfig().getNativeMemoryConfig();
final ClusterServiceImpl clusterService = hazelcastNode.getClusterService();
long totalNativeMemorySize = clusterService.getSize(DATA_MEMBER_SELECTOR) * memoryConfig.getSize().bytes();
String nativeMemoryParameter = (isEnterprise) ? Long.toString(MemoryUnit.BYTES.toGigaBytes(totalNativeMemorySize)) : "0";
//Calculate connected clients to the cluster.
Map<ClientType, Integer> clusterClientStats = hazelcastNode.clientEngine.getConnectedClientStats();
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
OperatingSystemMXBean osMxBean = ManagementFactory.getOperatingSystemMXBean();
Long clusterUpTime = clusterService.getClusterClock().getClusterUpTime();
PhoneHomeParameterCreator parameterCreator = new PhoneHomeParameterCreator();
parameterCreator.addParam("version", version);
parameterCreator.addParam("m", hazelcastNode.getThisUuid());
parameterCreator.addParam("e", Boolean.toString(isEnterprise));
parameterCreator.addParam("l", MD5Util.toMD5String(hazelcastNode.getConfig().getLicenseKey()));
parameterCreator.addParam("p", downloadId);
parameterCreator.addParam("c", clusterService.getClusterId());
parameterCreator.addParam("crsz", convertToLetter(clusterService.getMembers().size()));
parameterCreator.addParam("cssz", convertToLetter(hazelcastNode.clientEngine.getClientEndpointCount()));
parameterCreator.addParam("hdgb", nativeMemoryParameter);
parameterCreator.addParam("ccpp", Integer.toString(clusterClientStats.get(ClientType.CPP)));
parameterCreator.addParam("cdn", Integer.toString(clusterClientStats.get(ClientType.CSHARP)));
parameterCreator.addParam("cjv", Integer.toString(clusterClientStats.get(ClientType.JAVA)));
parameterCreator.addParam("cnjs", Integer.toString(clusterClientStats.get(ClientType.NODEJS)));
parameterCreator.addParam("cpy", Integer.toString(clusterClientStats.get(ClientType.PYTHON)));
parameterCreator.addParam("cuptm", Long.toString(clusterUpTime));
parameterCreator.addParam("nuptm", Long.toString(runtimeMxBean.getUptime()));
parameterCreator.addParam("jvmn", runtimeMxBean.getVmName());
parameterCreator.addParam("jvmv", System.getProperty("java.version"));
JetBuildInfo jetBuildInfo = hazelcastNode.getBuildInfo().getJetBuildInfo();
parameterCreator.addParam("jetv", jetBuildInfo == null ? "" : jetBuildInfo.getVersion());
try {
parameterCreator.addParam("osn", osMxBean.getName());
parameterCreator.addParam("osa", osMxBean.getArch());
parameterCreator.addParam("osv", osMxBean.getVersion());
} catch (SecurityException e) {
parameterCreator.addParam("osn", "N/A");
parameterCreator.addParam("osa", "N/A");
parameterCreator.addParam("osv", "N/A");
}
String urlStr = BASE_PHONE_HOME_URL + parameterCreator.build();
fetchWebService(urlStr);
return parameterCreator.getParameters();
}
Aggregations