mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
monitor support
This commit is contained in:
@@ -24,7 +24,9 @@ import java.io.PrintWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
public class IOUtils {
|
||||
@@ -221,4 +223,27 @@ public class IOUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static int pid;
|
||||
|
||||
public final static int getPID() {
|
||||
if (pid == 0) {
|
||||
String name = ManagementFactory.getRuntimeMXBean().getName();
|
||||
|
||||
String[] items = name.split("@");
|
||||
|
||||
pid = Integer.parseInt(items[0]);
|
||||
}
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
private static Date startTime;
|
||||
|
||||
public final static Date getStartTime() {
|
||||
if (startTime == null) {
|
||||
startTime = new Date(ManagementFactory.getRuntimeMXBean().getStartTime());
|
||||
}
|
||||
return startTime;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user