Ticket #926: GCTime.patch
| File GCTime.patch, 3.8 KB (added by jsa, 3 years ago) |
|---|
-
plugins/javalib/org/munin/plugin/jmx/GCTimeGet.java
13 13 class GCTimeGet { 14 14 15 15 private ArrayList<GarbageCollectorMXBean> gcmbeans; 16 private String[] GCresult = new String[2];16 private long[] GCresult = new long[2]; 17 17 private MBeanServerConnection connection; 18 18 19 19 public GCTimeGet(MBeanServerConnection connection) { 20 20 this.connection = connection; 21 21 } 22 22 23 public String[] GC() throws IOException, MalformedObjectNameException {23 public long[] GC() throws IOException, MalformedObjectNameException { 24 24 ObjectName gcName = null; 25 25 26 26 gcName = new ObjectName( … … 41 41 int i = 0; 42 42 43 43 for (GarbageCollectorMXBean gc : gcmbeans) { 44 GCresult[i++] = formatMillis(gc.getCollectionTime());44 GCresult[i++] = gc.getCollectionTime(); 45 45 } 46 46 47 47 return GCresult; 48 48 } 49 50 private String formatMillis(long ms) {51 return String.format("%.4f", ms / (double) 1000);52 }53 49 } -
plugins/javalib/org/munin/plugin/jmx/GCTime.java
3 3 import org.munin.plugin.jmx.AbstractAnnotationGraphsProvider.Graph; 4 4 5 5 6 @Graph(title="GarbageCollectionTime", vlabel=" seconds", info="The Sun JVM defines garbage collection in two modes: Minor copy collections and Major Mark-Sweep-Compact collections. A minor collection runs relatively quickly and involves moving live data around the heap in the presence of running threads. A major collection is a much more intrusive garbage collection that suspends all execution threads while it completes its task. In terms of performance tuning the heap, the primary goal is to reduce the frequency and duration of major garbage collections.")6 @Graph(title="GarbageCollectionTime", vlabel="ms", info="The Sun JVM defines garbage collection in two modes: Minor copy collections and Major Mark-Sweep-Compact collections. A minor collection runs relatively quickly and involves moving live data around the heap in the presence of running threads. A major collection is a much more intrusive garbage collection that suspends all execution threads while it completes its task. In terms of performance tuning the heap, the primary goal is to reduce the frequency and duration of major garbage collections.") 7 7 public class GCTime extends AbstractAnnotationGraphsProvider { 8 8 9 private String[] times;9 private long[] times; 10 10 11 11 @Override 12 12 public void prepareValues() throws Exception { … … 14 14 times = collector.GC(); 15 15 } 16 16 17 @Field(label="MinorTime", info="The approximate accumulated collection elapsed time in seconds. This method returns -1 if the collection elapsed time is undefined for this collector.", type="DERIVE")18 public String copyTime() {17 @Field(label="MinorTime", info="The approximate accumulated collection elapsed time in milliseconds. This method returns -1 if the collection elapsed time is undefined for this collector.", type="DERIVE", min=0) 18 public long copyTime() { 19 19 return times[0]; 20 20 } 21 21 22 @Field(label="MajorTime", info="The approximate accumulated collection elapsed time in seconds. This method returns -1 if the collection elapsed time is undefined for this collector.", type="DERIVE")23 public String markSweepCompactTime() {22 @Field(label="MajorTime", info="The approximate accumulated collection elapsed time in milliseconds. This method returns -1 if the collection elapsed time is undefined for this collector.", type="DERIVE", min=0) 23 public long markSweepCompactTime() { 24 24 return times[1]; 25 25 } 26 26
