use of java.lang.management.RuntimeMXBean in project Mycat_plus by coderczp.
the class EnvironmentInformation method getJvmStartupOptions.
/**
* Gets the system parameters and environment parameters that were passed to the JVM on startup.
*
* @return The options passed to the JVM on startup.
*/
public static String getJvmStartupOptions() {
try {
final RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
final StringBuilder bld = new StringBuilder();
for (String s : bean.getInputArguments()) {
bld.append(s).append(' ');
}
return bld.toString();
} catch (Throwable t) {
return UNKNOWN;
}
}
use of java.lang.management.RuntimeMXBean in project traccar by traccar.
the class Log method logSystemInfo.
public static void logSystemInfo() {
try {
OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
Log.info("Operating system" + " name: " + operatingSystemBean.getName() + " version: " + operatingSystemBean.getVersion() + " architecture: " + operatingSystemBean.getArch());
RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
Log.info("Java runtime" + " name: " + runtimeBean.getVmName() + " vendor: " + runtimeBean.getVmVendor() + " version: " + runtimeBean.getVmVersion());
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
Log.info("Memory limit" + " heap: " + memoryBean.getHeapMemoryUsage().getMax() / (1024 * 1024) + "mb" + " non-heap: " + memoryBean.getNonHeapMemoryUsage().getMax() / (1024 * 1024) + "mb");
Log.info("Character encoding: " + System.getProperty("file.encoding") + " charset: " + Charset.defaultCharset());
} catch (Exception error) {
Log.warning("Failed to get system info");
}
}
use of java.lang.management.RuntimeMXBean in project mlib by myshzzx.
the class Oss method getPid.
/**
* get current process id.
*/
public static int getPid() {
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
String name = runtimeMXBean.getName();
int idx = name.indexOf('@');
return Integer.parseInt(name.substring(0, idx));
}
use of java.lang.management.RuntimeMXBean in project jmeter-plugins-manager by undera.
the class ChangesMaker method getRestartFile.
public File getRestartFile(LinkedList<String> additionalJMeterOptions) throws IOException {
File file = File.createTempFile("jpgc-restart-", ".list");
try (PrintWriter out = new PrintWriter(file)) {
out.print(SafeDeleter.getJVM() + "\n");
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
List<String> jvmArgs = runtimeMXBean.getInputArguments();
for (String arg : jvmArgs) {
out.print(arg + "\n");
}
out.print("-jar\n");
out.print(getJMeterStartCommand(additionalJMeterOptions));
return file;
}
}
use of java.lang.management.RuntimeMXBean in project wicket by apache.
the class Threads method dumpAllThreads.
/**
* Creates a dump of all the threads' state and stack traces similar to what JVM produces when
* signal SIGQUIT is send to the process on Unix machine.
* <p>
* Note: This is a best effort to dump as much information as possible because the Java API
* doesn't provide means to get all the information that is produced by jstack program for
* example.
* </p>
*
* @param logger
* the logger where the collected information will be written
*/
public static void dumpAllThreads(Logger logger) {
Args.notNull(logger, "logger");
if (!logger.isWarnEnabled()) {
return;
}
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
StringBuilder dump = new StringBuilder();
dump.append("Full thread dump ").append(runtimeMXBean.getVmName()).append('(').append(runtimeMXBean.getVmVersion()).append(')');
logger.warn(dump.toString());
Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
for (Entry<Thread, StackTraceElement[]> entry : allStackTraces.entrySet()) {
dumpSingleThread(logger, entry.getKey(), entry.getValue());
}
}
Aggregations