|
@@ -9,6 +9,7 @@
|
|
|
|
|
|
package org.elasticsearch.monitor.jvm;
|
|
|
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
import org.elasticsearch.TransportVersions;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
@@ -30,10 +31,14 @@ import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import static org.apache.logging.log4j.LogManager.getLogger;
|
|
|
+
|
|
|
public class JvmInfo implements ReportingService.Info {
|
|
|
|
|
|
private static final JvmInfo INSTANCE;
|
|
|
|
|
|
+ private static final Logger logger = getLogger(JvmInfo.class);
|
|
|
+
|
|
|
static {
|
|
|
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
|
|
|
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
|
|
@@ -94,47 +99,63 @@ public class JvmInfo implements ReportingService.Info {
|
|
|
try {
|
|
|
Object onErrorObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "OnError");
|
|
|
onError = (String) valueMethod.invoke(onErrorObject);
|
|
|
- } catch (Exception ignored) {}
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("Error getting JVM info from MX Bean", e);
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
Object onOutOfMemoryErrorObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "OnOutOfMemoryError");
|
|
|
onOutOfMemoryError = (String) valueMethod.invoke(onOutOfMemoryErrorObject);
|
|
|
- } catch (Exception ignored) {}
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("Error getting JVM info from MX Bean", e);
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
Object useCompressedOopsVmOptionObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "UseCompressedOops");
|
|
|
useCompressedOops = (String) valueMethod.invoke(useCompressedOopsVmOptionObject);
|
|
|
- } catch (Exception ignored) {}
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("Error getting JVM info from MX Bean", e);
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
Object useG1GCVmOptionObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "UseG1GC");
|
|
|
useG1GC = (String) valueMethod.invoke(useG1GCVmOptionObject);
|
|
|
Object regionSizeVmOptionObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "G1HeapRegionSize");
|
|
|
g1RegisionSize = Long.parseLong((String) valueMethod.invoke(regionSizeVmOptionObject));
|
|
|
- } catch (Exception ignored) {}
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("Error getting JVM info from MX Bean", e);
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
Object initialHeapSizeVmOptionObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "InitialHeapSize");
|
|
|
configuredInitialHeapSize = Long.parseLong((String) valueMethod.invoke(initialHeapSizeVmOptionObject));
|
|
|
- } catch (Exception ignored) {}
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("Error getting JVM info from MX Bean", e);
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
Object maxHeapSizeVmOptionObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "MaxHeapSize");
|
|
|
configuredMaxHeapSize = Long.parseLong((String) valueMethod.invoke(maxHeapSizeVmOptionObject));
|
|
|
- } catch (Exception ignored) {}
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("Error getting JVM info from MX Bean", e);
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
Object maxDirectMemorySizeVmOptionObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "MaxDirectMemorySize");
|
|
|
directMemoryMax = Long.parseLong((String) valueMethod.invoke(maxDirectMemorySizeVmOptionObject));
|
|
|
- } catch (Exception ignored) {}
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("Error getting JVM info from MX Bean", e);
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
Object useSerialGCVmOptionObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "UseSerialGC");
|
|
|
useSerialGC = (String) valueMethod.invoke(useSerialGCVmOptionObject);
|
|
|
- } catch (Exception ignored) {}
|
|
|
-
|
|
|
- } catch (Exception ignored) {
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("Error getting JVM info from MX Bean", e);
|
|
|
+ }
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("Error getting JVM info from MX Bean", e);
|
|
|
}
|
|
|
|
|
|
Mem mem = new Mem(heapInit, heapMax, nonHeapInit, nonHeapMax, directMemoryMax);
|